:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #69707a;
  --line: #d9dde3;
  --paper: #fbfbf8;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --gold: #ffe58f;
  --gold-line: #d8a900;
  --blue: #2457c5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #eef1f0;
}

button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-size: 14px;
  cursor: pointer;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

input,
select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 84px;
  resize: vertical;
  padding: 10px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #9bd7d0;
  border-color: var(--accent);
}

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

.primary:not(:disabled):hover {
  background: var(--accent-dark);
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.panel,
.reader {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 16px;
  position: sticky;
  top: 16px;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px dashed #9ba4b0;
  border-radius: 8px;
  background: #f7f8f7;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}

.dropzone input {
  display: none;
}

.uploadIcon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #e6f3f1;
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.dropzone strong {
  margin-top: 12px;
  font-size: 16px;
}

.dropzone small + small {
  margin-top: 4px;
}

.fileList {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.fileItem {
  display: grid;
  grid-template-columns: 54px 1fr 36px;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  cursor: pointer;
}

.fileItem.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.fileItem:hover {
  border-color: #9fb9b5;
}

.fileDivider {
  height: 1px;
  background: var(--line);
  margin: 0 4px;
}

.fileThumb {
  width: 54px;
  height: 66px;
  display: grid;
  place-items: center;
  border: 1px solid #b8c2cc;
  border-radius: 4px;
  background: linear-gradient(180deg, #ffffff 0%, #eef3f7 100%);
  color: #385166;
  font-size: 12px;
  font-weight: 800;
  position: relative;
}

.fileThumb::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 15px;
  height: 15px;
  background: #d9e4ec;
  border-left: 1px solid #b8c2cc;
  border-bottom: 1px solid #b8c2cc;
  border-radius: 0 4px 0 3px;
}

.fileMeta {
  min-width: 0;
}

.fileMeta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.fileMeta small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.progressBox {
  display: none;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf9;
  padding: 11px;
}

.progressMeta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.progressMeta span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progressMeta strong {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
}

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

.progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 260ms ease;
}

.removeFileBtn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.dropzone small,
.metricGrid small,
.emptyState span {
  color: var(--muted);
}

.metricGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.metricGrid div {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.metricGrid span {
  display: block;
  font-size: 28px;
  font-weight: 750;
  color: var(--blue);
}

.themes,
.colorThemes,
.modelStatus {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.panelTools {
  position: sticky;
  top: 12px;
  z-index: 12;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  background: var(--panel);
  justify-content: stretch;
}

.panelTools select,
.panelTools button {
  width: 100%;
}

.themes h2,
.colorThemes h2,
.modelStatus h2,
.reader h2 {
  font-size: 16px;
  line-height: 1.35;
}

.themeList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.themeList span {
  border: 1px solid #b8d6d1;
  background: #eff8f6;
  color: #075e56;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
}

.colorThemeList {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.colorThemeList span,
.colorChip {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 650;
  border: 1px solid transparent;
}

.modelStatus p {
  margin-top: 8px;
  line-height: 1.55;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.modelStatus .ready {
  color: #075e56;
}

.modelStatus .missing {
  color: #9a3412;
}

.reader {
  min-height: calc(100vh - 158px);
  overflow: hidden;
}

.readerHeader {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 82px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.docName {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
}

.tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.tools select {
  width: 150px;
  height: 38px;
  font-size: 14px;
}

.emptyState {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 360px;
  text-align: center;
  padding: 32px;
  color: var(--ink);
}

.revisionBox {
  display: none;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f7faf9;
}

.revisionBox label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.revisionControls {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 10px;
  align-items: stretch;
}

.revisionControls button {
  height: auto;
  min-height: 84px;
}

.titlePreview {
  display: none;
  gap: 10px;
  padding: 18px 18px 0;
  background: var(--paper);
}

.themeTitleBlock {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  padding: 14px 16px;
}

.themeTitleBlock span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.themeTitleBlock strong {
  display: block;
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

.segments {
  display: none;
  padding: 18px;
  background: var(--paper);
}

.segment {
  width: 100%;
  display: block;
  text-align: left;
  height: auto;
  min-height: 44px;
  padding: 10px 12px;
  margin: 0 0 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  line-height: 1.75;
  cursor: text;
}

.segment:hover {
  border-color: #b9c0ca;
  background: #fff;
}

.segmentText {
  margin: 0;
  white-space: pre-wrap;
}

.highlight {
  display: inline;
  border-radius: 3px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  padding: 1px 2px;
}

.orderBadge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-right: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.76);
  color: currentColor;
  font-size: 11px;
  line-height: 1;
  font-weight: 850;
  vertical-align: text-bottom;
  user-select: none;
}

.color-blue {
  background: #dbeafe;
  border-color: #93c5fd;
  border-bottom: 2px solid #2563eb;
}

.color-blue.hookHighlight {
  background: #1d4ed8;
  border-color: #1e40af;
  border-bottom-color: #172554;
  color: #fff;
}

.color-green {
  background: #dcfce7;
  border-color: #86efac;
  border-bottom: 2px solid #16a34a;
}

.color-green.hookHighlight {
  background: #15803d;
  border-color: #166534;
  border-bottom-color: #14532d;
  color: #fff;
}

.color-orange {
  background: #ffedd5;
  border-color: #fdba74;
  border-bottom: 2px solid #ea580c;
}

.color-orange.hookHighlight {
  background: #c2410c;
  border-color: #9a3412;
  border-bottom-color: #7c2d12;
  color: #fff;
}

.color-yellow {
  background: #fef3c7;
  border-color: #facc15;
  border-bottom: 2px solid #ca8a04;
}

.color-yellow.hookHighlight {
  background: #a16207;
  border-color: #854d0e;
  border-bottom-color: #713f12;
  color: #fff;
}

.color-pink {
  background: #fce7f3;
  border-color: #f9a8d4;
  border-bottom: 2px solid #db2777;
}

.color-pink.hookHighlight {
  background: #be185d;
  border-color: #9d174d;
  border-bottom-color: #831843;
  color: #fff;
}

.color-red {
  background: #fee2e2;
  border-color: #fecaca;
  border-bottom: 2px solid #f87171;
}

.color-red.hookHighlight {
  background: #dc2626;
  border-color: #b91c1c;
  border-bottom-color: #7f1d1d;
  color: #fff;
}

.settingsDialog {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(32, 33, 36, 0.22);
}

.settingsDialog::backdrop {
  background: rgba(26, 32, 36, 0.45);
}

.settingsForm {
  padding: 18px;
}

.dialogHeader {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.dialogHeader p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

#closeSettingsBtn {
  width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.settingsForm label {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.settingsForm label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.dialogActions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 860px) {
  .shell {
    padding: 12px;
  }

  .topbar,
  .readerHeader {
    align-items: stretch;
    flex-direction: column;
  }

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

  .panel {
    position: static;
  }

  .topActions,
  .primary,
  .tools select,
  .tools button {
    width: 100%;
  }

  .topActions button,
  .revisionControls,
  .dialogActions button {
    width: 100%;
  }

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

  .revisionControls button {
    min-height: 42px;
  }
}
