:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-subtle: #f1f3f2;
  --surface-hover: #e9eeeb;
  --ink: #17201d;
  --muted: #66716d;
  --line: #dce2df;
  --line-strong: #c5cfca;
  --accent: #176b55;
  --accent-hover: #125744;
  --accent-soft: #e3f1ec;
  --amber: #8a5a00;
  --amber-soft: #fff3d5;
  --danger: #9d3737;
  --danger-soft: #f9e7e7;
  --blue: #315f87;
  --blue-soft: #e8f0f7;
  --shadow: 0 12px 32px rgba(28, 39, 35, 0.1);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf1ef;
}

.login-panel {
  width: min(100%, 390px);
  padding: 38px 36px 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 22px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  font-weight: 750;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  margin: 0;
  font-size: 17px;
}

.eyebrow, .section-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.4;
  text-transform: uppercase;
}

.login-panel h1 {
  margin: 5px 0 28px;
  font-size: 27px;
  line-height: 1.2;
}

.form-stack { display: grid; gap: 17px; }

label > span {
  display: block;
  margin-bottom: 7px;
  color: #39433f;
  font-size: 13px;
  font-weight: 650;
}

input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 85, 0.13);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 680;
  text-decoration: none;
}

.button:disabled { cursor: not-allowed; opacity: 0.52; }
.button.full { width: 100%; }
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.secondary { border-color: var(--line-strong); background: #fff; color: var(--ink); }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled) { background: var(--surface-subtle); }
.button.quiet { padding-inline: 8px; background: transparent; color: #4d5853; }

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #53605b;
  cursor: pointer;
  font-size: 20px;
}

.icon-button:hover { border-color: var(--line); background: var(--surface-subtle); }

.form-error, .inline-error {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: #792a2a;
  font-size: 13px;
  line-height: 1.5;
}

.app-shell { min-height: 100vh; }

.topbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 28px;
  min-height: 68px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.brand-row, .account-row, .library-summary { display: flex; align-items: center; }
.brand-row { gap: 11px; }
.brand-row h1 { margin: 1px 0 0; font-size: 17px; line-height: 1.2; }
.account-row { gap: 8px; }
.account-name { color: var(--muted); font-size: 12px; }
.library-summary { justify-content: center; gap: 22px; color: var(--muted); font-size: 12px; }
.library-summary strong { color: var(--ink); font-size: 15px; }

.library-workspace {
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(280px, 350px) minmax(460px, 1fr);
  height: calc(100vh - 68px);
  max-width: 1720px;
  margin: 0 auto;
  background: var(--surface);
}

.anchor-panel, .session-panel, .detail-panel {
  min-width: 0;
  overflow: auto;
}

.anchor-panel, .session-panel { border-right: 1px solid var(--line); }
.anchor-panel { background: #f7f8f7; }

.panel-heading {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 73px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: inherit;
}

.panel-heading h2 { margin: 3px 0 0; font-size: 16px; line-height: 1.25; }
.count-label { color: var(--muted); font-size: 12px; white-space: nowrap; }

.anchor-list { padding: 8px; }

.anchor-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  width: 100%;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.anchor-item:hover { background: var(--surface-hover); }
.anchor-item.active { border-color: #c8ddd5; background: var(--accent-soft); }
.anchor-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.anchor-item span { color: var(--muted); font-size: 12px; }
.anchor-item small { grid-column: 1 / -1; margin-top: 4px; color: #7b8581; font-size: 10px; }

.session-panel { background: var(--surface); }
.session-heading { background: var(--surface); }
.session-list { display: grid; }

.session-item {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 100px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.session-item:hover { background: #f8faf9; }
.session-item.active { background: #eef5f2; }
.session-item.active::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
}

.session-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.session-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.session-time { margin-top: 7px; color: var(--muted); font-size: 11px; }
.session-assets { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

.asset-chip, .source-label, .status-label, .event-kind {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-subtle);
  color: #56615c;
  font-size: 10px;
  font-weight: 650;
}

.asset-chip.present { background: var(--accent-soft); color: var(--accent-hover); }
.source-label { background: var(--blue-soft); color: var(--blue); }
.status-label.ready { background: var(--accent-soft); color: var(--accent-hover); }
.status-label.processing { background: var(--amber-soft); color: var(--amber); }
.status-label.failed { background: var(--danger-soft); color: var(--danger); }

.load-more {
  width: calc(100% - 32px);
  min-height: 38px;
  margin: 14px 16px 24px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #4c5853;
  cursor: pointer;
}

.load-more:hover { background: var(--surface-subtle); }

.empty-state {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 56px 24px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.empty-state strong { color: var(--ink); font-size: 14px; }
.detail-panel { background: #fbfcfb; }

.detail-empty {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 100%;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-glyph {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--accent);
  font-size: 20px;
  font-weight: 750;
}

.detail-empty strong { color: var(--ink); }
.detail-empty p { max-width: 350px; margin: 8px 0 0; font-size: 13px; line-height: 1.6; }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.detail-context { display: flex; gap: 6px; margin-bottom: 9px; }
.detail-header h2 { margin: 0; overflow-wrap: anywhere; font-size: 22px; line-height: 1.35; }
.detail-header p { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.media-stage {
  display: grid;
  grid-template-columns: minmax(220px, 430px) minmax(240px, 1fr);
  align-items: center;
  gap: 22px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: #f0f3f1;
}

.media-stage video {
  width: 100%;
  max-height: 430px;
  border-radius: 6px;
  background: #101311;
}

.media-unavailable {
  display: grid;
  place-items: center;
  min-height: 160px;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.audio-wrap { min-width: 0; }
.audio-wrap > div { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.audio-wrap strong { font-size: 13px; }
.audio-wrap span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.audio-wrap audio { width: 100%; height: 40px; }

.detail-tabs {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  gap: 22px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
}

.detail-tabs button {
  min-height: 48px;
  padding: 0 1px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 680;
}

.detail-tabs button:hover { color: var(--ink); }
.detail-tabs button.active { border-color: var(--accent); color: var(--accent); }
.tab-panel { padding: 24px 28px 60px; }

.section-block + .section-block { margin-top: 28px; }
.section-block h3 { margin: 0 0 13px; font-size: 14px; }
.section-block-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-block-heading span { color: var(--muted); font-size: 11px; }

.facts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.fact {
  min-width: 0;
  padding: 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.fact span { display: block; color: var(--muted); font-size: 10px; }
.fact strong { display: block; margin-top: 5px; overflow-wrap: anywhere; font-size: 12px; font-weight: 650; }

.task-list, .material-list, .file-list, .asset-list { border-top: 1px solid var(--line); }

.task-row, .material-row, .file-row, .asset-row {
  display: grid;
  align-items: start;
  gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}

.task-row { grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.3fr) auto; }
.task-row strong, .file-row strong, .asset-row strong { font-size: 12px; }
.task-row span, .task-row small { color: var(--muted); font-size: 11px; }
.task-row small { overflow-wrap: anywhere; }

.material-row { grid-template-columns: 72px minmax(0, 1fr); }
.time-button {
  min-height: 27px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.time-button:hover { background: var(--accent-soft); }
.material-body { min-width: 0; }
.material-author { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.material-text { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 13px; line-height: 1.7; }
.event-kind { margin-bottom: 5px; }

.empty-material {
  padding: 42px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.material-footer { padding-top: 15px; text-align: center; }

.file-row, .asset-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.file-main { min-width: 0; }
.file-main strong { display: block; overflow-wrap: anywhere; }
.file-main span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.file-actions { display: flex; gap: 6px; }
.file-actions a { min-height: 31px; padding: 5px 9px; font-size: 11px; }

.storage-flags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.storage-flag { padding: 2px 6px; border-radius: 3px; background: var(--surface-subtle); color: var(--muted); font-size: 10px; }
.storage-flag.available { background: var(--accent-soft); color: var(--accent-hover); }

.document-preview {
  max-height: 300px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #38433f;
  font: 11px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.upload-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.upload-dialog::backdrop { background: rgba(20, 27, 24, 0.48); }
.dialog-heading {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.dialog-heading h2 { margin: 3px 0 0; font-size: 19px; }
.upload-dialog form { padding: 22px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.field-grid .wide { grid-column: 1 / -1; }

.file-drop {
  display: grid;
  justify-items: center;
  margin-top: 20px;
  padding: 28px 18px;
  border: 1px dashed #aeb8b3;
  border-radius: 6px;
  background: #f8faf9;
  cursor: pointer;
  text-align: center;
}
.file-drop:hover, .file-drop.dragging { border-color: var(--accent); background: #f1f8f5; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-drop strong { margin-top: 9px; font-size: 14px; overflow-wrap: anywhere; }
.file-drop span:last-child { margin-top: 5px; color: var(--muted); font-size: 11px; }
.file-glyph { color: var(--accent); font-size: 27px; line-height: 1; }

.progress-area { margin-top: 20px; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.progress-track { height: 7px; margin-top: 9px; overflow: hidden; border-radius: 4px; background: #e7eae9; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 180ms ease; }
.progress-area p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.form-actions { display: flex; gap: 9px; margin-top: 20px; }

@media (max-width: 1050px) {
  body { overflow: auto; }
  .topbar { grid-template-columns: auto 1fr; min-height: 64px; padding: 0 16px; }
  .library-summary { display: none; }
  .account-row { justify-self: end; }
  .library-workspace {
    grid-template-columns: minmax(180px, 220px) minmax(270px, 330px) minmax(420px, 1fr);
    height: calc(100vh - 64px);
  }
  .detail-header, .media-stage, .tab-panel { padding-right: 20px; padding-left: 20px; }
  .detail-tabs { padding: 0 20px; }
  .media-stage { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    top: 0;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .brand-mark.small, .eyebrow, .account-name { display: none; }
  .brand-row h1 { font-size: 16px; }
  .account-row { gap: 2px; }
  .account-row .button { min-height: 36px; padding: 7px 10px; }
  .library-workspace {
    display: block;
    height: auto;
    min-height: calc(100vh - 64px);
  }
  .anchor-panel, .session-panel, .detail-panel { overflow: visible; border: 0; }
  .anchor-panel { border-bottom: 1px solid var(--line); }
  .anchor-panel .panel-heading { position: static; min-height: 56px; padding: 10px 14px 4px; border: 0; }
  .anchor-panel .panel-heading h2 { display: none; }
  .anchor-list { display: flex; gap: 7px; overflow-x: auto; padding: 7px 14px 13px; scrollbar-width: none; }
  .anchor-list::-webkit-scrollbar { display: none; }
  .anchor-item { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; width: auto; padding: 8px 10px; border-color: var(--line); background: #fff; white-space: nowrap; }
  .anchor-item small { display: none; }
  .session-panel { border-bottom: 8px solid var(--bg); }
  .session-heading { position: static; min-height: 62px; padding: 11px 14px; }
  .session-item { min-height: 92px; padding: 13px 14px; }
  .detail-panel { min-height: 450px; }
  .detail-empty { min-height: 380px; }
  .detail-header { padding: 19px 14px 16px; }
  .detail-header { display: grid; }
  .detail-header h2 { font-size: 19px; }
  .detail-header .button { justify-self: start; }
  .media-stage { padding: 14px; }
  .media-stage video { max-height: 72vh; }
  .detail-tabs { top: 64px; gap: 0; justify-content: space-between; padding: 0 14px; overflow-x: auto; }
  .detail-tabs button { flex: 0 0 auto; min-height: 46px; padding: 0 8px; }
  .tab-panel { padding: 18px 14px 50px; }
  .facts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-row { grid-template-columns: minmax(100px, 0.7fr) minmax(0, 1.3fr); }
  .task-row > :last-child { grid-column: 1 / -1; }
  .material-row { grid-template-columns: 64px minmax(0, 1fr); gap: 9px; }
  .file-row, .asset-row { grid-template-columns: 1fr; }
  .file-actions { margin-top: 2px; }
  .upload-dialog { max-height: calc(100vh - 18px); }
  .dialog-heading, .upload-dialog form { padding: 17px 15px; }
  .field-grid { grid-template-columns: 1fr; gap: 14px; }
  .field-grid .wide { grid-column: auto; }
  .login-panel { padding: 32px 24px; }
}
