*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --manual-ink: #1c1917;
  --manual-muted: #6b625b;
  --manual-soft: #fffaf3;
  --manual-paper: #ffffff;
  --manual-line: #eadfce;
  --manual-blue: #2563eb;
  --manual-green: #059669;
  --manual-rose: #dc2626;
  --manual-violet: #6d28d9;
  --manual-shadow: 0 12px 34px rgba(41, 37, 36, .08);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  background: #f9f5ee;
  color: var(--manual-ink);
  line-height: 1.75;
}

a {
  color: var(--c-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.manual-page {
  min-height: 100vh;
}

.manual-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 250, 243, .96);
  border-bottom: 1px solid var(--manual-line);
  backdrop-filter: blur(12px);
}

.manual-header-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  color: var(--manual-ink);
  font-weight: 800;
  white-space: nowrap;
}

.brand-link img {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-actions a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: .45rem .75rem;
  font-size: .86rem;
  font-weight: 800;
}

.header-actions .ghost {
  color: #57534e;
  border: 1px solid var(--manual-line);
  background: #fff;
}

.header-actions .primary {
  color: #fff;
  background: var(--c-primary);
  border: 1px solid var(--c-primary);
}

.manual-hero {
  background:
    linear-gradient(115deg, rgba(255, 243, 226, .96), rgba(255, 255, 255, .92)),
    radial-gradient(circle at 88% 18%, rgba(37, 99, 235, .18), transparent 26%),
    radial-gradient(circle at 20% 78%, rgba(5, 150, 105, .14), transparent 26%);
  border-bottom: 1px solid var(--manual-line);
}

.manual-hero-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 2.4rem 0 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 2rem;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--c-primary-dark);
  background: #fff;
  border: 1px solid var(--c-border-tint);
  border-radius: 999px;
  padding: .24rem .7rem;
  font-size: .78rem;
  font-weight: 800;
  margin-bottom: .8rem;
}

.manual-hero h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.22;
  letter-spacing: 0;
}

.lead {
  margin: 1rem 0 0;
  color: #4b4037;
  font-size: 1.02rem;
  max-width: 760px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: 1.1rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-height: 34px;
  padding: .35rem .7rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--manual-line);
  color: #57534e;
  font-size: .82rem;
  font-weight: 700;
}

.hero-panel {
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--manual-line);
  border-radius: 8px;
  box-shadow: var(--manual-shadow);
  padding: 1rem;
}

.app-signal {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: .8rem;
  align-items: center;
  margin-bottom: .85rem;
}

.app-signal img {
  width: 58px;
  height: 58px;
  border-radius: 14px;
}

.app-signal strong {
  display: block;
  font-size: 1.02rem;
}

.app-signal span {
  display: block;
  color: var(--manual-muted);
  font-size: .84rem;
}

.flow-mini {
  display: grid;
  gap: .45rem;
}

.flow-mini div {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 42px;
  padding: .55rem .65rem;
  border-radius: 7px;
  border: 1px solid #f1e5d5;
  background: #fffaf3;
  font-size: .85rem;
  font-weight: 700;
}

.flow-mini b {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  font-size: .78rem;
  flex: 0 0 auto;
}

.manual-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 1.4rem 0 3rem;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.4rem;
  min-width: 0;
}

.toc {
  position: sticky;
  top: 84px;
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--manual-line);
  border-radius: 8px;
  box-shadow: 0 1px 8px rgba(41, 37, 36, .05);
  padding: 1rem;
}

.toc-title {
  margin: 0 0 .7rem;
  font-size: .84rem;
  font-weight: 900;
  color: #57534e;
}

.toc a {
  display: block;
  padding: .34rem .45rem;
  border-radius: 6px;
  color: #4b5563;
  font-size: .84rem;
  font-weight: 700;
}

.toc a:hover {
  background: var(--c-tint);
  color: var(--c-primary-dark);
  text-decoration: none;
}

.manual-content {
  min-width: 0;
  display: grid;
  gap: 1rem;
}

.section {
  background: #fff;
  border: 1px solid var(--manual-line);
  border-radius: 8px;
  box-shadow: 0 1px 8px rgba(41, 37, 36, .05);
  padding: 1.25rem;
  scroll-margin-top: 86px;
  min-width: 0;
}

.section.compact {
  padding-bottom: 1rem;
}

.section h2 {
  margin: 0 0 .45rem;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  line-height: 1.35;
  letter-spacing: 0;
}

.section h3 {
  margin: 1.2rem 0 .45rem;
  font-size: 1.02rem;
  line-height: 1.45;
  letter-spacing: 0;
}

.section h4 {
  margin: 1rem 0 .35rem;
  font-size: .94rem;
  line-height: 1.45;
  color: #374151;
}

.section p {
  margin: .45rem 0;
  color: #4b4037;
  overflow-wrap: anywhere;
}

.subtle {
  color: var(--manual-muted);
  font-size: .9rem;
}

.note,
.warning,
.success {
  margin: .85rem 0;
  border-radius: 8px;
  padding: .75rem .85rem;
  font-size: .9rem;
}

.note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #7c2d12;
}

.warning {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
}

.success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: .8rem;
  margin: .85rem 0;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.info-card {
  border: 1px solid #eadfce;
  border-radius: 8px;
  background: #fffdf9;
  padding: .9rem;
  min-width: 0;
}

.info-card strong {
  display: block;
  margin-bottom: .25rem;
  color: #1f2937;
}

.info-card p {
  margin: 0;
  font-size: .88rem;
  color: #5f5851;
}

.role-card {
  border-left: 4px solid var(--c-primary);
}

.role-card:nth-child(2) {
  border-left-color: var(--manual-blue);
}

.role-card:nth-child(3) {
  border-left-color: var(--manual-green);
}

.role-card:nth-child(4) {
  border-left-color: var(--manual-violet);
}

.role-card:nth-child(5) {
  border-left-color: var(--manual-rose);
}

.step-list {
  counter-reset: step;
  display: grid;
  gap: .65rem;
  margin: .85rem 0;
}

.step-item {
  counter-increment: step;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: .65rem;
  align-items: start;
  padding: .75rem;
  border: 1px solid var(--manual-line);
  border-radius: 8px;
  background: #fffdf9;
}

.step-item::before {
  content: counter(step);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  font-weight: 900;
  font-size: .84rem;
}

.step-item strong {
  display: block;
  margin-bottom: .15rem;
  color: #1f2937;
}

.step-item p {
  margin: 0;
  font-size: .9rem;
}

.list {
  margin: .6rem 0;
  padding-left: 1.2rem;
}

.list li {
  margin: .28rem 0;
}

.definition-list {
  display: grid;
  gap: .45rem;
  margin: .75rem 0;
}

.definition {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: .8rem;
  padding: .65rem .75rem;
  border: 1px solid #efe5d8;
  border-radius: 7px;
  background: #fffdf9;
}

.definition dt {
  font-weight: 900;
  color: #1f2937;
}

.definition dd {
  margin: 0;
  color: #4b4037;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: .7rem 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: .18rem .62rem;
  font-size: .78rem;
  font-weight: 900;
  border: 1px solid transparent;
}

.badge.pending {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.badge.approved,
.badge.active {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.badge.rejected,
.badge.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.badge.neutral {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #374151;
}

.badge.blue {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.table-wrap {
  overflow-x: auto;
  margin: .85rem 0;
  border: 1px solid var(--manual-line);
  border-radius: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  background: #fff;
  font-size: .88rem;
}

th,
td {
  padding: .68rem .75rem;
  border-bottom: 1px solid #f0e7db;
  text-align: left;
  vertical-align: top;
}

th {
  background: #fff7ed;
  color: #374151;
  font-weight: 900;
}

tr:last-child td {
  border-bottom: 0;
}

.flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .6rem;
  margin: .85rem 0;
}

.flow-step {
  position: relative;
  min-height: 112px;
  border-radius: 8px;
  border: 1px solid var(--manual-line);
  background: #fffdf9;
  padding: .8rem;
}

.flow-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -.45rem;
  width: .55rem;
  height: .55rem;
  border-top: 2px solid var(--c-primary);
  border-right: 2px solid var(--c-primary);
  transform: translateY(-50%) rotate(45deg);
  background: #f9f5ee;
}

.flow-step b {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  margin-bottom: .45rem;
}

.flow-step strong {
  display: block;
  line-height: 1.45;
}

.flow-step span {
  display: block;
  margin-top: .25rem;
  color: var(--manual-muted);
  font-size: .82rem;
}

.check-panel {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
  padding: .85rem;
}

.check-panel ul {
  margin: .45rem 0 0;
  padding-left: 1.1rem;
}

.screen-index {
  display: grid;
  gap: .55rem;
  margin: .85rem 0;
}

.screen-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  border: 1px solid var(--manual-line);
  border-radius: 8px;
  background: #fffdf9;
  padding: .65rem .75rem;
  color: #292524;
}

.screen-link:hover {
  border-color: var(--c-border-mid);
  background: #fff7ed;
  text-decoration: none;
}

.screen-link span:first-child {
  font-weight: 900;
}

.screen-link span:last-child {
  color: var(--manual-muted);
  font-size: .82rem;
  overflow-wrap: anywhere;
}

.mini-code {
  display: inline-block;
  padding: .05rem .35rem;
  border-radius: 5px;
  background: #f3f4f6;
  color: #374151;
  font-family: Consolas, "Courier New", monospace;
  font-size: .85em;
}

.footer {
  border-top: 1px solid var(--manual-line);
  background: #fffaf3;
}

.footer-inner {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 1.2rem 0;
  display: flex;
  gap: .8rem;
  align-items: center;
  justify-content: space-between;
  color: #57534e;
  font-size: .86rem;
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  gap: .8rem;
  flex-wrap: wrap;
}

@media (max-width: 980px) {
  .manual-hero-inner,
  .manual-shell {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    max-width: 560px;
  }

  .toc {
    position: static;
    max-height: none;
  }

  .toc nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .2rem .4rem;
  }

  .grid-3,
  .grid-4,
  .flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .manual-header-inner,
  .manual-hero-inner,
  .manual-shell,
  .footer-inner {
    width: min(100% - 22px, 1180px);
  }

  .manual-header-inner {
    align-items: flex-start;
    padding: .65rem 0;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    margin-left: 0;
    justify-content: stretch;
  }

  .header-actions a {
    flex: 1;
    padding: .45rem .55rem;
  }

  .manual-hero-inner {
    padding: 1.55rem 0 1.2rem;
  }

  .section {
    padding: 1rem;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .flow {
    grid-template-columns: 1fr;
  }

  .toc {
    max-height: 360px;
    overflow: auto;
  }

  .toc nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .15rem .25rem;
  }

  .toc a {
    padding: .3rem .35rem;
    font-size: .78rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  .definition {
    grid-template-columns: 1fr;
    gap: .2rem;
  }

  .flow-step {
    min-height: auto;
  }

  .flow-step:not(:last-child)::after {
    display: none;
  }

  .screen-link {
    align-items: flex-start;
    flex-direction: column;
    gap: .15rem;
  }
}

@media (max-width: 420px) {
  .header-actions a {
    min-width: calc(50% - .3rem);
  }

  .section {
    padding: .9rem;
  }

  table {
    font-size: .82rem;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .manual-header,
  .toc,
  .header-actions,
  .footer {
    display: none !important;
  }

  .manual-hero {
    border-bottom: 1px solid #999;
    background: #fff;
  }

  .manual-hero-inner,
  .manual-shell {
    width: 100%;
    display: block;
    padding: 0;
  }

  .hero-panel {
    display: none;
  }

  .section {
    box-shadow: none;
    border: 1px solid #bbb;
    break-inside: avoid;
    margin: 0 0 .8rem;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
