:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --ink: #16201f;
  --muted: #61706d;
  --line: #d9dfdc;
  --panel: #ffffff;
  --accent: #0f7a6a;
  --accent-strong: #075f53;
  --warn: #a95813;
  --shadow: 0 18px 50px rgba(20, 32, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #eef4f2 0%, var(--bg) 38%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
}

a.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 0 12px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.danger {
  border-color: rgba(169, 88, 19, 0.36);
  background: rgba(169, 88, 19, 0.08);
  color: var(--warn);
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 16px;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.app-shell {
  width: 100%;
  padding: 24px;
}

.workspace {
  max-width: 1320px;
  margin: 0 auto;
}

.narrow-workspace {
  max-width: 860px;
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 48px);
  place-items: center;
}

.auth-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  padding: 26px;
}

.auth-copy {
  color: var(--muted);
  line-height: 1.6;
  margin: 12px 0 20px;
}

.auth-form,
.auth-actions {
  display: grid;
  gap: 12px;
}

.auth-actions {
  grid-template-columns: 1fr 1fr;
}

.auth-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  min-height: 20px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.api-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.user-pill,
.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(15, 122, 106, 0.22);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(15, 122, 106, 0.08);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 800;
}

.version-pill {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 700;
}

.api-pill.ready {
  border-color: rgba(15, 122, 106, 0.28);
  color: var(--accent-strong);
}

.api-pill.missing {
  border-color: rgba(169, 88, 19, 0.28);
  color: var(--warn);
}

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

.control-band {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(220px, 1fr) 150px 160px;
  gap: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.field,
.toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.toggle {
  justify-content: end;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.toggle input:checked + span {
  border-color: var(--accent);
  background: rgba(15, 122, 106, 0.1);
  color: var(--accent-strong);
}

.recorder {
  padding: 16px;
  margin-bottom: 14px;
}

.scene-panel {
  min-height: 0;
}

.scene-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px;
}

.context-field {
  min-width: 0;
}

.scene-hint {
  grid-column: 1 / -1;
  border: 1px solid rgba(15, 122, 106, 0.18);
  border-radius: 8px;
  background: rgba(15, 122, 106, 0.06);
  color: #38504b;
  line-height: 1.6;
  padding: 12px 14px;
  word-break: break-word;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e9e6;
  margin-bottom: 14px;
}

.meter div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f7a6a, #e0a228);
  transition: width 120ms ease;
}

.record-actions,
.status-line,
.panel-header,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-actions {
  flex-wrap: wrap;
}

.status-line {
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, 0.92fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  min-height: 560px;
  overflow: hidden;
}

.right-stack {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.panel-header {
  justify-content: space-between;
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
}

.transcript-list {
  height: 500px;
  overflow: auto;
  padding: 16px;
}

.empty {
  color: var(--muted);
  margin: 0;
}

.segment {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid #edf0ef;
  padding: 13px 0;
}

.segment:first-child {
  padding-top: 0;
}

.speaker {
  color: var(--accent-strong);
  font-weight: 800;
  word-break: break-word;
}

.segment-text {
  line-height: 1.7;
  word-break: break-word;
}

#minutesOutput {
  height: 500px;
  margin: 0;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #24302e;
  line-height: 1.65;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.history-panel {
  min-height: 220px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.history-item {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  text-align: left;
}

.history-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
}

.history-meta {
  color: var(--muted);
  font-size: 12px;
}

.history-preview {
  display: -webkit-box;
  overflow: hidden;
  color: #33413f;
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.knowledge-panel {
  min-height: 320px;
}

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

.knowledge-subhead {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.knowledge-list,
.quiz-list {
  display: grid;
  gap: 10px;
}

.knowledge-item,
.qa-result-item,
.quiz-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.qa-result-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
}

.qa-result-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(15, 122, 106, 0.1);
  color: var(--accent-strong);
  font-weight: 900;
}

.qa-result-content {
  min-width: 0;
}

.qa-parent-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.4;
  word-break: break-word;
}

.knowledge-item-title,
.quiz-question {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.4;
  word-break: break-word;
}

.quiz-question {
  margin-top: 10px;
}

.qa-chain {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(15, 122, 106, 0.16);
  border-radius: 8px;
  background: rgba(15, 122, 106, 0.05);
  padding: 10px;
}

.qa-chain-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  color: #33413f;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
}

.qa-chain-label {
  color: var(--accent-strong);
  font-weight: 800;
}

.knowledge-item-meta,
.quiz-reason,
.verify-result {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.knowledge-item-summary {
  margin-top: 8px;
  color: #33413f;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.compact-summary {
  color: var(--muted);
  font-size: 12px;
}

.result-notice {
  border: 1px solid rgba(15, 122, 106, 0.22);
  border-radius: 8px;
  background: rgba(15, 122, 106, 0.07);
  color: var(--accent-strong);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

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

.detail-panel {
  min-height: 520px;
}

.detail-panel pre {
  height: 460px;
  margin: 0;
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #24302e;
  line-height: 1.65;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.wide-list {
  padding: 16px;
}

.knowledge-search-band {
  grid-template-columns: minmax(220px, 1fr) 180px 150px 120px 120px;
}

.token-box,
.learning-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.token-box input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.token-secret {
  min-height: 24px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  word-break: break-all;
}

.qa-preview {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.qa-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.qa-section-empty {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.qa-entry {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid rgba(15, 122, 106, 0.18);
  border-radius: 8px;
  background: rgba(15, 122, 106, 0.035);
  padding: 10px;
}

.qa-entry.single {
  margin-top: 10px;
}

.qa-entry-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(15, 122, 106, 0.12);
  color: var(--accent-strong);
  font-weight: 900;
}

.qa-entry-body {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.qa-entry-question,
.qa-entry-answer {
  color: #33413f;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.qa-entry-question::before {
  content: "Q";
  margin-right: 8px;
  color: var(--accent-strong);
  font-weight: 900;
}

.qa-entry-answer::before {
  content: "A";
  margin-right: 8px;
  color: var(--warn);
  font-weight: 900;
}

.knowledge-editor {
  width: min(920px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
}

.knowledge-editor::backdrop {
  background: rgba(22, 32, 31, 0.38);
}

.knowledge-editor-card {
  background: #fff;
}

.editor-body {
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 120px);
  overflow: auto;
  padding: 16px;
}

.editor-body textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  font: inherit;
  line-height: 1.55;
}

.editor-qa-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.editor-qa-head h3 {
  margin: 0;
}

.editor-qa-list {
  display: grid;
  gap: 12px;
}

.editor-qa-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(0, 1fr) 128px;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.editor-qa-item.is-deleted {
  border-color: rgba(184, 83, 18, 0.34);
  background: rgba(184, 83, 18, 0.05);
}

.editor-qa-item.is-deleted textarea {
  color: var(--muted);
  text-decoration: line-through;
}

.editor-qa-index {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(15, 122, 106, 0.1);
  color: var(--accent-strong);
  font-weight: 900;
}

.editor-qa-actions {
  display: grid;
  align-content: start;
  gap: 8px;
}

.editor-qa-badge {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-actions {
  margin-top: 10px;
}

.no-margin {
  margin-top: 0;
}

.learning-panel {
  min-height: 360px;
}

.manual-knowledge-panel {
  min-height: 360px;
  margin-bottom: 14px;
}

.manual-knowledge-body {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 220px 160px 190px;
  gap: 14px;
  padding: 16px;
}

.manual-file-button {
  align-self: end;
}

.manual-text-field {
  grid-column: 1 / -1;
}

.manual-knowledge-body > .auth-status,
.manual-qa-preview {
  grid-column: 1 / -1;
}

.manual-text-field textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  font: inherit;
  line-height: 1.6;
}

.quiz-answer {
  width: 100%;
  min-height: 78px;
  margin-top: 10px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  font: inherit;
  line-height: 1.5;
}

.quiz-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .control-band,
  .main-grid,
  .detail-grid,
  .manual-knowledge-body,
  .editor-qa-item,
  .history-list,
  .knowledge-grid,
  .knowledge-search-band {
    grid-template-columns: 1fr;
  }

  .panel,
  .transcript-list,
  #minutesOutput {
    min-height: 420px;
    height: 420px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .inline-actions {
    width: 100%;
  }

  .inline-actions button {
    flex: 1;
  }
}
