:root {
  --bg: #f3f9ff;
  --bg-2: #eef7ff;
  --surface: #ffffff;
  --surface-blue: #f7fbff;
  --line: #d7e8f6;
  --line-strong: #b9d8ef;
  --text: #193246;
  --text-soft: #425b70;
  --muted: #6f8799;
  --blue: #2f8ec8;
  --blue-strong: #1d6f9f;
  --blue-soft: #e7f5ff;
  --green: #2d8a68;
  --amber: #aa7524;
  --red: #b65a5a;
  --shadow: 0 14px 34px rgba(45, 126, 176, 0.1);
  --radius: 8px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(116, 196, 237, 0.22), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, var(--bg-2) 100%);
  color: var(--text);
  font-family:
    "Avenir Next", Satoshi, Geist, "Helvetica Neue", Arial, "Microsoft YaHei",
    sans-serif;
  line-height: 1.55;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

ul,
ol {
  margin-top: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 22px;
  width: min(100%, 1460px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.sidebar {
  position: sticky;
  top: 18px;
  height: calc(100dvh - 36px);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--blue-soft);
  color: var(--blue-strong);
  font-weight: 900;
}

.brand strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
}

.brand small,
.role-button small,
.sidebar-block small {
  color: var(--muted);
}

.role-switcher {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.role-button {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  text-align: left;
  transition:
    transform 220ms var(--ease),
    border-color 220ms var(--ease),
    background 220ms var(--ease);
}

.role-button:hover,
.role-button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  outline: none;
}

.role-button.active {
  border-color: #83c7ee;
  background: #eef8ff;
}

.role-button span {
  font-weight: 850;
}

.role-button small {
  font-size: 12px;
}

.sidebar-block {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-blue);
}

.tiny-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.sidebar-block strong {
  display: block;
  margin: 3px 0 2px;
  color: var(--blue-strong);
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 36px;
  line-height: 1;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 6px 6px 40px;
}

.page-header {
  order: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--blue-strong);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin-bottom: 6px;
  color: var(--text);
  font-size: clamp(27px, 2.45vw, 38px);
  font-weight: 850;
  line-height: 1.12;
}

.subtitle {
  max-width: 820px;
  margin-bottom: 0;
  color: var(--text-soft);
  font-size: 14px;
}

.header-actions {
  display: grid;
  grid-template-columns: auto auto;
  gap: 10px;
}

.primary-action,
.secondary-action,
.panel-toggle,
.answer-toggle {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border-radius: var(--radius);
  font-weight: 850;
  transition:
    transform 200ms var(--ease),
    border-color 200ms var(--ease),
    background 200ms var(--ease);
}

.primary-action,
.answer-toggle {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
  box-shadow: 0 10px 20px rgba(47, 142, 200, 0.18);
}

.secondary-action,
.panel-toggle {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--blue-strong);
}

.panel-toggle {
  display: none;
}

.primary-action:hover,
.secondary-action:hover,
.answer-toggle:hover,
.panel-toggle:hover {
  transform: translateY(-1px);
}

.panel,
.metrics {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.knowledge-panel {
  order: 3;
}

.question-bank {
  order: 2;
  overflow: hidden;
}

.metrics {
  order: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 14px;
  overflow: hidden;
}

.panel {
  margin-top: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin-bottom: 3px;
  color: var(--text);
  font-size: 18px;
  font-weight: 850;
}

.panel-head p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.knowledge-panel .panel-toggle {
  display: none;
}

.panel-body {
  display: block;
}

.knowledge-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.knowledge-card {
  display: grid;
  gap: 7px;
  min-height: 128px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  text-align: left;
  transition:
    transform 220ms var(--ease),
    border-color 220ms var(--ease),
    background 220ms var(--ease);
}

.knowledge-card:hover,
.knowledge-card:focus-visible {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: #f8fcff;
  outline: none;
}

.knowledge-card.active {
  border-color: #77c1eb;
  background: #edf8ff;
}

.knowledge-card h3 {
  margin: 0;
  color: var(--blue-strong);
  font-size: 15px;
  font-weight: 850;
}

.knowledge-card p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12px;
}

.knowledge-meta,
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid #c9e4f6;
  border-radius: 999px;
  background: #f7fcff;
  color: var(--blue-strong);
  font-size: 11px;
  font-weight: 850;
}

.pill.must {
  border-color: #f0d9a8;
  color: var(--amber);
}

.pill.strong {
  border-color: #bde7d7;
  color: var(--green);
}

.pill.risk {
  border-color: #efc4c4;
  color: var(--red);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 230px 180px;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.toolbar label {
  display: grid;
  gap: 5px;
}

.toolbar span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.toolbar input,
.toolbar select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.toolbar input:focus,
.toolbar select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 142, 200, 0.13);
}

.bank-layout {
  display: block;
  min-height: 0;
  padding: 14px;
  background: #f7fcff;
}

.question-list {
  display: grid;
  gap: 12px;
  align-content: start;
  max-height: none;
  overflow: visible;
  background: transparent;
  border-right: 0;
}

.question-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 10px 22px rgba(47, 142, 200, 0.06);
  transition:
    border-color 180ms var(--ease),
    box-shadow 180ms var(--ease),
    transform 180ms var(--ease);
}

.question-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.question-card.active {
  border-color: #8dccf1;
  box-shadow: 0 16px 34px rgba(47, 142, 200, 0.11);
}

.question-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  width: 100%;
  min-height: 82px;
  align-items: center;
  padding: 15px 16px;
  border: 0;
  background: white;
  color: var(--text);
  text-align: left;
}

.question-row:hover,
.question-row:focus-visible {
  background: #fbfdff;
  outline: none;
}

.question-card.active .question-row {
  background: var(--blue-soft);
}

.question-index {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid #c9e4f6;
  border-radius: 50%;
  background: #ffffff;
  color: var(--blue-strong);
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 850;
}

.question-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.question-row strong {
  color: var(--text);
  font-size: 17px;
  font-weight: 850;
  line-height: 1.38;
}

.question-row small {
  color: var(--muted);
  font-size: 12px;
}

.row-action {
  display: inline-flex;
  min-width: 52px;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 1px solid #c9e4f6;
  border-radius: 999px;
  background: #f7fcff;
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 850;
}

.inline-answer {
  padding: 0 18px 18px 66px;
  background:
    linear-gradient(180deg, rgba(231, 245, 255, 0.58), rgba(255, 255, 255, 0.9) 180px),
    #ffffff;
  border-top: 1px solid var(--line);
}

.inline-answer h3 {
  margin-bottom: 12px;
  color: var(--text);
  font-size: clamp(20px, 2vw, 28px);
  font-weight: 850;
  line-height: 1.25;
}

.detail-meta {
  padding-top: 18px;
  margin-bottom: 12px;
}

.answer-toggle {
  margin-bottom: 4px;
}

.answer-block,
.full-answer-content {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.answer-block h4,
.full-answer-content h4 {
  margin: 0 0 7px;
  color: var(--blue-strong);
  font-size: 13px;
  font-weight: 900;
}

.answer-block p,
.answer-block li,
.full-answer-content p,
.full-answer-content li {
  color: var(--text-soft);
}

.full-answer {
  display: none;
}

.full-answer.is-open {
  display: block;
}

.dense-list {
  margin: 0;
  padding-left: 18px;
}

.dense-list li {
  margin: 7px 0;
}

.dense-list li::marker {
  color: var(--blue);
}

.warning li::marker {
  color: var(--amber);
}

.metrics article {
  display: grid;
  gap: 3px;
  min-height: 82px;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.metrics article:last-child {
  border-right: 0;
}

.metrics span,
.metrics small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.metrics strong {
  color: var(--blue-strong);
  font-family: "SF Mono", "JetBrains Mono", Consolas, monospace;
  font-size: 26px;
  line-height: 1.05;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-blue);
  color: var(--muted);
  text-align: center;
}

.single-question {
  cursor: default;
}

.question-nav {
  display: grid;
  grid-template-columns: minmax(100px, auto) 1fr minmax(100px, auto);
  align-items: center;
  gap: 12px;
  padding: 14px 18px 18px 66px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.question-nav span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.nav-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sidebar {
    position: relative;
    top: auto;
    height: auto;
  }

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

  .sidebar-block {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

@media (max-width: 920px) {
  body {
    background: linear-gradient(180deg, #ffffff 0%, #edf8ff 100%);
  }

  .app-shell {
    padding: 10px;
  }

  .sidebar {
    padding: 10px;
  }

  .brand {
    grid-template-columns: 34px minmax(0, 1fr);
    padding-bottom: 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .brand strong {
    font-size: 13px;
  }

  .brand small {
    display: none;
  }

  .role-switcher {
    gap: 8px;
    margin-top: 10px;
  }

  .role-button {
    min-height: 54px;
    padding: 10px;
  }

  .role-button span {
    font-size: 13px;
  }

  .role-button small {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-block {
    margin-top: 10px;
    padding: 10px;
  }

  .sidebar-block strong {
    font-size: 28px;
  }

  .workspace {
    padding: 0 0 22px;
  }

  .page-header {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 10px;
  }

  h1 {
    font-size: 23px;
  }

  .subtitle {
    display: none;
  }

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

  .knowledge-map,
  .toolbar,
  .bank-layout,
  .metrics {
    grid-template-columns: 1fr;
  }

  .metrics article {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metrics article:last-child {
    border-bottom: 0;
  }

  .knowledge-map {
    padding: 10px;
  }

  .knowledge-card {
    min-height: 96px;
    padding: 12px;
  }

  .panel-head {
    padding: 12px;
  }

  .panel-head h2 {
    font-size: 16px;
  }

  .panel-head p {
    font-size: 12px;
  }

  .toolbar {
    padding: 12px;
  }

  .bank-layout {
    display: block;
    min-height: 0;
    padding: 10px;
  }

  .question-list {
    max-height: none;
  }

  .question-row {
    min-height: auto;
    grid-template-columns: auto minmax(0, 1fr);
    padding: 12px;
  }

  .question-row strong {
    font-size: 14px;
  }

  .question-index {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .row-action {
    display: none;
  }

  .inline-answer {
    padding: 0 13px 14px;
  }

  .inline-answer h3 {
    font-size: 18px;
  }

  .question-nav {
    grid-template-columns: 1fr auto 1fr;
    padding: 12px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 8px;
  }

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

  .primary-action,
  .secondary-action {
    min-height: 38px;
    padding: 0 10px;
    font-size: 13px;
  }
}
