:root {
  color-scheme: light;
  --bg: #f5f5f2;
  --panel: #ffffff;
  --panel-soft: #fafaf8;
  --text: #1f2421;
  --muted: #68706a;
  --border: #dfe3de;
  --accent: #315f4b;
  --accent-strong: #214536;
  --accent-soft: #e5efe9;
  --warm: #8a5b20;
  --warm-soft: #fff8e9;
  --danger: #9a3412;
  --danger-soft: #fff1eb;
  --shadow: 0 16px 46px rgba(35, 48, 40, .08);
  --topbar-height: 70px;
  --sidebar-width: 296px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, ui-sans-serif, system-ui, sans-serif; }
a { color: var(--accent-strong); }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid rgba(49, 95, 75, .25); outline-offset: 2px; }

.public-topbar, .private-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-height);
  padding: 12px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(15px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 760; text-decoration: none; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: #fff; background: var(--accent-strong); font-size: 12px; letter-spacing: .06em; }
.topbar-note { color: var(--muted); font-size: 12px; }
.signed-out-main { display: grid; place-items: center; min-height: calc(100vh - var(--topbar-height)); padding: 40px 20px 80px; }
.signed-out-card { width: min(630px, 100%); padding: clamp(28px, 6vw, 58px); border: 1px solid var(--border); border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.signed-out-card h1 { max-width: 510px; margin-bottom: 16px; font-size: clamp(35px, 6vw, 58px); line-height: 1.04; letter-spacing: -.05em; }
.lede { max-width: 540px; margin-bottom: 25px; color: #465149; font-size: 17px; }
.lede-small { max-width: 680px; margin-bottom: 17px; color: var(--muted); font-size: 13px; }
.sign-in-button { min-height: 42px; }
.public-trust-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px 22px; margin-top: 26px; color: var(--muted); font-size: 12px; }
.public-trust-row span::before { content: "·"; margin-right: 7px; color: var(--accent); font-weight: 900; }
.status { min-height: 1.4em; margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.status[data-kind="good"] { color: var(--accent-strong); }
.status[data-kind="warn"] { color: var(--warm); }
.status[data-kind="bad"] { color: var(--danger); }

.private-topbar { position: sticky; top: 0; z-index: 20; padding-left: 22px; padding-right: 22px; }
.private-topbar-actions, .toolbar-actions, .inline-actions, .player-actions, .player-footer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.owner-chip { display: inline-flex; align-items: center; gap: 7px; max-width: min(42vw, 360px); padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 12px; }
.owner-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owner-dot { width: 7px; height: 7px; border-radius: 50%; background: #4e9b70; }
.private-layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-height)); }
.archive-sidebar { position: sticky; top: var(--topbar-height); align-self: start; height: calc(100vh - var(--topbar-height)); overflow-y: auto; padding: 22px 15px 30px; border-right: 1px solid var(--border); background: var(--panel); }
.sidebar-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 6px 18px; }
.sidebar-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.03em; }
.sidebar-mark, .panel-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; color: var(--accent-strong); background: var(--accent-soft); font-weight: 800; }
.search-field, .select-field { display: grid; gap: 7px; margin: 0 5px 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
.search-field input, .select-field select { width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: var(--panel-soft); color: var(--text); }
.search-field input:focus, .select-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sidebar-summary { margin: 17px 6px 12px; color: var(--muted); font-size: 12px; }
.catalog-tree { min-height: 80px; }
.tree-list { list-style: none; margin: 0; padding: 0; }
.tree-list .tree-list { margin: 3px 0 6px 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.tree-item { position: relative; }
.tree-row { display: grid; grid-template-columns: 23px minmax(0, 1fr); align-items: center; gap: 2px; }
.tree-toggle, .tree-toggle-spacer { display: grid; place-items: center; width: 23px; height: 30px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.tree-toggle { cursor: pointer; }
.tree-toggle:hover { background: var(--panel-soft); color: var(--text); }
.tree-button { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 7px; width: 100%; min-width: 0; padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; text-align: left; cursor: pointer; }
.tree-button:hover { background: var(--panel-soft); }
.tree-button.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 750; }
.tree-icon { color: var(--muted); text-align: center; }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-note { margin: 24px 6px 0; color: var(--muted); font-size: 12px; }
.archive-main { min-width: 0; padding: 26px clamp(20px, 4vw, 62px) 76px; }
.main-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 38px; margin-bottom: 24px; }
.main-toolbar .status { margin: 0; }
.panel { padding: 22px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); box-shadow: 0 9px 28px rgba(35, 48, 40, .04); }
.import-panel { max-width: 780px; margin-bottom: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.small-heading { margin-bottom: 9px; }
.panel-heading h1, .panel-heading h2 { margin: 0; font-size: 22px; line-height: 1.15; letter-spacing: -.035em; }
.file-field { display: grid; gap: 7px; margin: 16px 0; color: var(--muted); font-size: 12px; font-weight: 750; }
.file-field input { width: 100%; padding: 9px; border: 1px dashed #b8c3bc; border-radius: 9px; background: var(--panel-soft); color: var(--text); }
.preview-copy { min-height: 1.4em; color: var(--accent-strong); font-size: 13px; }
.first-run-recovery { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.text-button { padding: 0; border: 0; background: none; color: var(--accent-strong); cursor: pointer; font-weight: 750; text-decoration: underline; }
.settings-details { margin-bottom: 28px; border: 1px solid var(--border); border-radius: 15px; background: rgba(255, 255, 255, .55); }
.settings-details > summary { padding: 13px 16px; color: var(--accent-strong); cursor: pointer; font-weight: 750; list-style-position: inside; }
.settings-details[open] > summary { border-bottom: 1px solid var(--border); }
.settings-details-body { padding: 14px; }
.gap-details { margin: 0 0 14px; border: 1px solid #ecdcb8; border-radius: 11px; background: var(--warm-soft); color: var(--warm); }
.gap-details > summary { padding: 10px 12px; cursor: pointer; font-size: 13px; font-weight: 750; }
.gap-list { padding: 0 12px 10px; }
.gap-list .gap-item { margin: 4px 0 0; font-size: 12px; }
.restore-panel { box-shadow: none; }
.primary-button, .secondary-button, .load-more { min-height: 37px; padding: 8px 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--panel); color: var(--text); cursor: pointer; font-weight: 750; text-decoration: none; }
.primary-button { border-color: var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-strong); }
.secondary-button:hover, .load-more:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.secondary-button:disabled, .primary-button:disabled, .load-more:disabled { cursor: not-allowed; opacity: .5; }
.compact-button { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.full-button { width: 100%; }
.node-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.kind-pill, .asset-kind, .progress-chip { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.node-header h1 { max-width: 900px; margin: 8px 0 6px; font-size: clamp(31px, 5vw, 54px); line-height: 1.03; letter-spacing: -.055em; }
.node-meta { margin: 0; color: var(--muted); font-size: 13px; }
.node-source { padding-top: 18px; font-size: 12px; font-weight: 700; }
.external-link { color: var(--accent-strong); font-weight: 750; }
.notice { margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; font-size: 13px; }
.notice p { margin: 4px 0 0; }
.notice-warm { border-color: #ecdcb8; background: var(--warm-soft); color: var(--warm); }
.notice-danger { border-color: #efc9bb; background: var(--danger-soft); color: var(--danger); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 300px); gap: 24px; align-items: start; }
.content-column, .side-column { min-width: 0; }
.side-column { position: sticky; top: calc(var(--topbar-height) + 24px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2, .section-heading h3 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.tight-heading { margin-bottom: 8px; }
.asset-list { display: grid; gap: 9px; }
.asset-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 16px; border: 1px solid var(--border); border-radius: 13px; background: var(--panel); transition: border-color .15s ease, transform .15s ease; }
.asset-card:hover { border-color: #a8c4b4; transform: translateY(-1px); }
.asset-copy { min-width: 0; }
.asset-kind { min-height: 21px; margin-bottom: 5px; font-size: 10px; }
.asset-title { margin: 0 0 4px; overflow: hidden; font-size: 16px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.asset-meta { margin: 0; color: var(--muted); font-size: 12px; }
.asset-technical-details { margin-top: 9px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel-soft); }
.asset-technical-details > summary { padding: 11px 13px; color: var(--accent-strong); cursor: pointer; font-size: 13px; font-weight: 750; }
.asset-technical-list { padding: 0 10px 10px; }
.asset-technical-list .asset-card { margin-top: 8px; }
.asset-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
.asset-bookmark-button { width: 32px; min-height: 32px; padding: 0; border: 0; background: transparent; color: var(--accent-strong); cursor: pointer; font-size: 21px; }
.load-more { display: block; margin: 15px auto 0; }
.empty-state { padding: 24px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; }
.player-panel { margin-top: 25px; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.player-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 14px; }
.player-heading h2 { margin: 3px 0 4px; font-size: 22px; line-height: 1.15; letter-spacing: -.035em; }
.progress-chip { min-height: 29px; padding: 5px 9px; white-space: nowrap; }
.media-frame { position: relative; display: grid; min-height: 260px; overflow: hidden; border-radius: 12px; background: #121816; }
.media-frame video, .media-frame audio { display: block; width: 100%; align-self: center; background: #121816; }
.media-frame video { min-height: 260px; }
.media-frame audio { padding: 32px 20px; }
.media-placeholder { display: grid; place-items: center; gap: 6px; min-height: 260px; padding: 28px; color: #d9e7df; text-align: center; }
.media-placeholder-icon { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: #fff; }
.media-placeholder strong { color: #fff; }
.media-placeholder span:last-child { max-width: 340px; color: #aebfb6; font-size: 12px; }
.player-footer { display: flex; justify-content: space-between; gap: 16px; padding: 15px 0 5px; }
.player-footer .muted { margin: 0 0 7px; }
.muted { color: var(--muted); font-size: 12px; }
.transcript-panel { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border); }
.transcript-list { display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.transcript-cue { display: grid; grid-template-columns: 45px minmax(0, 1fr); gap: 10px; width: 100%; padding: 8px 9px; border: 1px solid transparent; border-radius: 8px; background: var(--panel-soft); text-align: left; cursor: pointer; }
.transcript-cue:hover, .transcript-cue.active { border-color: #a8c4b4; background: var(--accent-soft); }
.cue-time { color: var(--accent-strong); font-variant-numeric: tabular-nums; font-weight: 800; }
.cue-text { overflow-wrap: anywhere; }
.drive-panel { padding: 18px; }
.drive-panel .panel-icon { background: #edf2ee; }

@media (max-width: 980px) {
  .content-grid { grid-template-columns: 1fr; }
  .side-column { position: static; order: -1; }
  .drive-panel { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 15px; align-items: center; }
  .drive-panel .panel-heading, .drive-panel .lede-small { grid-column: 1 / -1; }
  .drive-panel .full-button { width: auto; }
  .drive-panel .status { margin: 0; }
}

@media (max-width: 760px) {
  .private-layout { grid-template-columns: 1fr; }
  .archive-sidebar { position: static; height: auto; max-height: 335px; border-right: 0; border-bottom: 1px solid var(--border); }
  .catalog-tree { max-height: 180px; overflow-y: auto; }
  .archive-main { padding: 22px 16px 54px; }
  .main-toolbar, .node-header, .player-heading { align-items: flex-start; flex-direction: column; }
  .main-toolbar { gap: 7px; }
  .toolbar-actions { width: 100%; }
  .node-source { padding-top: 0; }
  .asset-card { align-items: flex-start; flex-direction: column; gap: 10px; }
  .asset-actions { width: 100%; justify-content: space-between; }
  .player-footer { align-items: flex-start; flex-direction: column; }
  .private-topbar { padding: 10px 16px; }
  .private-topbar .brand span:last-child { display: none; }
  .owner-chip { max-width: 47vw; }
}

@media (max-width: 460px) {
  .public-topbar { padding: 10px 16px; }
  .topbar-note { display: none; }
  .signed-out-card { padding: 26px 21px; border-radius: 17px; }
  .signed-out-card h1 { font-size: 36px; }
  .drive-panel { display: block; }
  .drive-panel .full-button { width: 100%; }
  .drive-panel .status { margin-top: 12px; }
  .owner-chip { display: none; }
}
