:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #f0f3f7;
  --line: #d9dee7;
  --line-strong: #b9c2d0;
  --text: #17202e;
  --muted: #667085;
  --muted-strong: #475467;
  --accent: #176b63;
  --accent-strong: #0f564f;
  --accent-soft: #e2f3ef;
  --danger: #b42318;
  --danger-soft: #fff0ed;
  --warn: #8a4b0d;
  --warn-soft: #fff4df;
  --ok: #12715d;
  --ok-soft: #e6f6f0;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(23, 107, 99, 0.25);
  outline-offset: 2px;
}

body[data-drawer-open="true"] {
  overflow: hidden;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 20;
  transform: translateY(-140%);
  background: #ffffff;
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.node-rail {
  background: #101820;
  color: #edf2f7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid #24313f;
}

.rail-head {
  padding: 22px 18px 14px;
  border-bottom: 1px solid #253444;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.node-rail .eyebrow {
  color: #9aa8b8;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 760;
}

h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 760;
}

h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 720;
}

.rail-note {
  margin: 8px 0 0;
  color: #b8c4d2;
  font-size: 13px;
  line-height: 1.5;
}

.rail-back-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-top: 12px;
  padding: 0 10px;
  border: 1px solid #35475a;
  border-radius: 6px;
  color: #edf2f7;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.rail-back-link:hover {
  background: #1a2633;
}

.node-list {
  padding: 12px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
}

.node-button {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  color: #e8edf3;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.node-button:hover {
  background: #1a2633;
}

.node-button[data-active="true"] {
  background: #e7f4f1;
  color: #0f312e;
}

.node-title {
  font-size: 14px;
  font-weight: 690;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-meta {
  flex: 0 0 auto;
  color: currentColor;
  opacity: 0.75;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.top-actions,
.button-group,
.action-row,
.panel-head,
.editor-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.path-line {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.78fr) minmax(320px, 1fr) minmax(320px, 1fr);
  align-items: stretch;
  gap: 16px;
  margin-top: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.asr-panel,
.prompt-panel,
.output-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.asr-textarea,
.prompt-editor {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
  color: var(--text);
  resize: vertical;
  line-height: 1.65;
  padding: 12px;
}

.field-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.asr-textarea {
  min-height: 360px;
  flex: 1 1 auto;
}

.asr-textarea.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px rgba(23, 107, 99, 0.18);
}

.prompt-editor {
  min-height: 420px;
  flex: 1 1 auto;
  margin-top: 10px;
  font-family: Consolas, "Microsoft YaHei", monospace;
  font-size: 13px;
}

.prompt-editor:disabled {
  color: #98a2b3;
  background: #f7f8fa;
}

.action-row {
  justify-content: space-between;
  margin-top: 12px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.step-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}

.step-button {
  height: 38px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 760;
}

.step-button:hover {
  border-color: var(--line-strong);
}

.step-button[data-active="true"] {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 680;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.secondary-btn {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

.secondary-btn:hover {
  border-color: var(--line-strong);
}

.ghost-btn {
  color: var(--accent-strong);
  background: transparent;
}

.ghost-btn:hover {
  background: var(--accent-soft);
}

.compact-btn {
  min-height: 32px;
  padding: 6px 10px;
}

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

.status-pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface-soft);
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill[data-mode="ok"] {
  background: var(--ok-soft);
  color: var(--ok);
}

.status-pill[data-mode="busy"] {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-pill[data-mode="error"] {
  background: var(--danger-soft);
  color: var(--danger);
}

.report-links {
  min-height: 36px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 12px;
}

.report-links a {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid #bee4dc;
  border-radius: 6px;
  padding: 7px 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 680;
}

.report-links a:hover {
  border-color: var(--accent);
}

.run-log {
  flex: 1 1 auto;
  min-height: 420px;
  max-height: none;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111820;
  color: #dce6f0;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(16, 24, 32, 0.42);
}

.drawer-overlay[hidden] {
  display: none;
}

.lesson-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  width: min(760px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 50px rgba(16, 24, 40, 0.18);
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  transform: translateX(100%);
  transition: transform 160ms ease;
}

.video-drawer {
  width: min(860px, 100vw);
}

.lesson-drawer[aria-hidden="false"] {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.drawer-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.lesson-tab {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 720;
}

.lesson-tab:hover {
  border-color: var(--line-strong);
}

.lesson-tab[data-active="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.lesson-tab[data-exists="false"] {
  color: var(--danger);
  background: var(--danger-soft);
}

.lesson-tools {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
  background: #ffffff;
}

.lesson-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.download-link {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.download-link:hover {
  text-decoration: underline;
}

.download-link[aria-disabled="true"] {
  color: var(--muted);
  pointer-events: none;
}

.lesson-content {
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.75;
}

.lesson-content.native-preview {
  padding: 18px;
  overflow: auto;
  background: #eef1f5;
}

.lesson-content.docx-native-preview {
  padding: 22px;
  background: #e6eaf0;
  line-height: normal;
}

.docx-loading {
  width: min(100%, 794px);
  margin: 0 auto;
  padding: 24px;
  background: #ffffff;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  color: var(--muted);
}

.docx-wrapper {
  background: transparent !important;
  padding: 0 !important;
}

.docx-wrapper > section.docx {
  margin: 0 auto 18px !important;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
  border: 1px solid #d5dbe5;
}

.docx-wrapper > section.docx:last-child {
  margin-bottom: 0 !important;
}

.docx-wrapper table {
  border-collapse: collapse;
}

.docx-wrapper img {
  max-width: 100%;
}

.docx-preview {
  white-space: normal;
}

.docx-preview:not(.docx-native-preview) h1,
.docx-preview:not(.docx-native-preview) h2,
.docx-preview:not(.docx-native-preview) h3 {
  margin: 18px 0 8px;
  color: #17202e;
}

.docx-preview:not(.docx-native-preview) h1 {
  font-size: 22px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.docx-preview:not(.docx-native-preview) h2 {
  font-size: 18px;
}

.docx-preview:not(.docx-native-preview) h3 {
  font-size: 16px;
}

.docx-preview:not(.docx-native-preview) p {
  margin: 8px 0;
}

.docx-preview:not(.docx-native-preview) ul,
.docx-preview:not(.docx-native-preview) ol {
  margin: 8px 0 8px 24px;
  padding: 0;
}

.docx-preview:not(.docx-native-preview) table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  background: #ffffff;
}

.docx-preview:not(.docx-native-preview) td,
.docx-preview:not(.docx-native-preview) th {
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
  line-height: 1.65;
}

.docx-preview:not(.docx-native-preview) tr:first-child td {
  background: var(--surface-soft);
  font-weight: 700;
}

.search-result-text {
  margin: 0;
  white-space: pre-wrap;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  line-height: 1.75;
}

.video-tool-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.video-tool-section h3 {
  font-size: 15px;
}

.section-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.capability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.capability-item {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.capability-item[data-ok="true"] {
  border-color: #bce3d8;
  background: var(--ok-soft);
}

.capability-item[data-ok="false"] {
  border-color: #f4beb7;
  background: var(--danger-soft);
}

.capability-item strong {
  font-size: 13px;
}

.capability-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-all;
}

.file-input {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 8px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
}

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

.video-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 13px;
}

.video-results-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(120px, 0.8fr) minmax(140px, 1fr);
}

.video-fill-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0;
}

.video-fill-item {
  min-height: 34px;
  border-radius: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted-strong);
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  font-weight: 680;
}

.video-fill-item[data-filled="true"] {
  color: var(--accent-strong);
  border-color: #bee4dc;
  background: var(--accent-soft);
}

.video-log {
  max-height: none;
  min-height: 140px;
}

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

  .node-rail {
    min-height: auto;
  }

  .node-list {
    grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
    max-height: 260px;
  }

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

  .output-panel {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 12px;
  }

  .topbar,
  .panel-head,
  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .button-group {
    justify-content: stretch;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    min-height: 44px;
    width: 100%;
  }

  .node-button,
  .step-button {
    min-height: 44px;
  }

  .asr-textarea,
  .prompt-editor,
  .run-log {
    min-height: 280px;
  }

  .lesson-drawer {
    padding: 12px;
  }

  .drawer-head,
  .lesson-meta-row,
  .search-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .capability-grid,
  .video-fill-list {
    grid-template-columns: 1fr;
  }

  .download-link {
    white-space: normal;
  }
}

.beian-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 20px 22px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.beian-footer__icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex: 0 0 auto;
}

.beian-footer a {
  color: inherit;
  text-decoration: none;
}

.beian-footer a:hover,
.beian-footer a:focus-visible {
  color: var(--accent-strong);
  text-decoration: underline;
}
