:root {
  color-scheme: light;
  --bg-a:#edf7fa;
  --bg-b:#f7f9fc;
  --bg-c:#eaf0ff;
  --side:rgba(255,255,255,.82);
  --panel:rgba(255,255,255,.76);
  --panel-strong:rgba(255,255,255,.92);
  --line:rgba(30,58,83,.12);
  --text:#13202b;
  --muted:#667684;
  --hot:#e66f35;
  --blue:#2563eb;
  --blue-2:#1e64e4;
  --green:#0fa678;
  --danger:#b42318;
  --shadow:0 24px 80px rgba(31,54,77,.14);
  --font-main:"Noto Serif SC","Source Han Serif SC","Songti SC","SimSun",serif;
}

body.dark {
  color-scheme: dark;
  --bg-a:#07111d;
  --bg-b:#10132a;
  --bg-c:#081522;
  --side:rgba(19,35,49,.86);
  --panel:rgba(10,20,34,.78);
  --panel-strong:rgba(7,18,31,.92);
  --line:rgba(130,168,196,.12);
  --text:#eef6ff;
  --muted:#8795a8;
  --hot:#ff8a4c;
  --blue:#2f7df6;
  --blue-2:#1e64e4;
  --green:#20d695;
  --danger:#ff8f86;
  --shadow:0 24px 80px rgba(0,0,0,.34);
}

* {
  box-sizing:border-box;
}

body {
  margin:0;
  min-height:100vh;
  background:linear-gradient(135deg,var(--bg-a),var(--bg-b) 56%,var(--bg-c));
  color:var(--text);
  font-family:var(--font-main);
}

button,
input,
textarea {
  font:inherit;
}

button {
  letter-spacing:0;
}

.app {
  display:grid;
  grid-template-columns:280px 1fr;
  gap:14px;
  min-height:100vh;
  padding:14px;
}

.sidebar,
.main,
.advisor-drawer {
  border:1px solid var(--line);
  background:var(--side);
  box-shadow:var(--shadow);
  backdrop-filter:blur(18px);
}

.sidebar {
  border-radius:18px;
  padding:18px;
  display:flex;
  flex-direction:column;
  min-height:calc(100vh - 28px);
}

.brand {
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:22px;
}

.brand-mark {
  width:42px;
  height:42px;
  display:grid;
  place-items:center;
  border-radius:50%;
  color:#fff;
  font-size:21px;
  font-weight:900;
  background:linear-gradient(135deg,#22b8cf,#2563eb);
}

.brand-title {
  font-size:20px;
  font-weight:900;
  line-height:1.1;
}

.brand-title span {
  display:block;
  margin-top:4px;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}

.module-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.module {
  min-height:72px;
  border:1px solid var(--line);
  border-radius:10px;
  background:rgba(255,255,255,.58);
  color:var(--muted);
  padding:12px;
  text-align:left;
  cursor:pointer;
  transition:transform .18s ease,border-color .18s ease,color .18s ease,background .18s ease;
}

body.dark .module {
  background:rgba(8,18,31,.72);
}

.module:hover {
  transform:translateY(-1px);
  border-color:rgba(37,99,235,.24);
  color:var(--text);
}

.module.active {
  color:var(--hot);
  border-color:rgba(230,111,53,.32);
  background:rgba(230,111,53,.08);
}

.module b {
  display:block;
  margin-bottom:7px;
  color:inherit;
}

.module span {
  display:block;
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
}

.sidebar-footer {
  margin-top:auto;
  padding-top:18px;
  color:var(--muted);
  font-size:13px;
}

.theme-row,
.account-row,
.state-row {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:9px 0;
  border-top:1px solid var(--line);
}

.account-row b {
  color:var(--text);
}

.theme-toggle {
  width:48px;
  height:28px;
  border:1px solid var(--line);
  border-radius:999px;
  padding:3px;
  background:rgba(255,255,255,.68);
  cursor:pointer;
}

body.dark .theme-toggle {
  background:rgba(3,12,22,.68);
}

.theme-knob {
  display:block;
  width:20px;
  height:20px;
  border-radius:50%;
  background:linear-gradient(135deg,var(--blue),var(--blue-2));
  transition:.2s ease;
}

body.dark .theme-knob {
  transform:translateX(20px);
}

.state-pill {
  color:var(--green);
  font-weight:800;
}

.main {
  min-width:0;
  border-radius:18px;
  padding:18px 24px 24px;
  background:var(--panel);
}

.topbar {
  min-height:42px;
  display:grid;
  grid-template-columns:88px 1fr auto;
  align-items:center;
  gap:14px;
  margin-bottom:26px;
}

.back-chip,
.crumb,
.status {
  min-height:38px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(255,255,255,.62);
  display:flex;
  align-items:center;
}

body.dark .back-chip,
body.dark .crumb,
body.dark .status {
  background:rgba(2,10,18,.5);
}

.back-chip {
  justify-content:center;
  color:var(--muted);
  font-size:14px;
}

.crumb {
  justify-content:center;
  padding:0 16px;
  color:var(--muted);
  font-size:14px;
}

.status {
  display:none;
  gap:6px;
  padding:0 14px;
  color:var(--muted);
  font-size:13px;
}

.status span {
  color:var(--green);
  font-weight:900;
}

.main.advisor-mode .status {
  display:flex;
}

.hero-line {
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:18px;
  margin-bottom:24px;
}

h1,
h2,
p {
  margin:0;
}

h1 {
  margin:0 0 8px;
  font-size:30px;
  line-height:1.18;
}

.sub {
  color:var(--muted);
  line-height:1.6;
}

.primary-card {
  border:1px solid var(--line);
  border-radius:12px;
  background:var(--panel-strong);
  padding:22px;
}

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

.card-head strong {
  font-size:17px;
}

.tag {
  border:1px solid rgba(37,99,235,.16);
  border-radius:999px;
  color:var(--blue);
  padding:7px 10px;
  font-size:12px;
  font-weight:800;
  background:rgba(37,99,235,.07);
}

.extract-form {
  display:grid;
  gap:13px;
}

.input-row {
  display:flex;
  gap:10px;
}

.url-input,
.advisor-input,
#video-link {
  width:100%;
  min-width:0;
  height:48px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  color:var(--text);
  padding:0 14px;
  outline:none;
}

textarea.url-input {
  min-height:92px;
  height:auto;
  resize:vertical;
  line-height:1.55;
  padding:12px 14px;
}

body.dark .url-input,
body.dark .advisor-input,
body.dark #video-link {
  background:#050d18;
}

.url-input:focus,
.advisor-input:focus,
#video-link:focus {
  border-color:rgba(37,99,235,.5);
  box-shadow:0 0 0 3px rgba(37,99,235,.13);
}

.primary-btn {
  border:0;
  border-radius:10px;
  background:linear-gradient(135deg,var(--blue),var(--blue-2));
  color:#fff;
  padding:0 18px;
  min-height:48px;
  font-weight:900;
  cursor:pointer;
  white-space:nowrap;
}

.primary-btn:disabled {
  cursor:wait;
  opacity:.72;
}

.option-row {
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  color:var(--muted);
  font-size:14px;
}

.check {
  display:inline-flex;
  align-items:center;
  gap:7px;
}

.check input {
  width:16px;
  height:16px;
  accent-color:var(--blue);
}

.message {
  margin-top:16px;
  border:1px solid rgba(180,35,24,.18);
  border-radius:10px;
  background:rgba(180,35,24,.07);
  color:var(--danger);
  padding:12px 14px;
  line-height:1.5;
}

.message.success {
  border-color:rgba(15,166,120,.22);
  background:rgba(15,166,120,.08);
  color:var(--green);
}

.result-panel {
  display:grid;
  grid-template-columns:260px minmax(0,1fr);
  align-items:stretch;
  gap:18px;
  margin-top:18px;
}

.media-preview {
  width:100%;
  aspect-ratio:3 / 4;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:10px;
  background:
    radial-gradient(circle at 18% 18%,rgba(34,184,207,.34),transparent 34%),
    radial-gradient(circle at 84% 82%,rgba(230,111,53,.24),transparent 38%),
    #07111d;
}

.media-preview img {
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
}

.result-content {
  display:grid;
  min-width:0;
  align-content:start;
  gap:14px;
  border:1px dashed rgba(30,58,83,.18);
  border-radius:10px;
  padding:14px;
  background:rgba(248,251,253,.58);
}

body.dark .result-content {
  border-color:rgba(130,168,196,.16);
  background:rgba(4,11,20,.34);
}

.result-meta,
.link-box,
.actions {
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
}

.chip {
  border:1px solid rgba(37,99,235,.16);
  border-radius:999px;
  padding:7px 10px;
  background:rgba(37,99,235,.08);
  color:var(--blue);
  font-size:12px;
  font-weight:800;
}

.chip.subdued {
  border-color:var(--line);
  background:rgba(255,255,255,.5);
  color:var(--muted);
}

body.dark .chip.subdued {
  background:rgba(255,255,255,.05);
}

.result-content h2 {
  font-size:22px;
  line-height:1.25;
}

.result-content p {
  color:var(--muted);
}

#video-link {
  flex:1;
  height:42px;
}

.icon-btn {
  width:42px;
  height:42px;
  border:1px solid var(--line);
  border-radius:10px;
  background:rgba(255,255,255,.68);
  color:var(--text);
  cursor:pointer;
}

body.dark .icon-btn {
  background:rgba(255,255,255,.06);
}

.secondary-btn {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  border:1px solid var(--line);
  border-radius:10px;
  background:rgba(255,255,255,.62);
  color:var(--text);
  padding:0 14px;
  font-weight:800;
  text-decoration:none;
  cursor:pointer;
}

body.dark .secondary-btn {
  background:rgba(255,255,255,.06);
}

.secondary-btn.hot {
  border-color:rgba(230,111,53,.28);
  color:var(--hot);
  background:rgba(230,111,53,.08);
}

.secondary-btn:disabled {
  cursor:wait;
  opacity:.68;
}

.advisor-drawer {
  position:fixed;
  top:14px;
  right:14px;
  bottom:14px;
  width:392px;
  border-radius:18px;
  display:flex;
  flex-direction:column;
  transform:translateX(calc(100% + 24px));
  opacity:0;
  pointer-events:none;
  transition:.28s ease;
  background:var(--panel-strong);
  z-index:20;
}

.advisor-drawer.open {
  transform:translateX(0);
  opacity:1;
  pointer-events:auto;
}

.advisor-head {
  padding:18px;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
  gap:14px;
}

.advisor-head h2 {
  margin:0 0 6px;
  font-size:20px;
}

.chat {
  flex:1;
  padding:18px;
  display:grid;
  align-content:start;
  gap:12px;
  overflow:auto;
}

.msg {
  border-radius:12px;
  padding:12px;
  line-height:1.55;
  font-size:14px;
}

.bot {
  background:rgba(37,99,235,.08);
  border:1px solid rgba(37,99,235,.14);
}

.user {
  justify-self:end;
  max-width:88%;
  color:#fff;
  background:linear-gradient(135deg,var(--blue),var(--blue-2));
}

.advisor-compose {
  padding:14px;
  border-top:1px solid var(--line);
}

.advisor-prompts {
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:10px;
}

.advisor-prompts[hidden] {
  display:none;
}

.advisor-prompts button {
  border:1px solid rgba(37,99,235,.2);
  border-radius:999px;
  background:rgba(37,99,235,.08);
  color:var(--blue);
  min-height:32px;
  padding:0 12px;
  font-weight:800;
  cursor:pointer;
}

.advisor-prompts button:hover {
  border-color:rgba(230,111,53,.3);
  color:var(--hot);
  background:rgba(230,111,53,.08);
}

.chat-input {
  display:flex;
  gap:10px;
}

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

  .sidebar {
    min-height:0;
  }

  .topbar,
  .hero-line,
  .input-row,
  .result-panel {
    grid-template-columns:1fr;
    display:grid;
  }

  .status {
    justify-content:center;
  }

  .advisor-drawer {
    left:14px;
    width:auto;
  }

  .media-preview {
    max-height:420px;
  }
}

@media (max-width:520px) {
  .app {
    padding:10px;
  }

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

  .main {
    padding:16px;
  }

  h1 {
    font-size:25px;
  }
}
