:root {
  --bg: #f5f7fb;
  --sidebar: #ffffff;
  --card: #ffffff;
  --soft: #f7f9fc;
  --line: #e1e6ef;
  --text: #172033;
  --muted: #667085;
  --subtle: #98a2b3;
  --purple: #7657f6;
  --purple-dark: #6545df;
  --purple-soft: #eeeafe;
  --green: #16a15a;
  --green-soft: #e8f8ef;
  --red: #e5485d;
  --red-soft: #fdecef;
  --cyan: #15aaa0;
  --cyan-soft: #e7f8f5;
  --orange: #d88719;
  --orange-soft: #fff4e3;
  --shadow: 0 22px 60px rgba(46, 54, 80, 0.08);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); }
button, textarea, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 20px 22px;
  border-right: 1px solid #edf0f5;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 2px 4px 36px; }
.brand-mark, .auth-mark {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  color: white; background: linear-gradient(145deg, #8b70ff, #6946f0); font-weight: 800; font-size: 18px;
  box-shadow: 0 12px 24px rgba(118, 87, 246, .22);
}
.brand-mark { display: block; object-fit: cover; background: transparent; }
.brand strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.brand small { display: block; margin-top: 4px; color: var(--purple); font-size: 14px; font-weight: 800; letter-spacing: .08em; }
.nav-label { margin: 0 8px 9px; color: var(--subtle); font-size: 14px; }
.nav-item, .quick-actions button {
  width: 100%; height: 42px; border: 0; border-radius: 11px; padding: 0 12px;
  display: flex; align-items: center; gap: 10px; color: var(--muted); background: transparent;
  font-size: 14px; text-align: left; transition: .2s ease;
}
.nav-item:hover, .quick-actions button:hover { color: var(--text); background: var(--soft); }
.nav-item.active { color: var(--purple); background: var(--purple-soft); font-weight: 700; }
.nav-item span, .quick-actions span { width: 18px; text-align: center; font-weight: 800; }
.quick-actions { margin-top: 28px; }
.service-card {
  margin-top: auto; padding: 16px; border: 1px solid #d9d0ff; border-radius: 15px; background: #f5f1ff;
  color: var(--purple); font-size: 14px;
}
.service-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #21c777; box-shadow: 0 0 0 4px rgba(33,199,119,.12); }
.service-card p { margin: 8px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }

.workspace { width: min(1280px, 100%); margin: 0 auto; padding: 34px 28px 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 7px; color: var(--purple); font-size: 14px; font-weight: 800; letter-spacing: .13em; }
.topbar h1 { margin: 0; font-size: clamp(25px, 2.2vw, 33px); line-height: 1.16; letter-spacing: -.04em; }
.topbar p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions > a, .secure-pill, .history-pill {
  height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: white;
  display: inline-flex; align-items: center; color: var(--muted); font-size: 14px; font-weight: 800;
}
.top-actions > a { color: var(--purple); background: var(--purple-soft); border-color: transparent; }
.history-pill { gap: 6px; transition: .2s ease; }
.history-pill:hover { color: var(--purple); border-color: #d8d0ff; background: #faf9ff; }
.history-pill > span { color: var(--purple); font-size: 14px; }
.history-pill b {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 6px; display: grid; place-items: center;
  color: var(--purple); background: var(--purple-soft); font-size: 14px;
}
.secure-pill i, .input-footer i, .queue-status i { width: 7px; height: 7px; border-radius: 50%; margin-right: 7px; background: #21c777; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.stat-card, .input-card, .platform-card, .queue-card {
  border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
}
.stat-card { min-height: 120px; padding: 19px 20px; }
.stat-label { display: flex; align-items: center; color: var(--muted); font-size: 14px; }
.stat-label i { width: 8px; height: 8px; border-radius: 3px; margin-right: 8px; }
.stat-label .purple { background: var(--purple); }.stat-label .green { background: #20c675; }
.stat-label .red { background: #f0566d; }.stat-label .cyan { background: #1cc7bb; }
.stat-card strong { display: block; margin-top: 12px; font-size: 27px; line-height: 1; letter-spacing: -.04em; }
.stat-card small { display: block; margin-top: 9px; color: var(--subtle); font-size: 14px; }

.control-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(270px, .75fr); gap: 14px; }
.input-card, .platform-card { padding: 17px; }
.card-heading, .queue-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-heading > div:first-child, .queue-heading > div:first-child { display: flex; align-items: center; gap: 10px; }
.section-index {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  color: var(--purple); background: var(--purple-soft); font: 800 10px/1 system-ui;
}
.card-heading h2, .queue-heading h2 { margin: 0; font-size: 14px; letter-spacing: -.02em; }
.link-tools { display: flex; align-items: center; gap: 6px; }
.link-tools span, .live-badge { padding: 6px 10px; border-radius: 8px; color: var(--purple); background: var(--purple-soft); font-size: 14px; font-weight: 700; }
.link-tools button {
  height: 29px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--soft); font-size: 14px;
}
#video-input {
  width: 100%; min-height: 124px; margin-top: 14px; padding: 15px; resize: vertical; outline: none;
  border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: #fbfcfe; font-size: 14px; line-height: 1.7;
}
#video-input:focus { border-color: #a997ff; box-shadow: 0 0 0 3px rgba(118,87,246,.1); }
#video-input::placeholder { color: #a8b0bf; }
.input-footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 12px; }
.input-footer > span { display: flex; align-items: center; color: var(--subtle); font-size: 14px; }
#parse-button, .download-all, .auth-submit {
  border: 0; border-radius: 11px; color: white; background: var(--purple); font-weight: 750; transition: .2s ease;
}
#parse-button { min-width: 160px; height: 40px; padding: 0 18px; font-size: 14px; }
#parse-button span { margin-right: 6px; font-size: 14px; }
#parse-button:hover, .download-all:hover, .auth-submit:hover { background: var(--purple-dark); transform: translateY(-1px); }
#parse-button:disabled, .download-all:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.card-note { margin: 10px 0 13px; color: var(--subtle); font-size: 14px; }
.platform-row { margin-top: 10px; }
.platform-row > div { display: grid; grid-template-columns: 25px 1fr auto; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; }
.platform-row strong { color: var(--text); }
.platform-code { width: 24px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: var(--purple); background: var(--purple-soft); font-size: 14px; font-weight: 800; }
.bar { display: block; height: 4px; margin-top: 5px; overflow: hidden; border-radius: 9px; background: #edf0f5; }
.bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), #9a84ff); transition: width .35s ease; }
.download-all { width: 100%; height: 38px; margin-top: 15px; font-size: 14px; }

.queue-card { margin-top: 14px; padding: 17px; min-height: 270px; }
.queue-heading > div:first-child { align-items: flex-start; }
.queue-heading p { margin: 4px 0 0; color: var(--subtle); font-size: 14px; }
.queue-status { display: flex; align-items: center; color: var(--muted); font-size: 14px; }
.overall-progress { height: 5px; margin: 15px 0 16px; overflow: hidden; border-radius: 10px; background: #eef1f6; }
.overall-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--purple), #9a84ff); transition: width .35s ease; }
.queue-list { display: grid; gap: 8px; }
.empty-state { min-height: 160px; display: grid; place-items: center; align-content: center; color: var(--subtle); text-align: center; }
.empty-state > span { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--purple-soft); color: var(--purple); font-size: 20px; }
.empty-state strong { margin-top: 11px; color: var(--muted); font-size: 14px; }
.empty-state p { margin: 5px 0 0; font-size: 14px; }
.task {
  display: grid; grid-template-columns: 34px 96px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  min-height: 52px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfe;
}
.task-index { color: var(--subtle); font: 700 9px/1 ui-monospace, monospace; }
.task-platform { padding: 7px 9px; border-radius: 8px; color: var(--purple); background: var(--purple-soft); font-size: 14px; font-weight: 750; text-align: center; }
.task-copy { min-width: 0; }
.task-copy strong, .task-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-copy strong { font-size: 14px; font-weight: 650; }
.task-copy small { margin-top: 4px; color: var(--subtle); font-size: 14px; }
.task-action {
  min-width: 76px; height: 30px; padding: 0 12px; border: 0; border-radius: 8px;
  color: var(--muted); background: #eef1f6; font-size: 14px; font-weight: 750;
}
.task.is-ready .task-action { color: white; background: var(--purple); }
.task.is-error .task-platform { color: var(--red); background: var(--red-soft); }
.task.is-error .task-action { color: var(--red); background: var(--red-soft); }
.task.is-working .task-platform { color: var(--orange); background: var(--orange-soft); }
.legal-note { padding: 15px 0 0; color: var(--subtle); font-size: 14px; text-align: center; }

.history-overlay {
  position: fixed; z-index: 110; inset: 0; display: flex; justify-content: flex-end;
  background: rgba(23, 32, 51, .24); backdrop-filter: blur(5px);
  opacity: 0; transition: opacity .22s ease;
}
.history-overlay[hidden] { display: none; }
.history-overlay.is-open { opacity: 1; }
.history-panel {
  width: min(500px, calc(100% - 28px)); height: 100%; padding: 25px; overflow: hidden;
  border-left: 1px solid var(--line); background: #fbfcfe; box-shadow: -24px 0 70px rgba(35, 42, 63, .16);
  display: flex; flex-direction: column; transform: translateX(28px); transition: transform .22s ease;
}
.history-overlay.is-open .history-panel { transform: translateX(0); }
.history-header, .history-header > div { display: flex; align-items: center; }
.history-header { justify-content: space-between; gap: 18px; }
.history-header > div { gap: 12px; }
.history-header .eyebrow { margin-bottom: 4px; }
.history-header h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
.history-icon {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  color: var(--purple); background: var(--purple-soft); font-size: 20px;
}
.history-close {
  width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); background: white; font-size: 20px; line-height: 1;
}
.history-close:hover { color: var(--text); background: var(--soft); }
.history-privacy {
  margin-top: 20px; padding: 13px 14px; border: 1px solid #ccebdc; border-radius: 13px;
  display: flex; align-items: center; gap: 11px; background: var(--green-soft);
}
.history-privacy > span {
  width: 27px; height: 27px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center;
  color: white; background: var(--green); font-size: 14px; font-weight: 800;
}
.history-privacy p { margin: 0; }
.history-privacy strong, .history-privacy small { display: block; }
.history-privacy strong { color: #157347; font-size: 14px; }
.history-privacy small { margin-top: 3px; color: #54806a; font-size: 14px; line-height: 1.5; }
.history-toolbar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.history-toolbar span { color: var(--subtle); font-size: 14px; }
.history-toolbar button {
  height: 28px; padding: 0 10px; border: 1px solid #f4cbd1; border-radius: 8px;
  color: var(--red); background: var(--red-soft); font-size: 14px; font-weight: 700;
}
.history-toolbar button:disabled { cursor: not-allowed; opacity: .45; }
.history-list { min-height: 0; overflow: auto; display: grid; align-content: start; gap: 8px; padding-right: 3px; }
.history-empty { min-height: 300px; display: grid; place-items: center; align-content: center; color: var(--subtle); text-align: center; }
.history-empty > span { font-size: 35px; color: #c1b6fa; }
.history-empty strong { margin-top: 12px; color: var(--muted); font-size: 14px; }
.history-empty p { margin: 6px 0 0; font-size: 14px; }
.history-entry {
  padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: white;
  display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; box-shadow: 0 8px 24px rgba(46, 54, 80, .04);
}
.history-entry-platform {
  height: 28px; border-radius: 8px; display: grid; place-items: center;
  color: var(--purple); background: var(--purple-soft); font-size: 14px; font-weight: 750;
}
.history-entry-copy { min-width: 0; }
.history-entry-copy strong, .history-entry-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-entry-copy strong { font-size: 14px; }
.history-entry-copy small { margin-top: 5px; color: var(--subtle); font-size: 14px; }
.history-entry-footer {
  grid-column: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 2px;
}
.history-entry-footer time { color: var(--subtle); font-size: 14px; }
.history-entry-actions { display: flex; gap: 6px; }
.history-entry-actions button {
  height: 27px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px;
  color: var(--muted); background: var(--soft); font-size: 14px;
}
.history-entry-actions .history-reuse { color: white; border-color: var(--purple); background: var(--purple); font-weight: 700; }

.auth-overlay {
  position: fixed; z-index: 100; inset: 0; padding: 24px; display: grid; place-items: center;
  background: rgba(241,244,249,.88); backdrop-filter: blur(12px); transition: opacity .25s ease;
}
.auth-overlay.is-hidden { opacity: 0; pointer-events: none; }
.auth-card {
  width: min(450px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 22px;
  background: white; box-shadow: 0 28px 80px rgba(35,42,63,.16); text-align: center;
}
.auth-mark { margin: 0 auto 18px; }
.auth-card h2 { margin: 0; font-size: 23px; letter-spacing: -.04em; }
.auth-card > p:not(.eyebrow) { margin: 9px 0 24px; color: var(--muted); font-size: 14px; }
.auth-card label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 14px; text-align: left; }
.auth-input-wrap { position: relative; }
.auth-input-wrap input {
  width: 100%; height: 44px; padding: 0 65px 0 14px; outline: none; border: 1px solid var(--line);
  border-radius: 11px; color: var(--text); background: var(--soft); font-size: 14px;
}
.auth-input-wrap input:focus { border-color: #a997ff; box-shadow: 0 0 0 3px rgba(118,87,246,.1); }
.auth-input-wrap button { position: absolute; top: 7px; right: 7px; height: 30px; border: 0; color: var(--purple); background: transparent; font-size: 14px; }
.auth-message { display: block; min-height: 17px; margin: 9px 0; color: var(--subtle); font-size: 14px; }
.auth-message.is-error { color: var(--red); }
.auth-submit { width: 100%; height: 43px; font-size: 14px; }
.auth-card > small { display: block; margin-top: 17px; color: var(--subtle); font-size: 14px; }
.toast {
  position: fixed; z-index: 120; left: 50%; bottom: 28px; max-width: min(420px, calc(100% - 32px)); padding: 11px 16px;
  border-radius: 10px; color: white; background: #273044; box-shadow: 0 16px 40px rgba(23,32,51,.2);
  font-size: 14px; opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .25s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 24px 12px; }
  .brand { justify-content: center; margin-left: 0; margin-right: 0; }
  .brand > span:last-child, .nav-label, .nav-item:not(.active), .quick-actions, .service-card { display: none; }
  .nav-item.active { justify-content: center; padding: 0; font-size: 0; }
  .nav-item.active span { font-size: 15px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .control-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 14px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { justify-content: flex-start; margin: 0; }.brand > span:last-child { display: block; }
  .sidebar nav { display: none; }
  .workspace { padding: 22px 14px; }
  .topbar { align-items: flex-start; }.secure-pill, .top-actions > a { display: none; }
  .stats-grid { gap: 9px; }.stat-card { min-height: 105px; padding: 15px; }
  .input-footer { align-items: stretch; flex-direction: column; }
  #parse-button { width: 100%; }
  .task { grid-template-columns: 28px 70px minmax(0, 1fr); }
  .task-action { grid-column: 2 / -1; width: 100%; }
  .history-panel { width: 100%; padding: 20px 16px; }
  .history-entry { grid-template-columns: 52px minmax(0, 1fr); }
}
