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

:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-soft: #fbfaf8;
  --text: #171717;
  --muted: #6b7280;
  --line: #e5e1da;
  --dark: #26211d;
  --green: #047857;
  --green-bg: #dff5ea;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(39, 32, 26, .08);
  --radius: 10px;
  --max-w: 840px;
  --sidebar-w: 220px;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.layout {
  display: flex;
  height: 100%;
}

.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-w);
  background: #2f2924;
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-close {
  display: none;
}

.sidebar-brand {
  padding: 1.6rem 1.2rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-eyebrow {
  color: #f7c974;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-title {
  margin-top: .15rem;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.15;
}

.sidebar-nav {
  flex: 1;
  padding: .6rem .6rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .7rem .75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-item.active {
  background: rgba(192, 138, 47, .22);
  color: #f7c974;
}

.sidebar-icon {
  font-size: 1.15rem;
  width: 1.4rem;
  text-align: center;
  flex-shrink: 0;
}

.main-area {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

.app-shell {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.2rem 1rem 3rem;
}

.phase-panel {
  animation: fadeIn .2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1rem;
}

.stat-card {
  min-height: 5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}

.stat-value {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
  font-weight: 900;
}

.stat-label {
  display: block;
  margin-top: .35rem;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}

.tone-green .stat-value { color: var(--green); }
.tone-blue .stat-value { color: var(--blue); }
.tone-amber .stat-value { color: var(--amber); }
.tone-red .stat-value { color: var(--red); }
.tone-dark .stat-value { color: var(--dark); }

.controls {
  margin-bottom: 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
}

.search-box {
  display: grid;
  gap: .35rem;
}

.search-box span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.search-input-row {
  display: flex;
  gap: .5rem;
}

.search-input-row input {
  flex: 1;
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: .55rem .7rem;
  outline: none;
}

.search-input-row input:focus {
  border-color: #c08a2f;
  box-shadow: 0 0 0 3px rgba(192, 138, 47, .16);
}

.search-btn {
  flex-shrink: 0;
  min-height: 2.6rem;
  padding: .55rem 1rem;
  border: 1px solid #c08a2f;
  border-radius: 8px;
  background: #c08a2f;
  color: #fff;
  font-weight: 800;
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s;
}

.search-btn:hover {
  background: #a67a26;
}

.search-box input {
  width: 100%;
  min-height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: .55rem .7rem;
  outline: none;
}

.search-box input:focus {
  border-color: #c08a2f;
  box-shadow: 0 0 0 3px rgba(192, 138, 47, .16);
}

.result-bar {
  display: flex;
  gap: .75rem;
  align-items: center;
  justify-content: space-between;
  margin-top: .9rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .88rem;
}

.result-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border: none;
  background: transparent;
  color: var(--amber);
  font-size: .88rem;
  font-weight: 800;
}

.check-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.part-header {
  margin: 1.8rem 0 1rem;
  padding-bottom: .6rem;
  border-bottom: 3px solid #2f2924;
}

.part-header:first-child {
  margin-top: 0;
}

.part-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: #2f2924;
  letter-spacing: .06em;
}

.group-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.4rem 0 .3rem;
  padding: 0 0 .4rem;
  border-bottom: 2px solid var(--line);
}

.group-header:first-child {
  margin-top: 0;
}

.group-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #2f2924;
  letter-spacing: .04em;
}

.group-role {
  font-size: .85rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .2rem .6rem;
  color: var(--muted);
  font-weight: 700;
}

.group-note {
  margin: .2rem 0 .6rem;
  color: var(--muted);
  font-size: .82rem;
  font-style: italic;
  padding-left: .2rem;
}

.section-note {
  padding: .3rem 1.1rem .5rem;
  margin-top: -.3rem;
  color: var(--muted);
  font-size: .8rem;
  font-style: italic;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.item-sub {
  padding: .5rem 1.1rem .2rem;
  color: var(--amber);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.check-item.has-sub {
  padding-left: 1.5rem;
  border-left: 3px solid transparent;
}

.check-item.has-sub:hover {
  border-left-color: var(--line);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.1rem;
  background: #2f2924;
  color: #fff;
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}

.section-header:hover {
  background: #3b342d;
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0;
}

.section-header h2 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.role-badge {
  flex-shrink: 0;
  font-size: .82rem;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: .15rem .55rem;
  color: #f7c974;
  font-weight: 700;
}

.section-header-right {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

.section-count {
  font-size: .75rem;
  font-weight: 700;
  color: #f7c974;
}

.section-arrow {
  font-size: .85rem;
  transition: transform .2s ease;
  color: #f7c974;
}

.check-section.open .section-arrow {
  transform: rotate(90deg);
}

.section-body {
  overflow: hidden;
  transition: max-height .3s ease, opacity .2s ease;
}

.check-section.collapsed .section-body {
  max-height: 0 !important;
  opacity: 0;
}

.check-section.collapsed .section-note {
  display: none;
}

.check-list {
  padding: .5rem 0;
}

.check-item {
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.check-item:last-child {
  border-bottom: none;
}

.check-q {
  font-weight: 700;
  color: var(--text);
  font-size: .94rem;
  line-height: 1.5;
}

.check-hint {
  margin-top: .3rem;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.55;
}

.contract-list {
  padding: .5rem 0;
}

.contract-item {
  display: flex;
  gap: .9rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--line);
}

.contract-item:last-child {
  border-bottom: none;
}

.contract-num {
  flex-shrink: 0;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  background: #2f2924;
  color: #f7c974;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .82rem;
  font-weight: 900;
  letter-spacing: .04em;
}

.contract-body {
  min-width: 0;
}

.contract-q {
  font-weight: 700;
  color: var(--text);
  font-size: .94rem;
  line-height: 1.5;
}

.empty-state {
  margin-top: 1rem;
  border: 1px dashed #c9c1b7;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .6);
  padding: 2rem;
  text-align: center;
}

.empty-state p {
  margin-top: .4rem;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
  padding: 1.5rem 1rem;
  text-align: center;
}

.checklist-ol {
  margin: 0;
  padding: .8rem 1.1rem .8rem 2.4rem;
  counter-reset: checklist-counter;
  list-style: none;
}

.checklist-ol li {
  position: relative;
  padding: .6rem 0 .6rem 2rem;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: .94rem;
  line-height: 1.5;
  counter-increment: checklist-counter;
}

.checklist-ol > li:last-child {
  border-bottom: none;
}

.checklist-ol > li::before {
  content: counter(checklist-counter);
  position: absolute;
  left: -.2rem;
  top: .6rem;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  background: #2f2924;
  color: #f7c974;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 900;
}

.checklist-q {
  font-weight: 600;
}

.checklist-note {
  margin: .3rem 0 0;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 400;
  line-height: 1.55;
}

.checklist-sub {
  margin: .4rem 0 0;
  padding-left: 1.2rem;
  list-style: none;
}

.checklist-sub li {
  position: relative;
  padding: .2rem 0 .2rem 1rem;
  font-size: .85rem;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.55;
  border-bottom: none;
  counter-increment: none;
}

.checklist-sub li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--muted);
}

@media (max-width: 719px) {
  :root {
    --sidebar-w: 220px;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: .5rem;
    left: .5rem;
    z-index: 15;
    width: 2.3rem;
    height: 2.3rem;
    border: none;
    border-radius: 8px;
    background: #2f2924;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    -webkit-backface-visibility: hidden;
    transition: opacity .2s;
  }

  .sidebar-toggle:hover {
    opacity: .85;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 24;
    background: rgba(0, 0, 0, .45);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 25;
    -webkit-backface-visibility: hidden;
    -webkit-transform: translateX(-100%);
    transform: translateX(-100%);
    will-change: transform;
    transition: -webkit-transform .25s ease, transform .25s ease;
    width: var(--sidebar-w);
  }

  body.sidebar-open .sidebar {
    -webkit-transform: translateX(0);
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: .5rem;
    right: .5rem;
    width: 1.8rem;
    height: 1.8rem;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, .1);
    color: rgba(255, 255, 255, .7);
    font-size: .9rem;
    cursor: pointer;
    transition: background .15s;
  }

  .sidebar-close:hover {
    background: rgba(255, 255, 255, .18);
    color: #fff;
  }

  .sidebar-brand {
    padding: 1.2rem .8rem .9rem;
    position: relative;
  }

  .sidebar-title {
    font-size: 1.1rem;
  }

  .sidebar-nav {
    padding: .4rem .4rem .8rem;
  }

  .sidebar-item {
    padding: .6rem .6rem;
    font-size: .82rem;
  }

  .main-area {
    padding-top: .2rem;
  }
}
