:root {
  color-scheme: dark;
  --bg: #0b0f19;
  --surface: #111827;
  --surface-raised: #172033;
  --surface-soft: #1c263a;
  --surface-hover: #222e45;
  --text: #f8fafc;
  --text-muted: #9aa8bc;
  --text-subtle: #718096;
  --border: #2b374c;
  --border-strong: #40506a;
  --primary: #f6bd26;
  --primary-hover: #ffd45a;
  --on-primary: #271900;
  --success: #34d399;
  --danger: #fb7185;
  --danger-bg: rgba(190, 24, 93, 0.13);
  --warning: #fbbf24;
  --info: #60a5fa;
  --focus: #93c5fd;
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.34);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --sidebar-width: 244px;
  --transition: 180ms ease;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 75% -15%, rgba(246, 189, 38, 0.08), transparent 30rem),
    var(--bg);
  font-size: 16px;
  line-height: 1.5;
}

body.drawer-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
select,
input[type="file"] {
  cursor: pointer;
}

button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(147, 197, 253, 0.8);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.sr-only,
.svg-sprite {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--on-primary);
  background: var(--primary);
  transform: translateY(-180%);
  transition: transform var(--transition);
}

.skip-link:focus {
  transform: translateY(0);
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.13em;
}

.brand-mark {
  display: inline-grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: var(--on-primary);
  background: linear-gradient(145deg, #ffda62, #e9a90d);
  box-shadow: 0 10px 26px rgba(246, 189, 38, 0.16);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.05em;
}

.brand-mark-large {
  width: 56px;
  height: 56px;
  margin-bottom: 24px;
  border-radius: 16px;
  font-size: 19px;
}

.login-view {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 430px);
  padding: clamp(28px, 7vw, 44px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(17, 24, 39, 0.94);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin: 0;
  font-size: clamp(26px, 6vw, 34px);
  line-height: 1.2;
}

.login-intro {
  margin: 10px 0 28px;
  color: var(--text-muted);
}

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

.app-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  padding: 20px 16px;
  border-right: 1px solid var(--border);
  background: rgba(12, 17, 28, 0.97);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 24px;
}

.brand-row strong,
.brand-row small,
.account-copy strong,
.account-copy small {
  display: block;
}

.brand-row strong {
  line-height: 1.25;
}

.brand-row small,
.account-copy small {
  margin-top: 2px;
  color: var(--text-subtle);
  font-size: 12px;
}

.main-nav {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--text-muted);
  background: transparent;
  font-weight: 650;
  text-align: left;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.nav-item:hover:not(:disabled) {
  color: var(--text);
  background: var(--surface-soft);
}

.nav-item.active {
  border-color: rgba(246, 189, 38, 0.18);
  color: var(--primary);
  background: rgba(246, 189, 38, 0.1);
}

.nav-item:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.account-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 50%;
  color: var(--on-primary);
  background: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.account-copy {
  min-width: 0;
  flex: 1;
}

.account-copy strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 3.5vw, 44px);
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 25, 0.92);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.2;
}

.selected-context {
  display: flex;
  max-width: 300px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.selected-context img {
  width: 32px;
  height: 42px;
  border-radius: 6px;
  background: var(--surface-soft);
  object-fit: cover;
}

.selected-context span,
.selected-context small,
.selected-context strong {
  display: block;
  min-width: 0;
}

.selected-context small {
  color: var(--text-subtle);
  font-size: 11px;
}

.selected-context strong {
  overflow: hidden;
  margin-top: 1px;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: 30px clamp(18px, 3.5vw, 44px) 56px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  border: 0;
  background: rgba(3, 7, 18, 0.54);
  backdrop-filter: blur(3px);
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 18px clamp(18px, 3.5vw, 44px) 0;
  padding: 14px 16px;
  border: 1px solid rgba(251, 113, 133, 0.38);
  border-radius: var(--radius-md);
  background: var(--danger-bg);
}

.error-banner p,
.error-banner strong {
  margin: 0;
}

.error-banner p {
  margin-top: 2px;
  color: #fecdd3;
  font-size: 13px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: clamp(22px, 3vw, 30px);
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--text-muted);
}

.heading-actions,
.form-actions,
.upload-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.split-layout {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(360px, 0.92fr) minmax(480px, 1.08fr);
  gap: 18px;
}

#episodes-view .split-layout {
  grid-template-columns: minmax(560px, 1.12fr) minmax(420px, 0.88fr);
}

.drama-library-layout {
  display: grid;
}

.panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(17, 24, 39, 0.92);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.13);
}

.list-panel {
  overflow: hidden;
}

.editor-panel {
  position: sticky;
  top: 102px;
  padding: clamp(18px, 3vw, 26px);
}

.editor-panel.is-switching {
  animation: editor-switch-in 240ms ease-out;
}

.settings-panel {
  max-width: 980px;
  padding: clamp(18px, 3vw, 26px);
}

.system-config-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  scrollbar-width: thin;
}

.system-config-tabs button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 750;
}

.system-config-tabs button:hover { color: var(--text); background: var(--surface-hover); }
.system-config-tabs button.active {
  border-color: rgba(246, 189, 38, 0.45);
  background: rgba(246, 189, 38, 0.12);
  color: var(--primary);
}

.system-config-group[hidden] { display: none; }
#system-config-form[hidden] { display: none; }

.style-mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.style-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 108px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.style-mode-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(87, 197, 255, 0.09);
  box-shadow: 0 0 0 1px var(--primary);
}

.style-mode-option input { margin-top: 4px; accent-color: var(--primary); }
.style-mode-option span { display: grid; gap: 8px; }
.style-mode-option small { color: var(--muted); line-height: 1.55; }

@media (max-width: 720px) {
  .style-mode-options { grid-template-columns: 1fr; }
}

.telegram-bot-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  align-items: start;
  gap: 18px;
}

.telegram-bot-layout .settings-panel {
  max-width: none;
}

.telegram-bot-runtime {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.telegram-bot-runtime span {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(13, 20, 34, 0.65);
  font-size: 12px;
}

.telegram-bot-runtime p {
  flex-basis: 100%;
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.telegram-bot-preview {
  position: sticky;
  top: 102px;
  padding: clamp(18px, 3vw, 24px);
}

.telegram-message-card {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 16px;
  color: #111827;
  background: #f8fafc;
}

.telegram-message-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #168aad;
}

.telegram-preview-avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: #0b1220;
  font-size: 12px;
  font-weight: 800;
}

.telegram-preview-media {
  position: relative;
  display: grid;
  min-height: 190px;
  overflow: hidden;
  place-items: center;
  border-radius: 10px;
  color: #d8e0ee;
  background: #182235;
}

.telegram-preview-media img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.telegram-preview-media span {
  position: relative;
  z-index: 1;
  align-self: end;
  width: 100%;
  padding: 32px 12px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  font-size: 12px;
}

.telegram-message-card p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.telegram-preview-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.telegram-preview-buttons span {
  min-width: 0;
  padding: 9px 7px;
  overflow: hidden;
  border-radius: 6px;
  background: #e5e7eb;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-config-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 20, 34, 0.42);
}

.system-config-group legend {
  padding: 0 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.system-config-group-help {
  margin: -3px 0 1px;
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.6;
}

.site-logo-preview {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--text-subtle);
  font-size: 12px;
}

.site-logo-preview img {
  width: 56px;
  height: 56px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0c0c13;
  object-fit: contain;
}

.site-logo-preview--wide img {
  width: auto;
  min-width: 112px;
  max-width: min(220px, 70vw);
  height: auto;
  max-height: 56px;
}

.brand-image-history {
  display: grid;
  gap: 12px;
}

.brand-image-history-heading {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}

.brand-image-history-heading small,
.brand-image-history-empty {
  color: var(--text-subtle);
  font-size: 12px;
}

.brand-image-history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.brand-image-history-item {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(6, 10, 19, 0.42);
}

.brand-image-history-item img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 82px;
  margin-inline: auto;
  padding: 6px;
  border-radius: 9px;
  background: #0c0c13;
  object-fit: contain;
}

.brand-image-history-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.brand-image-history-actions button {
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}

.home-ad-list {
  display: grid;
  gap: 14px;
}

.home-ad-item {
  display: grid;
  grid-template-columns: minmax(110px, 0.35fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 20, 34, 0.42);
}

.home-ad-item legend {
  padding: 0 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
}

.home-ad-item .file-field,
.home-ad-preview,
.home-ad-actions {
  grid-column: span 3;
}

.home-ad-preview {
  display: grid;
  gap: 8px;
  color: var(--text-subtle);
  font-size: 12px;
}

.home-ad-preview img {
  width: min(100%, 710px);
  aspect-ratio: 71 / 18;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c0c13;
  object-fit: cover;
}

.home-ad-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tracking-group-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.tracking-group-option {
  display: flex;
  min-width: 0;
  gap: 11px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(19, 29, 48, 0.72);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.tracking-group-option:hover {
  border-color: var(--border-strong);
  background: rgba(25, 39, 64, 0.82);
}

.tracking-group-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(67, 97, 238, 0.14);
  box-shadow: 0 0 0 1px rgba(103, 128, 255, 0.18);
}

.tracking-group-option input {
  flex: 0 0 auto;
  margin: 3px 0 0;
  accent-color: var(--primary);
}

.tracking-group-option span {
  display: grid;
  flex: 1 1 auto;
  min-width: 0;
  gap: 5px;
}

.tracking-group-order {
  display: inline-grid;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  color: #0d1422;
  background: var(--primary);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.tracking-group-order:empty {
  display: none;
}

.tracking-group-option strong {
  color: var(--text);
  font-size: 14px;
}

.tracking-group-option small {
  overflow-wrap: anywhere;
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 1.5;
}

.tracking-code-editor {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(13, 20, 34, 0.55);
}

.tracking-record-toolbar { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.tracking-record-toolbar p { margin:0; color:var(--muted); }
.tracking-record-list { display:grid; gap:14px; }
.tracking-record { display:grid; grid-template-columns:130px minmax(0,1fr) auto; align-items:center; gap:18px; padding:18px; border:1px solid var(--border); border-radius:16px; background:var(--panel); }
.tracking-record-toggle { display:flex; align-items:center; gap:10px; font-weight:700; }
.tracking-record-toggle input { width:22px; height:22px; accent-color:var(--primary); }
.tracking-record-content { min-width:0; display:grid; gap:8px; }
.tracking-record-content strong { font-size:17px; }
.tracking-record-content .tag { display:inline-flex; margin-right:6px; padding:3px 9px; border-radius:999px; background:var(--surface-muted); color:var(--muted); font-size:12px; }
.tracking-record-content code { display:block; overflow:hidden; padding:9px 12px; border-radius:9px; background:var(--surface-muted); color:var(--text); text-overflow:ellipsis; white-space:nowrap; }
.tracking-record-actions { display:flex; gap:10px; }
.tracking-code-form { display:grid; gap:16px; }
.tracking-code-form textarea { min-height:240px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; }
@media (max-width: 760px) { .tracking-record { grid-template-columns:1fr; } .tracking-record-actions { justify-content:flex-end; } .tracking-record-toolbar { align-items:stretch; flex-direction:column; } }

.tracking-code-editor-heading,
.tracking-code-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tracking-code-editor-heading > div {
  display: grid;
  gap: 3px;
}

.tracking-code-editor-heading > .tracking-code-editor-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.tracking-code-editor-actions label {
  display: grid;
  gap: 4px;
  color: var(--text-subtle);
  font-size: 10px;
}

.tracking-code-editor-actions select {
  min-width: 104px;
  min-height: 38px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  background: #0d1422;
}

.tracking-code-editor-heading strong {
  color: var(--text);
  font-size: 14px;
}

.tracking-code-editor-heading small {
  color: var(--text-subtle);
  font-size: 11px;
}

.tracking-code-editor textarea {
  min-height: 190px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
}

.tracking-code-preview-dialog {
  width: min(1040px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 32px));
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
}

.tracking-code-preview-dialog::backdrop {
  background: rgba(3, 8, 18, 0.76);
  backdrop-filter: blur(5px);
}

.tracking-code-preview-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
}

.tracking-code-preview-heading {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.tracking-code-preview-heading h2,
.tracking-code-preview-heading p {
  margin: 0;
}

.tracking-code-preview-heading > div {
  display: grid;
  gap: 4px;
}

.tracking-code-preview-heading > div > p:last-child {
  color: var(--text-subtle);
  font-size: 12px;
}

#tracking-code-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.content-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  width: min(920px, calc(100vw - 54px));
  overflow: auto;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 0;
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.38);
  animation: drawer-in 180ms ease-out;
}

.content-drawer[data-panel="episodes"] {
  width: min(1280px, calc(100vw - 42px));
}

.relation-drawer {
  padding: clamp(18px, 3vw, 28px);
}

.drawer-heading {
  align-items: center;
}

.drawer-title-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-toolbar,
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-toolbar {
  min-height: 66px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-toolbar h3,
.panel-title-row h3 {
  margin: 0;
  font-size: 17px;
}

.panel-title-row {
  margin-bottom: 22px;
}

.count-badge {
  display: inline-flex;
  min-width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.search-field input {
  width: min(210px, 40vw);
  min-height: 40px;
}

.drama-toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.featured-filter-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.featured-filter-field select {
  min-width: 112px;
  min-height: 44px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  background: #0d1422;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.featured-filter-field select:hover {
  border-color: #60738f;
}

.featured-filter-field select:focus {
  border-color: var(--primary);
  background: #101827;
  box-shadow: 0 0 0 3px rgba(246, 189, 38, 0.1);
}

.button,
.icon-button {
  position: relative;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 750;
  transition: color var(--transition), background var(--transition), border-color var(--transition), opacity var(--transition);
  touch-action: manipulation;
}

.button {
  padding: 0 16px;
}

.button.primary {
  color: var(--on-primary);
  background: var(--primary);
}

.button.primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.button.secondary {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-soft);
}

.button.secondary:hover:not(:disabled) {
  border-color: #5a6e8c;
  background: var(--surface-hover);
}

.button.danger-ghost {
  border-color: rgba(251, 113, 133, 0.35);
  color: #fecdd3;
  background: rgba(251, 113, 133, 0.08);
}

.button.full {
  width: 100%;
}

.button.icon-text {
  gap: 8px;
}

.compact-action {
  min-height: 38px;
  padding-inline: 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}

.compact-action svg,
.compact-action span {
  flex: 0 0 auto;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button[aria-busy="true"] .button-label {
  opacity: 0;
}

.button-spinner {
  position: absolute;
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.button[aria-busy="true"] .button-spinner {
  display: block;
}

.icon-button {
  flex: 0 0 auto;
  width: 44px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.icon-button.compact {
  width: 42px;
  min-height: 42px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px;
}

.field {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 650;
}

.field > span:first-child b {
  color: var(--danger);
}

.field input,
.field textarea,
.field select,
.search-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  background: #0d1422;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.field input,
.field textarea,
.search-field input {
  padding: 10px 12px;
}

.field select {
  padding: 0 38px 0 12px;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.field input:hover,
.field textarea:hover,
.field select:hover,
.search-field input:hover {
  border-color: #60738f;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.search-field input:focus {
  border-color: var(--primary);
  background: #101827;
  box-shadow: 0 0 0 3px rgba(246, 189, 38, 0.1);
}

.field input[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.field input[readonly] {
  cursor: default;
  color: var(--text-muted);
  background: rgba(13, 20, 34, 0.55);
}

.field-help,
.field-error {
  min-height: 0;
  font-size: 11px;
  font-weight: 500;
}

.field-help {
  color: var(--text-subtle);
}

.field-error {
  color: #fda4af;
}

.span-2 {
  grid-column: 1 / -1;
}

.password-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #0d1422;
}

.password-field:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246, 189, 38, 0.1);
}

.password-field input {
  border: 0;
  background: transparent;
  box-shadow: none !important;
}

.url-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #0d1422;
}

.url-input-row:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(246, 189, 38, 0.1);
}

.url-input-row input {
  min-width: 0;
  border: 0;
  background: transparent;
  box-shadow: none !important;
}

.url-open-button {
  width: 44px;
  min-height: 44px;
}

.file-field {
  position: relative;
}

.file-field > input[type="file"] {
  position: absolute;
  inset: 27px 0 0;
  z-index: 1;
  width: 100%;
  height: calc(100% - 27px);
  opacity: 0;
}

.file-drop-copy {
  display: flex;
  min-height: 82px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px;
  border: 1px dashed #566a87;
  border-radius: 11px;
  color: var(--text-muted);
  background: rgba(13, 20, 34, 0.7);
  text-align: left;
  transition: border-color var(--transition), background var(--transition);
}

.file-field:hover .file-drop-copy,
.file-field:focus-within .file-drop-copy {
  border-color: var(--primary);
  background: rgba(246, 189, 38, 0.05);
}

.file-drop-copy strong,
.file-drop-copy small {
  display: block;
}

.file-drop-copy strong {
  color: var(--text);
}

.file-drop-copy small {
  margin-top: 2px;
  color: var(--text-subtle);
  font-weight: 500;
}

.cover-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.cover-preview img {
  width: 64px;
  height: 90px;
  border-radius: 7px;
  background: #0d1422;
  object-fit: cover;
}

.cover-preview strong,
.cover-preview small {
  display: block;
}

.cover-preview small {
  max-width: 36ch;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: var(--text-muted);
}

.derived-links {
  display: grid;
  gap: 12px;
}

.derived-links div {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.derived-links small {
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 700;
}

.derived-links code {
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.choice-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.55fr);
  align-items: end;
  gap: 16px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
}

.choice-group legend {
  padding: 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.switch-row {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-hover);
  transition: background var(--transition), border-color var(--transition);
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  content: "";
  transition: transform var(--transition), background var(--transition);
}

.switch-row input:checked + .switch {
  border-color: var(--primary);
  background: rgba(246, 189, 38, 0.25);
}

.switch-row input:checked + .switch::after {
  background: var(--primary);
  transform: translateX(18px);
}

.switch-row input:focus-visible + .switch {
  outline: 3px solid rgba(147, 197, 253, 0.8);
  outline-offset: 2px;
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row small {
  margin-top: 2px;
  color: var(--text-subtle);
  font-size: 11px;
}

.compact-field {
  gap: 5px;
}

.form-actions {
  margin-top: 5px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.form-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13px;
}

.form-message.error {
  border: 1px solid rgba(251, 113, 133, 0.3);
  color: #fecdd3;
  background: var(--danger-bg);
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 2px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill.published,
.status-pill.ready,
.status-pill.saved,
.status-pill.free {
  color: var(--success);
  background: rgba(52, 211, 153, 0.08);
}

.status-pill.draft,
.status-pill.pending {
  color: var(--warning);
  background: rgba(251, 191, 36, 0.08);
}

.status-pill.archived,
.status-pill.disabled,
.status-pill.failed,
.status-pill.hidden {
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.08);
}

.status-pill.member,
.status-pill.coin {
  color: #fdba74;
  background: rgba(251, 146, 60, 0.08);
}

.status-pill.featured {
  color: var(--primary);
  background: rgba(246, 189, 38, 0.1);
}

.drama-title-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.drama-title-line .table-title {
  min-width: 0;
}

.drama-list {
  display: grid;
}

.drama-library-panel .table-wrap {
  overflow-x: auto;
}

.drama-library-table {
  min-width: 1240px;
  table-layout: fixed;
}

.drama-library-table th:nth-child(1) { width: 3%; }
.drama-library-table th:nth-child(2) { width: 14%; }
.drama-library-table th:nth-child(3) { width: 22%; }
.drama-library-table th:nth-child(4) { width: 8%; }
.drama-library-table th:nth-child(5) { width: 11%; }
.drama-library-table th:nth-child(6) { width: 9%; }
.drama-library-table th:nth-child(7) { width: 9%; }
.drama-library-table th:nth-child(8) { width: 11%; }
.drama-library-table th:nth-child(9) { width: 11%; }
.drama-library-table th:nth-child(10) { width: 13%; }
.drama-library-table .sync-status-cell { flex-direction: column; align-items: flex-start; gap: 6px; }
.drama-library-table td[data-label="数据"] .table-title,
.drama-library-table td[data-label="数据"] .table-subtitle { white-space: normal; }
.drama-library-table .compact-action { padding-inline: 9px; }

.drama-library-table td[data-drama-metadata-cell] {
  min-width: 240px;
  max-width: 330px;
  overflow-wrap: anywhere;
}

.drama-library-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
  min-height: 0;
  accent-color: var(--primary);
}

.drama-source { margin-bottom: 5px; }
.drama-metadata-open { margin-top: 8px; }
.drama-metadata-editor { display: grid; gap: 8px; min-width: 210px; margin-top: 8px; }
.drama-metadata-editor label { display: grid; gap: 5px; }
.drama-metadata-editor label > span { color: var(--text-muted); font-size: 12px; }
.drama-metadata-editor input,
.drama-metadata-editor textarea { width: 100%; min-width: 0; padding: 8px 10px; }
.drama-metadata-editor textarea { resize: vertical; }
.drama-metadata-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.drama-metadata-feedback { display: block; margin-top: 8px; white-space: normal; overflow-wrap: anywhere; }
.drama-metadata-feedback.error { color: var(--danger); }
.drama-metadata-feedback.success { color: var(--success); }
.drama-bulk-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 0; }
.drama-bulk-toolbar > span { color: var(--text-muted); font-size: 13px; }
.drama-bulk-toolbar label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.drama-bulk-toolbar input { width: 200px; max-width: 100%; min-height: 36px; padding: 7px 10px; }
.drama-bulk-toolbar p { flex-basis: 100%; margin: 0; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
.drama-bulk-toolbar p:empty { display: none; }

.drama-library-table th:last-child,
.drama-library-table td:last-child {
  min-width: 130px;
}

.drama-library-table .relation-actions .button { display: flex; width: 100%; margin: 5px 0; }
.drama-library-table .relation-actions .button + .button { margin-left: 0; }
.drama-library-table th,
.drama-library-table td { padding-inline: 9px; }

.drama-item {
  display: grid;
  min-height: 96px;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  background: transparent;
  text-align: left;
  transition: background var(--transition);
}

.drama-item:last-child {
  border-bottom: 0;
}

.drama-item:hover,
.drama-item.active {
  background: var(--surface-soft);
}

.drama-item.active {
  box-shadow: inset 3px 0 var(--primary);
}

.drama-item img {
  width: 58px;
  height: 76px;
  border-radius: 7px;
  background: #0d1422;
  object-fit: cover;
}

.drama-item-copy {
  min-width: 0;
}

.drama-item-copy strong,
.drama-item-copy small {
  display: block;
}

.drama-item-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drama-item-copy small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drama-item-meta {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.drama-cell {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.drama-cell img {
  flex: 0 0 auto;
  width: 48px;
  height: 64px;
  border-radius: 7px;
  background: #0d1422;
  object-fit: cover;
}

.drama-cell span {
  min-width: 0;
}

.relation-actions {
  white-space: nowrap;
}

.drama-library-table td[data-label="编辑"] {
  white-space: nowrap;
}

.drama-library-table td[data-label="同步状态"] {
  white-space: nowrap;
}

.system-config-category-panel { display: grid; gap: 4px; }
.system-config-category-panel[hidden] { display: none; }
.system-config-category-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0 16px; }
.system-config-category-heading > div { display: grid; gap: 4px; }
.system-config-category-heading small { color: var(--text-muted); font-weight: 400; }
.category-management-list { padding-bottom: 4px; }
.category-management-row { display: grid; grid-template-columns: minmax(130px, .8fr) repeat(2, minmax(180px, 1fr)) minmax(135px, auto) auto; align-items: end; gap: 12px; padding: 14px 0; border-top: 1px solid var(--border); }
.category-management-key { align-self: center; display: grid; gap: 4px; min-width: 0; }
.category-management-key strong { overflow-wrap: anywhere; }
.category-management-key small, .category-management-empty { color: var(--text-muted); }
.category-enabled { min-height: 42px; padding: 0; border: 0; background: transparent; }

@media (max-width: 1000px) {
  .category-management-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .category-management-row { grid-template-columns: 1fr; }
}

.sync-status-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.sync-action {
  min-width: 68px;
  justify-content: center;
}

.sync-job-table {
  min-width: 1040px;
}

.sync-job-actions {
  white-space: nowrap;
}

.sync-job-actions .button + .button {
  margin-left: 8px;
}

.error-text {
  color: #fca5a5;
}

.sync-job-detail {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.48);
}

.sync-job-error-item {
  display: grid;
  gap: 4px;
}

.sync-job-error-item span,
.sync-job-error-item small {
  overflow-wrap: anywhere;
}

.sync-job-error-item span {
  color: #fecaca;
}

.sync-job-error-item small {
  color: var(--muted);
}

.relation-actions .button + .button {
  margin-left: 8px;
}

.hot-rate {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  align-content: center;
  padding: 42px 20px;
  text-align: center;
}

.empty-state svg {
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  color: var(--text-subtle);
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  max-width: 36ch;
  margin: 7px 0 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.skeleton-list {
  display: grid;
  gap: 1px;
  background: var(--border);
}

.skeleton-list span {
  display: block;
  height: 96px;
  background: linear-gradient(100deg, var(--surface) 20%, var(--surface-soft) 45%, var(--surface) 70%);
  background-size: 260% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.table-controls {
  display: flex;
  min-width: min(100%, 760px);
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 20, 34, 0.34);
}

.table-date-filter,
.table-pagination,
.table-date-filter label,
.table-page-size {
  display: flex;
  align-items: center;
}

.table-date-filter,
.table-pagination {
  flex-wrap: wrap;
  gap: 8px;
}

.table-date-filter label,
.table-page-size {
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
}

.table-filter-label,
.table-page-number {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.table-date-filter input,
.table-page-size select {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  background: var(--surface-soft);
  font: inherit;
}

.table-date-filter input {
  width: 142px;
  padding: 0 9px;
  color-scheme: dark;
}

.table-page-size select {
  padding: 0 30px 0 10px;
}

.table-controls .button {
  min-height: 44px;
}

.table-date-separator,
.table-page-summary {
  color: var(--text-subtle);
  font-size: 12px;
  white-space: nowrap;
}

.table-date-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table-filter-empty {
  min-height: 180px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.episode-table {
  min-width: 860px;
  table-layout: fixed;
}

.episode-table th:nth-child(1) { width: 142px; }
.episode-table th:nth-child(2) { width: 92px; }
.episode-table th:nth-child(3) { width: 92px; }

.data-table th,
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--text-subtle);
  background: rgba(13, 20, 34, 0.6);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table tbody tr {
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}

.data-table tbody tr:hover,
.data-table tbody tr.active {
  background: var(--surface-soft);
}

.episode-table tbody tr[data-edit-episode] {
  cursor: pointer;
}

.episode-table tbody tr[data-edit-episode]:hover,
.episode-table tbody tr[data-edit-episode]:focus-visible {
  transform: translateX(3px);
}

.episode-table tbody tr[data-edit-episode]:focus-visible {
  outline: 2px solid rgba(246, 189, 38, 0.58);
  outline-offset: -2px;
}

.episode-table tbody tr.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.data-table td:last-child,
.data-table th:last-child {
  text-align: right;
}

.episode-table td:last-child,
.episode-table th:last-child {
  text-align: left;
}

.table-title {
  display: block;
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-subtitle {
  display: block;
  max-width: 42ch;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-url-cell {
  min-width: 0;
}

.episode-url-link,
.episode-url-text,
.episode-url-empty {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-url-link svg,
.episode-url-text svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.episode-url-link span,
.episode-url-text span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.episode-url-link {
  color: #93c5fd;
}

.episode-url-link:hover {
  color: #bfdbfe;
}

.episode-url-empty {
  color: var(--text-subtle);
}

.table-action {
  display: inline-flex;
  min-width: 44px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  background: var(--surface);
}

.table-action:hover {
  color: var(--primary);
  background: var(--surface-hover);
}

.upload-panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(13, 20, 34, 0.72);
}

.upload-summary,
.upload-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.upload-summary strong,
.upload-summary p {
  margin: 0;
}

.upload-summary p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

#upload-percent {
  color: var(--primary);
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 9px;
  margin: 13px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-hover);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e5a915, #ffda62);
  transition: width 180ms ease-out;
}

.upload-meta {
  color: var(--text-subtle);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.upload-actions {
  margin-top: 14px;
}

.toast-region {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  display: grid;
  width: min(380px, calc(100vw - 36px));
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: #162035;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 220ms ease-out;
}

.toast::before {
  width: 4px;
  height: 100%;
  min-height: 28px;
  border-radius: 999px;
  background: var(--info);
  content: "";
}

.toast.success::before {
  background: var(--success);
}

.toast.error::before {
  background: var(--danger);
}

.toast strong,
.toast p {
  margin: 0;
}

.toast strong {
  font-size: 13px;
}

.toast p {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12px;
}

.toast button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 7px;
  color: var(--text-muted);
  background: transparent;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  to { background-position: -180% 0; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
}

@keyframes drawer-in {
  from { opacity: 0; transform: translateX(28px); }
}

@keyframes editor-switch-in {
  from {
    opacity: 0.78;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 1120px) {
  :root { --sidebar-width: 214px; }
  .split-layout { grid-template-columns: minmax(310px, 0.85fr) minmax(420px, 1.15fr); }
  #episodes-view .split-layout { grid-template-columns: minmax(420px, 1fr) minmax(360px, 0.86fr); }
  .choice-group { grid-template-columns: 1fr; }
  .telegram-bot-layout { grid-template-columns: 1fr; }
  .telegram-bot-preview { position: static; }
}

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

  .sidebar {
    position: sticky;
    display: grid;
    height: auto;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-row { padding: 0; }
  .brand-row > span:last-child { display: none; }
  .main-nav { display: flex; justify-content: start; gap: 4px; overflow-x: auto; }
  .nav-item { width: auto; min-height: 44px; padding: 0 12px; }
  .account-card { margin: 0; padding: 0; border: 0; background: transparent; }
  .account-avatar, .account-copy { display: none; }
  .topbar { top: 65px; min-height: 72px; }
  .editor-panel { position: static; }
  .content-drawer {
    position: fixed;
    top: 0;
    width: min(760px, calc(100vw - 34px));
  }
  .content-drawer[data-panel="episodes"] {
    width: min(820px, calc(100vw - 24px));
  }
  .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .login-view { padding: 14px; }
  .login-card { padding: 26px 20px; border-radius: 18px; }
  .sidebar { grid-template-columns: auto minmax(0, 1fr) auto; padding-inline: 10px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .main-nav { overflow: hidden; }
  .nav-item { min-width: 44px; padding: 0 10px; }
  .nav-item span { display: none; }
  .topbar { top: 59px; padding: 11px 16px; }
  .selected-context { max-width: 46%; border: 0; padding: 0; background: transparent; }
  .selected-context img { display: none; }
  .content { padding: 22px 14px 42px; }
  .section-heading { align-items: stretch; flex-direction: column; gap: 14px; }
  .heading-actions { justify-content: stretch; }
  .heading-actions .button { flex: 1; }
  .panel { border-radius: 14px; }
  .panel-toolbar { align-items: stretch; flex-direction: column; }
  .drama-toolbar-controls { display: grid; width: 100%; justify-content: stretch; }
  .featured-filter-field { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .featured-filter-field select { width: 100%; }
  .search-field input { width: 100%; }
  .editor-panel { padding: 18px 14px; }
  .content-drawer {
    width: 100vw;
    padding: 18px 14px;
  }
  .content-drawer[data-panel="episodes"] {
    width: 100vw;
  }
  .form-grid { grid-template-columns: 1fr; }
  .system-config-group { grid-template-columns: 1fr; padding: 15px; }
  .home-ad-item { grid-template-columns: 1fr; padding: 15px; }
  .home-ad-item .file-field,
  .home-ad-preview,
  .home-ad-actions { grid-column: 1; }
  .tracking-group-options { grid-template-columns: 1fr; }
  .tracking-code-editor-heading { align-items: stretch; flex-direction: column; }
  .tracking-code-editor-heading .button { width: 100%; }
  .tracking-code-editor-heading > .tracking-code-editor-actions { width: 100%; }
  .tracking-code-editor-actions label { flex: 1 1 auto; }
  .tracking-code-editor-actions select { width: 100%; }
  .tracking-code-editor-actions .button { width: auto; }
  .tracking-code-preview-dialog { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
  .span-2 { grid-column: 1; }
  .choice-group { grid-column: 1; }
  .form-actions .button, .upload-actions .button { flex: 1; }
  .drama-item { grid-template-columns: 52px minmax(0, 1fr); }
  .drama-item img { width: 52px; height: 70px; }
  .drama-item-meta { display: none; }
  .error-banner { align-items: stretch; flex-direction: column; margin-inline: 14px; }

  .table-controls {
    min-width: 0;
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }
  .table-date-filter {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }
  .table-filter-label { grid-column: 1 / -1; }
  .table-date-filter label { align-items: stretch; flex-direction: column; }
  .table-date-filter input { width: 100%; }
  .table-filter-reset { grid-column: 1 / -1; }
  .table-pagination { justify-content: space-between; }
  .table-page-summary { width: 100%; }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table thead { display: none; }
  .episode-table { min-width: 0; table-layout: auto; }
  .data-table tbody { padding: 8px; }
  .data-table tr { margin-bottom: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
  .data-table tr:last-child { margin-bottom: 0; }
  .data-table td { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 10px; padding: 7px 4px; border: 0; text-align: left !important; }
  .data-table td::before { color: var(--text-subtle); content: attr(data-label); font-size: 11px; font-weight: 700; }
  .data-table td:last-child { align-items: center; }
  .table-action { justify-self: start; }
  .table-title, .table-subtitle { max-width: none; white-space: normal; }
  .episode-url-link, .episode-url-text, .episode-url-empty { white-space: normal; overflow-wrap: anywhere; }
  .drama-library-table { min-width: 0; }
  .drama-library-table td[data-drama-metadata-cell] { display: block; min-width: 0; max-width: none; }
  .drama-library-table td[data-drama-metadata-cell]::before { display: block; margin-bottom: 7px; }
  .drama-metadata-editor { min-width: 0; }
  .relation-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
  }
  .relation-actions::before { flex: 0 0 76px; }
  .relation-actions .button + .button { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* User commerce administration */
.commerce-panel {
  margin-bottom: 20px;
}

.commerce-panel .table-wrap {
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}

.commerce-table {
  width: 100%;
  min-width: 820px;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}

.commerce-users-table th:nth-child(1) { width: 210px; }
.commerce-users-table th:nth-child(2) { width: 190px; }
.commerce-users-table th:nth-child(3) { width: 96px; }
.commerce-users-table th:nth-child(4) { width: 160px; }
.commerce-users-table th:nth-child(5) { width: 88px; }
.commerce-users-table th:nth-child(6) { width: 184px; }
.commerce-users-table th:nth-child(7) { width: 112px; }

.commerce-orders-table {
  min-width: 1300px;
}

.commerce-orders-table th:nth-child(1) { width: 220px; }
.commerce-orders-table th:nth-child(2) { width: 170px; }
.commerce-orders-table th:nth-child(3) { width: 170px; }
.commerce-orders-table th:nth-child(4) { width: 130px; }
.commerce-orders-table th:nth-child(5) { width: 90px; }
.commerce-orders-table th:nth-child(6) { width: 112px; }
.commerce-orders-table th:nth-child(7) { width: 178px; }
.commerce-orders-table th:nth-child(8) { width: 260px; }

.commerce-products-table {
  min-width: 1320px;
}

.commerce-products-table th:first-child { width: 210px; }
.commerce-products-table th:nth-child(8) { width: 180px; }
.commerce-products-table th:last-child { width: 100px; }

.commerce-ledger-table {
  min-width: 680px;
}

.commerce-ledger-table th:nth-child(1) { width: 180px; }
.commerce-ledger-table th:nth-child(2) { width: 150px; }
.commerce-ledger-table th:nth-child(3) { width: 110px; }

.commerce-table th {
  height: 46px;
  padding-block: 10px;
  color: var(--text-muted);
  background: rgba(13, 20, 34, 0.82);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.commerce-table td {
  height: 72px;
  padding-block: 14px;
  color: var(--text-muted);
}

.commerce-table tbody tr:last-child td {
  border-bottom: 0;
}

.commerce-table tbody tr:hover {
  background: rgba(34, 46, 69, 0.7);
}

.commerce-primary {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.commerce-sub {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: var(--text-subtle);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
}

.commerce-date {
  white-space: nowrap;
}

.commerce-number {
  color: var(--text) !important;
  font-weight: 650;
  text-align: right !important;
}

.commerce-users-table th:nth-child(3),
.commerce-users-table th:nth-child(5) {
  text-align: right;
}

.commerce-products-table th:nth-child(2),
.commerce-products-table th:nth-child(3),
.commerce-products-table th:nth-child(4),
.commerce-products-table th:nth-child(5),
.commerce-products-table th:nth-child(7),
.commerce-orders-table th:nth-child(4),
.commerce-ledger-table th:nth-child(3) {
  text-align: right;
}

.commerce-action-cell {
  text-align: right !important;
}

.commerce-action-cell .button {
  min-width: 76px;
  min-height: 40px;
}

.commerce-order-no {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.commerce-link-button {
  max-width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.commerce-link-button:hover .commerce-primary,
.commerce-link-button:focus-visible .commerce-primary {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.commerce-number-link {
  color: inherit;
  font: inherit;
  text-align: right;
}

.commerce-row-focus {
  background: rgba(249, 180, 76, 0.12) !important;
  outline: 1px solid rgba(249, 180, 76, 0.42);
  outline-offset: -1px;
}

.commerce-network {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: #bfdbfe;
  background: rgba(96, 165, 250, 0.08);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
}

.status-pill.confirming {
  color: var(--info);
  background: rgba(96, 165, 250, 0.08);
}

.status-pill.paid {
  color: var(--success);
  background: rgba(52, 211, 153, 0.08);
}

.status-pill.expired,
.status-pill.cancelled {
  color: var(--text-muted);
  background: rgba(154, 168, 188, 0.08);
}

.status-pill.exception {
  color: var(--danger);
  background: var(--danger-bg);
}

.commerce-panel table input,
.commerce-panel table select {
  width: 100%;
  min-width: 88px;
  max-width: 140px;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-strong);
}

.commerce-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 8px;
}

.commerce-actions .button {
  min-width: 68px;
  min-height: 40px;
}

.commerce-empty-row td {
  height: auto;
  padding: 0 !important;
  text-align: center !important;
}

.commerce-table-empty {
  display: grid;
  min-height: 180px;
  place-content: center;
  gap: 6px;
  padding: 28px;
}

.commerce-table-empty strong {
  color: var(--text);
  font-size: 15px;
}

.commerce-table-empty span {
  color: var(--text-subtle);
  font-size: 13px;
}

.commerce-loading {
  display: flex;
  min-height: 180px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}

.commerce-detail {
  padding: 22px;
}

.commerce-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.commerce-stats > div {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-strong);
}

.commerce-stats small {
  display: block;
  color: var(--text-muted);
}

.commerce-stats strong {
  display: block;
  margin-top: 7px;
  font-size: 20px;
}

.commerce-adjustments {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.commerce-adjustments form {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.commerce-detail-section + .commerce-detail-section {
  margin-top: 24px;
}

.commerce-detail-section > h4 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.commerce-user-orders-table {
  min-width: 920px;
}

.commerce-user-orders-table th:nth-child(1) { width: 220px; }
.commerce-user-orders-table th:nth-child(2) { width: 170px; }
.commerce-user-orders-table th:nth-child(3) { width: 130px; text-align: right; }
.commerce-user-orders-table th:nth-child(4) { width: 112px; }
.commerce-user-orders-table th:nth-child(5) { width: 178px; }
.commerce-user-orders-table th:nth-child(6) { width: 112px; }

.commerce-platform {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(154, 168, 188, 0.08);
  font-size: 11px;
  font-weight: 750;
}

.commerce-platform.iphone { color: #c4b5fd; background: rgba(167, 139, 250, 0.1); }
.commerce-platform.android { color: #86efac; background: rgba(74, 222, 128, 0.1); }
.commerce-platform.pc { color: #93c5fd; background: rgba(96, 165, 250, 0.1); }
.commerce-user-agent,
.commerce-device-ua {
  display: block;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.commerce-devices-table { min-width: 980px; }
.commerce-devices-table th:nth-child(1) { width: 130px; }
.commerce-devices-table th:nth-child(2),
.commerce-devices-table th:nth-child(3) { width: 180px; }

/* Umami analytics overview */
.analytics-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 16px 18px;
}
.analytics-presets,
.analytics-custom-range {
  display: flex;
  align-items: end;
  gap: 10px;
}
.analytics-presets .active {
  border-color: rgba(246, 189, 38, 0.65);
  color: var(--primary);
  background: rgba(246, 189, 38, 0.1);
}
.compact-field { gap: 5px; }
.compact-field > span { font-size: 11px; }
.compact-field input { min-height: 38px; padding: 7px 10px; }
.analytics-loading,
.analytics-unconfigured {
  min-height: 180px;
  place-content: center;
  text-align: center;
}
.analytics-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
}
.analytics-unconfigured { display: grid; padding: 32px; }
.analytics-unconfigured h3,
.analytics-unconfigured p { margin: 0; }
.analytics-unconfigured p { margin-top: 7px; color: var(--text-muted); }
.analytics-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.analytics-stats article {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.analytics-stats small,
.analytics-stats span { display: block; color: var(--text-subtle); }
.analytics-stats small { font-size: 11px; font-weight: 750; letter-spacing: .05em; }
.analytics-stats strong { display: block; margin: 6px 0 3px; font-size: clamp(21px, 2.1vw, 30px); }
.analytics-stats span { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.analytics-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.analytics-chart-panel.span-2 { grid-column: span 2; }
.analytics-chart-panel .panel-toolbar { margin-bottom: 0; padding: 16px 18px 0; }
.analytics-chart { width: 100%; height: 340px; }
.analytics-pages-panel { margin-bottom: 20px; }
.analytics-pages-table { min-width: 760px; }
.analytics-pages-table th:first-child { width: 45%; }

.commerce-user-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, .9fr);
  gap: 18px;
  margin-bottom: 18px;
}

.commerce-user-chart-panel { min-width: 0; }
.commerce-user-chart-panel .panel-toolbar { margin-bottom: 0; padding: 16px 18px 0; }
.commerce-user-chart-panel .panel-toolbar h3,
.commerce-user-chart-panel .panel-toolbar p { margin: 0; }
.commerce-user-chart-panel .panel-toolbar p { margin-top: 4px; color: var(--text-subtle); font-size: 12px; }
.commerce-user-chart { width: 100%; height: 300px; }

@media (max-width: 1120px) {
  .analytics-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .analytics-toolbar,
  .analytics-custom-range { align-items: stretch; flex-direction: column; }
  .analytics-custom-range { width: 100%; }
  .analytics-chart-grid { grid-template-columns: 1fr; }
  .analytics-chart-panel.span-2 { grid-column: auto; }
  .analytics-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .commerce-user-chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .commerce-stats,
  .commerce-adjustments {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .commerce-table {
    min-width: 0;
    table-layout: auto;
  }

  .commerce-table td {
    height: auto;
  }

  .commerce-number,
  .commerce-action-cell {
    text-align: left !important;
  }

  .commerce-date {
    white-space: normal;
  }

  .commerce-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .commerce-empty-row {
    padding: 0 !important;
  }

  .commerce-empty-row td::before {
    content: none;
  }
}

.sync-current-progress { padding: 20px; margin-bottom: 20px; }
.sync-current-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sync-current-heading h3 { margin: 0; overflow-wrap: anywhere; }
.sync-current-item { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.sync-current-meta { color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.sync-current-progress .progress-track { margin: 12px 0; }

.duplicate-badge { margin-top: 8px; white-space: normal; text-align: left; }
.duplicate-review-dialog { width: min(900px, calc(100vw - 32px)); max-height: 85vh; overflow: auto; padding: 24px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.duplicate-review-dialog::backdrop { background: rgba(0,0,0,.65); }
.duplicate-review-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.duplicate-review-group { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 12px; }
.duplicate-review-record { background: var(--surface-raised); border-radius: 8px; padding: 12px; margin: 10px 0; overflow-wrap: anywhere; }
.duplicate-review-note { color: var(--text-muted); overflow-wrap: anywhere; }
