:root {
  color-scheme: light;
  --ink: #17233a;
  --muted: #64748b;
  --line: #eadde2;
  --canvas: #faf8f9;
  --surface: #ffffff;
  --forest: #b63667;
  --forest-dark: #8f244e;
  --mint: #f7dce7;
  --amber: #b66b12;
  --amber-soft: #fff2d7;
  --danger: #b42318;
  --danger-soft: #fee4e2;
  --shadow: 0 14px 30px rgba(84, 33, 53, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

button, input, textarea { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; min-height: 100vh; padding: 28px 18px 20px; border-right: 1px solid var(--line); background: #f8edf2; }
.brand-lockup { display: flex; align-items: center; gap: 11px; padding: 0 8px; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; color: #fff; border-radius: 7px; background: var(--forest); font-weight: 800; font-size: 19px; }
.brand-lockup h1, .brand-lockup p { margin: 0; }
.brand-lockup h1 { font-size: 19px; line-height: 1.1; letter-spacing: 0; }
.eyebrow { margin: 0 0 3px; color: var(--forest); font-size: 12px; font-weight: 700; letter-spacing: 0; }
.nav-list { display: grid; gap: 4px; margin-top: 42px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 11px; color: #405062; border: 0; border-radius: 5px; background: transparent; text-align: left; }
.nav-item span { min-width: 22px; color: var(--muted); font-size: 12px; text-align: center; }
.nav-item:hover { background: rgba(182, 54, 103, 0.08); }
.nav-item.active { color: var(--forest-dark); background: var(--mint); font-weight: 700; }
.sidebar-footer { margin-top: auto; padding: 14px 8px 0; border-top: 1px solid rgba(23, 35, 58, 0.1); color: var(--muted); font-size: 12px; }
.sidebar-footer p { margin: 4px 0; }

.main-content { min-width: 0; padding: 0 38px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 108px; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 23px; line-height: 1.25; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.system-status { max-width: 210px; color: var(--muted); font-size: 12px; text-align: right; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 13px; border: 1px solid transparent; border-radius: 5px; font-weight: 700; line-height: 1.2; text-decoration: none; transition: background 160ms ease, border-color 160ms ease, color 160ms ease; }
.button-primary { color: #fff; background: var(--forest); }
.button-primary:hover { background: var(--forest-dark); }
.button-primary:disabled { cursor: not-allowed; opacity: 0.55; }
.button-quiet { color: #415167; border-color: var(--line); background: var(--surface); }
.button-quiet:hover { color: var(--forest-dark); border-color: var(--forest); }
.button-danger { color: var(--danger); border-color: #e8c4cb; background: #fff7f8; }
.button-danger:hover { border-color: var(--danger); background: var(--danger-soft); }

.import-band { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr); gap: 30px; padding: 35px 0; border-bottom: 1px solid var(--line); }
.import-copy h3, .section-heading h3, .lesson-header h3, .panel-heading h4 { margin: 0; letter-spacing: 0; }
.import-copy h3 { max-width: 460px; font-size: 26px; line-height: 1.28; }
.import-copy > p:last-child { max-width: 590px; margin: 12px 0 0; color: var(--muted); }
.drop-target { display: flex; flex-direction: column; justify-content: center; min-height: 146px; padding: 24px; border: 1px dashed #d59ab2; border-radius: 7px; background: #fffafb; cursor: pointer; transition: border-color 160ms ease, background 160ms ease; }
.drop-target:hover, .drop-target.dragging { border-color: var(--forest); background: #fdf0f5; }
.drop-title { color: var(--forest-dark); font-weight: 800; font-size: 16px; }
.drop-detail { margin-top: 6px; color: var(--muted); font-size: 13px; }

.course-section { padding-top: 30px; }
.section-heading, .panel-heading, .lesson-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.section-heading h3 { font-size: 20px; }
.course-meta { margin: 21px 0 0; color: var(--muted); font-size: 13px; }
.course-list { margin-top: 14px; border-top: 1px solid var(--line); }
.course-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; padding: 5px 0; border-bottom: 1px solid var(--line); }
.course-open { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 14px; align-items: center; width: 100%; min-width: 0; padding: 11px 5px; border: 0; background: transparent; text-align: left; }
.course-open:disabled { cursor: default; opacity: 0.72; }
.course-row:hover .course-name { color: var(--forest-dark); }
.course-row-actions { display: flex; align-items: center; gap: 5px; }
.icon-button { display: grid; width: 34px; height: 34px; place-items: center; padding: 0; color: #526373; border: 1px solid transparent; border-radius: 5px; background: transparent; font-weight: 800; font-size: 18px; }
.icon-button:hover { color: var(--forest-dark); border-color: var(--line); background: #fff; }
.icon-button.danger:hover { color: var(--danger); border-color: #e8c4cb; background: var(--danger-soft); }
.course-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 5px; color: var(--forest-dark); background: var(--mint); font-weight: 800; }
.course-name { display: block; overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.course-details { display: block; margin-top: 2px; color: var(--muted); font-size: 13px; }
.course-learning { display: block; margin-top: 6px; color: #3f5968; font-size: 12px; font-weight: 700; }
.course-watch-progress { display: block; width: min(260px, 100%); height: 3px; margin-top: 5px; overflow: hidden; background: #e6edf0; }
.course-watch-progress span { display: block; height: 100%; background: #4b8290; }
.status-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 4px; color: #526373; background: #e8edf0; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-badge.ready { color: var(--forest-dark); background: var(--mint); }
.status-badge.working { color: #8a4b00; background: var(--amber-soft); }
.status-badge.error { color: var(--danger); background: var(--danger-soft); }
.empty-library { padding: 38px 0; border-bottom: 1px solid var(--line); color: var(--muted); }

.back-button { margin: 28px 0 18px; padding: 0; color: var(--forest-dark); border: 0; background: transparent; font-weight: 700; }
.lesson-header { padding-bottom: 21px; border-bottom: 1px solid var(--line); }
.lesson-header h3 { max-width: 680px; font-size: 27px; line-height: 1.25; }
.lesson-subtitle { max-width: 680px; margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.lesson-tools { display: flex; gap: 8px; }
.processing-strip { display: flex; align-items: center; gap: 14px; min-height: 52px; border-bottom: 1px solid var(--line); }
.processing-strip p { margin: 0; color: var(--muted); font-size: 13px; }
.progress-track { width: 150px; height: 5px; overflow: hidden; border-radius: 3px; background: #f0dfe6; }
.progress-track span { display: block; width: 8%; height: 100%; border-radius: inherit; background: var(--forest); transition: width 220ms ease; }
.lesson-mode { display: none; }
.lesson-grid { display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(330px, 0.86fr); gap: 30px; padding-top: 27px; }
.transcript-panel { min-width: 0; padding-right: 30px; border-right: 1px solid var(--line); }
.panel-heading h4 { font-size: 20px; }
.panel-heading span { padding-top: 21px; color: var(--muted); font-size: 12px; }
.study-toolbar { display: flex; align-items: center; gap: 9px; margin-top: 16px; }
.transcript-search { position: relative; flex: 1; }
.transcript-search input { width: 100%; height: 38px; padding: 8px 92px 8px 10px; color: var(--ink); border: 1px solid #d8c5cd; border-radius: 5px; background: #fff; outline: none; }
.transcript-search input:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(182, 54, 103, 0.1); }
.transcript-search span:last-child { position: absolute; top: 9px; right: 10px; color: var(--muted); font-size: 12px; }
.study-toolbar .button span { margin-left: 5px; padding: 0; color: inherit; }
.bookmarks-panel { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fffafb; }
.bookmarks-heading, .bookmark-item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.bookmarks-heading h5 { margin: 0; font-size: 16px; }
.bookmark-list { display: grid; gap: 10px; max-height: 420px; margin-top: 12px; overflow-y: auto; }
.bookmark-item { padding: 11px 0 3px; border-top: 1px solid var(--line); }
.bookmark-item > p { display: -webkit-box; margin: 8px 0; overflow: hidden; color: #4d5d70; font-size: 12px; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.bookmark-item label { display: grid; gap: 5px; color: #46576a; font-size: 12px; font-weight: 700; }
.bookmark-item textarea { width: 100%; padding: 8px; resize: vertical; color: var(--ink); border: 1px solid #d8c5cd; border-radius: 4px; background: #fff; outline: none; }
.bookmark-item textarea:focus { border-color: var(--forest); }
.bookmark-delete { padding: 3px 0; color: var(--danger); border: 0; background: transparent; font-size: 12px; font-weight: 700; }
.empty-bookmarks { margin: 8px 0 2px; color: var(--muted); font-size: 13px; }
.transcript-body { min-height: 380px; margin-top: 18px; color: #344154; line-height: 1.85; white-space: pre-wrap; }
.transcript-body.pending { color: var(--muted); }
video { width: 100%; max-height: 420px; margin-top: 16px; border-radius: 6px; background: #101820; }
audio { width: 100%; height: 40px; margin-top: 16px; }
.transcript-segment { display: grid; grid-template-columns: 58px minmax(0, 1fr) 56px; gap: 12px; padding: 12px 6px; border-left: 3px solid transparent; border-bottom: 1px solid rgba(217, 225, 223, 0.82); white-space: normal; transition: background 160ms ease, border-color 160ms ease; }
.transcript-segment.active { border-left-color: #4b8290; background: #f0f7f8; }
.transcript-segment p { margin: 0; white-space: pre-wrap; }
.transcript-segment mark { color: #563600; background: #ffe39b; }
.time-jump, .source-time { align-self: start; padding: 3px 5px; color: var(--forest-dark); border: 1px solid var(--line); border-radius: 4px; background: #fff8fb; font-size: 12px; font-weight: 800; }
.time-jump:hover, .source-time:hover { border-color: var(--forest); background: var(--mint); }
.source-time { margin: 0 6px; }
.segment-bookmark { align-self: start; padding: 4px 0; color: var(--muted); border: 0; background: transparent; font-size: 12px; font-weight: 700; }
.segment-bookmark:hover, .segment-bookmark.saved { color: var(--forest-dark); }
.ask-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100vh - 48px);
  min-height: 530px;
  max-height: 820px;
  overflow: hidden;
}
.question-suggestions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.question-suggestions button { padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; color: #516174; background: var(--surface); font-size: 12px; text-align: left; }
.question-suggestions button:hover { border-color: var(--forest); color: var(--forest-dark); }
.answer-area {
  flex: 1;
  min-height: 0;
  margin: 18px 0;
  padding-right: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.clear-chat { margin-top: 20px; padding: 0; color: var(--muted); border: 0; background: transparent; font-size: 12px; font-weight: 700; }
.clear-chat:hover { color: var(--danger); }
.empty-answer { max-width: 350px; margin: 34px 0; color: var(--muted); }
.answer { color: #344154; line-height: 1.8; white-space: pre-wrap; }
.answer-label { margin-bottom: 7px; color: var(--forest); font-size: 12px; font-weight: 800; }
.chat-turn { display: grid; gap: 10px; margin-bottom: 18px; }
.chat-question { justify-self: end; max-width: 88%; padding: 9px 11px; color: #fff; border-radius: 6px 6px 2px 6px; background: #7b3f5a; line-height: 1.65; }
.chat-answer { max-width: 96%; padding: 11px 12px; border-left: 3px solid #4b8290; background: #f7faf9; }
.chat-turn.pending .empty-answer { margin: 4px 0 0; }
.source-list { display: grid; gap: 8px; margin-top: 18px; }
.source-item { padding: 9px 10px; border-left: 3px solid #d77d9f; color: #5b697b; background: #fff3f7; font-size: 12px; line-height: 1.6; }
.source-item p { margin: 4px 0 0; }
.source-label, .source-label a { color: var(--forest-dark); font-weight: 700; }
.recognized-question { margin-bottom: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; color: #526175; background: #f8faf9; font-size: 12px; }
.recognized-question summary { cursor: pointer; color: var(--forest-dark); font-weight: 800; }
.recognized-question p { margin: 8px 0 0; line-height: 1.65; white-space: pre-wrap; }
.ask-form { margin-top: auto; }
.ask-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 9px; }
.ask-form textarea { width: 100%; min-height: 76px; padding: 10px; resize: none; color: var(--ink); border: 1px solid #d8c5cd; border-radius: 5px; background: #fff; outline: none; }
.ask-form textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(182, 54, 103, 0.12); }
.ask-actions { display: grid; gap: 7px; width: 72px; }
.ask-actions .button { width: 100%; padding-inline: 8px; }
.question-image-preview { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 9px; padding: 8px; border: 1px solid #e0a9bd; border-radius: 5px; background: #fff5f8; }
.question-image-preview.hidden { display: none; }
.question-image-preview img { width: 52px; height: 52px; border-radius: 4px; object-fit: cover; background: #f3e4ea; }
.question-image-preview strong, .question-image-preview span { display: block; }
.question-image-preview strong { color: #344154; font-size: 12px; }
.question-image-preview span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.question-image-preview button { padding: 4px; border: 0; color: var(--danger); background: transparent; font-size: 12px; font-weight: 700; }

.settings-dialog { width: min(500px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.settings-dialog::backdrop { background: rgba(18, 31, 42, 0.42); }
.baidu-dialog { width: min(660px, calc(100vw - 28px)); max-height: min(720px, calc(100vh - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.baidu-dialog::backdrop { background: rgba(18, 31, 42, 0.42); }
.baidu-panel { display: grid; gap: 18px; padding: 22px; }
.baidu-status { margin: 0; color: #344154; font-weight: 700; }
.baidu-actions { padding-top: 14px; }
.baidu-browser-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.baidu-browser-tools { display: flex; gap: 8px; }
.baidu-path { max-width: 430px; margin: 0; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.baidu-file-list { max-height: min(440px, 52vh); overflow: auto; border-top: 1px solid var(--line); }
.baidu-file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 52px; padding: 9px 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.baidu-file-row:hover { background: #fff6f9; }
.baidu-file-row input { width: 17px; height: 17px; accent-color: var(--forest); }
.baidu-file-row:has(input:disabled) { cursor: not-allowed; opacity: 0.52; }
.baidu-file-name { display: block; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.baidu-file-detail { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }
.baidu-folder-button { padding: 5px 7px; color: var(--forest-dark); border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-size: 12px; font-weight: 700; }
.baidu-folder-button:hover { border-color: var(--forest); }
.baidu-selection-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 2px; color: var(--muted); font-size: 13px; }
.access-dialog { width: min(420px, calc(100vw - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.access-dialog::backdrop { background: rgba(18, 31, 42, 0.55); }
.settings-form { display: grid; gap: 15px; padding: 22px; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 5px; }
.dialog-header h3 { margin: 0; font-size: 20px; }
.close-button { padding: 3px 0; color: var(--muted); border: 0; background: transparent; }
.settings-form label { display: grid; gap: 6px; color: #445469; font-size: 13px; font-weight: 700; }
.settings-form input, .settings-form select { width: 100%; height: 39px; padding: 8px 10px; border: 1px solid #d8c5cd; border-radius: 4px; color: var(--ink); background: #fff; font-weight: 400; outline: none; }
.settings-form input:focus, .settings-form select:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(182, 54, 103, 0.1); }
.settings-form .check-row { display: flex; align-items: center; gap: 9px; }
.settings-form .check-row input { width: 17px; height: 17px; accent-color: var(--forest); }
.settings-note { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.dialog-actions-split { align-items: center; justify-content: space-between; }
.dialog-actions-split > div { display: flex; gap: 8px; }
.toast { position: fixed; right: 26px; bottom: 26px; max-width: min(380px, calc(100vw - 52px)); padding: 10px 13px; border-radius: 5px; color: #fff; background: #26384a; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: 1fr auto; min-height: auto; padding: 14px 20px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-list { display: flex; gap: 3px; margin: 0; }
  .sidebar-footer { display: none; }
  .main-content { padding: 0 24px 40px; }
  .lesson-mode { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; border-bottom: 1px solid var(--line); }
  .lesson-mode button { min-height: 40px; color: var(--muted); border: 0; border-bottom: 2px solid transparent; background: transparent; font-weight: 700; }
  .lesson-mode button.active { color: var(--forest-dark); border-bottom-color: var(--forest); }
  .lesson-grid { grid-template-columns: 1fr; }
  .lesson-grid:not(.show-ask) .ask-panel { display: none; }
  .lesson-grid.show-ask .transcript-panel { display: none; }
  .transcript-panel { padding: 0 0 27px; border-right: 0; border-bottom: 1px solid var(--line); }
  .ask-panel { position: static; height: auto; min-height: 530px; max-height: none; overflow: visible; }
  .answer-area { overflow: visible; scrollbar-gutter: auto; }
}

@media (max-width: 680px) {
  .sidebar { grid-template-columns: 1fr; gap: 12px; }
  .brand-lockup { padding: 0; }
  .nav-list { overflow-x: auto; }
  .nav-item { flex: 0 0 auto; width: auto; }
  .main-content { padding: 0 18px 30px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 13px; padding: 20px 0; }
  .topbar h2 { font-size: 21px; }
  .topbar-actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .system-status { max-width: none; text-align: left; }
  .import-band { grid-template-columns: 1fr; gap: 21px; padding: 26px 0; }
  .import-copy h3 { font-size: 23px; }
  .section-heading, .lesson-header { flex-direction: column; gap: 10px; }
  .course-meta { margin: 0; }
  .course-open { grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
  .course-open .status-badge { grid-column: 2; width: max-content; }
  .course-row-actions { align-self: start; padding-top: 10px; }
  .lesson-header h3 { font-size: 24px; }
  .processing-strip { align-items: flex-start; flex-direction: column; gap: 5px; padding: 12px 0; }
  .progress-track { width: 100%; }
  .ask-input-row { grid-template-columns: 1fr; }
  .ask-actions { grid-template-columns: 1fr 1fr; width: 100%; }
  .ask-actions .button { width: 100%; }
  .study-toolbar { align-items: stretch; flex-direction: column; }
  .study-toolbar .button { width: 100%; }
  .transcript-segment { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; }
  .transcript-segment p { grid-column: 1 / -1; }
  .time-jump { width: max-content; }
  .baidu-browser-head, .baidu-selection-bar { align-items: stretch; flex-direction: column; }
  .baidu-browser-head .button, .baidu-selection-bar .button { width: 100%; }
  .baidu-browser-tools { width: 100%; flex-direction: column; }
  .dialog-actions-split { align-items: stretch; flex-direction: column; }
  .dialog-actions-split > div { display: grid; grid-template-columns: 1fr 1fr; }
}
