:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --ink: #25211d;
  --muted: #716a62;
  --line: #ded7cc;
  --green: #2f6f5e;
  --green-dark: #24564a;
  --blue: #275f8f;
  --amber: #a96d12;
  --red: #b95045;
  --violet: #66518d;
  --shadow: 0 20px 50px rgba(41, 34, 24, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}

.eyebrow,
.section-kicker,
.meta-label {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions,
.view-actions,
.button-row,
.card-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}

.primary-button {
  background: var(--green);
  color: white;
  border-color: var(--green);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--green-dark);
}

.ghost-button {
  border-color: var(--line);
}

.ghost-button:hover,
.icon-button:hover {
  border-color: var(--green);
}

.danger-button {
  color: var(--red);
  border-color: rgba(185, 80, 69, 0.35);
  background: #fff8f6;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.file-button input {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
}

.sidebar {
  min-height: calc(100vh - 86px);
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  position: sticky;
  top: 86px;
  align-self: start;
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.nav-group-label {
  margin: 14px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: var(--ink);
  background: #ffffff;
  border-color: var(--line);
}

.nav-item.active {
  box-shadow: 0 8px 24px rgba(41, 34, 24, 0.07);
}

.side-checklist {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.side-checklist ol {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.8;
  font-size: 14px;
}

.workspace {
  min-width: 0;
  padding: 30px 34px 56px;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.view-header h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.view-header p {
  margin: 8px 0 0;
  max-width: 720px;
  color: var(--muted);
  line-height: 1.7;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

.band-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.band-title h3 {
  margin: 0;
  font-size: 18px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

.process-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.process-step {
  border-left: 4px solid var(--green);
  background: #f8fbf9;
  padding: 14px;
  border-radius: 8px;
  min-height: 112px;
}

.process-step:nth-child(2) {
  border-color: var(--blue);
  background: #f6f9fc;
}

.process-step:nth-child(3) {
  border-color: var(--amber);
  background: #fffaf0;
}

.process-step:nth-child(4) {
  border-color: var(--violet);
  background: #f9f7fd;
}

.process-step h4,
.item-card h3,
.compact-card h3 {
  margin: 0;
  font-size: 16px;
}

.process-step p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.item-card,
.compact-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.item-card {
  display: grid;
  gap: 12px;
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-card {
  display: grid;
  gap: 8px;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  line-height: 1.7;
}

.item-title-row,
.form-grid,
.filters {
  display: grid;
  gap: 12px;
}

.item-title-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #f1eee8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tag.green {
  background: #e7f1ed;
  color: var(--green-dark);
}

.tag.blue {
  background: #e8f0f8;
  color: var(--blue);
}

.tag.amber {
  background: #fff0d4;
  color: #85530a;
}

.tag.red {
  background: #fff0ee;
  color: var(--red);
}

.tag.violet {
  background: #eee9f8;
  color: var(--violet);
}

.muted {
  color: var(--muted);
}

.small-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.detail-text {
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.question-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe5da;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--value);
  background: linear-gradient(90deg, var(--green), var(--blue));
}

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

.form-field {
  display: grid;
  gap: 7px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-field label {
  font-weight: 700;
  font-size: 14px;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

.form-field textarea {
  min-height: 98px;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: 3px solid rgba(47, 111, 94, 0.16);
  border-color: var(--green);
}

.filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.filters .full {
  grid-column: 1 / -1;
}

.note-filter-actions {
  margin: -8px 0 18px;
}

.participation-panel {
  display: grid;
  gap: 10px;
  max-height: 460px;
  overflow: auto;
  padding-right: 4px;
}

.participation-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.participation-item input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.participation-item h4 {
  margin: 0;
  font-size: 15px;
}

.note-helper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.note-helper span {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.ai-draft-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.coach-step {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.coach-step h3 {
  margin: 0;
  font-size: 18px;
}

.ai-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.review-box,
.answer-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.answer-panel summary {
  cursor: pointer;
  color: var(--green-dark);
  font-weight: 700;
}

.answer-panel .detail-text {
  margin-top: 10px;
}

.sync-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sync-steps li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--muted);
  line-height: 1.7;
}

.sync-steps strong {
  color: var(--ink);
}

.step-number {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e7f1ed;
  color: var(--green-dark);
  font-weight: 800;
}

.code-block {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #27231f;
  color: #fffaf3;
  line-height: 1.7;
  white-space: pre-wrap;
}

.paste-box textarea {
  min-height: 260px;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 13px;
}

.sync-log {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(37, 33, 29, 0.36);
}

.modal-panel {
  position: relative;
  width: min(860px, 100%);
  max-height: min(840px, calc(100vh - 48px));
  overflow: auto;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 21px;
}

#modalBody {
  padding: 22px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;
  max-width: 360px;
  border-radius: 8px;
  padding: 13px 15px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav-group-label {
    grid-column: 1 / -1;
  }

  .workspace {
    padding: 24px 18px 44px;
  }

  .metrics-grid,
  .process-grid,
  .split-grid,
  .ai-draft-grid,
  .note-helper {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 20px 16px;
  }

  .topbar-actions,
  .view-header,
  .view-actions,
  .button-row,
  .inline-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .topbar-actions > *,
  .view-actions > *,
  .button-row > *,
  .inline-actions > * {
    width: 100%;
  }

  .sidebar nav,
  .metrics-grid,
  .process-grid,
  .split-grid,
  .ai-draft-grid,
  .form-grid,
  .filters,
  .note-helper,
  .participation-item {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 10px;
  }
}
