@font-face {
  font-family: "Vazirmatn";
  src: url("/static/Vazirmatn.ttf") format("truetype");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #070b15;
  --bg-2: #0b1222;
  --card: #101a2e;
  --card-2: #14203a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9eefb;
  --muted: #8e9bb5;
  --gold: #f0c24b;
  --gold-soft: rgba(240, 194, 75, 0.14);
  --red: #e0576a;
  --green: #35c48b;
  --blue: #5aa7ff;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(76, 108, 255, 0.16), transparent 60%),
    radial-gradient(700px 400px at 0% 0%, rgba(224, 87, 106, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.02rem; font-weight: 800; letter-spacing: -0.2px; }
h2 { font-size: 1.35rem; font-weight: 800; }
h3 { font-size: 1.08rem; font-weight: 800; }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

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

[hidden] { display: none !important; }

#app { min-height: 100vh; min-height: 100dvh; }

.container {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 20px clamp(16px, 3vw, 44px) calc(64px + var(--tg-safe-bottom, 0px));
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: calc(12px + var(--tg-safe-top, 0px));
  background: rgba(7, 11, 21, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(145deg, #f6d271, #d6a22c);
  color: #1c1605;
  font-weight: 900;
  font-size: 1.05rem;
  box-shadow: 0 8px 24px rgba(240, 194, 75, 0.28);
}

.brand-mark.large { width: 64px; height: 64px; border-radius: 20px; font-size: 1.5rem; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.brand h1 { line-height: 1.2; }
.userbox { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.84rem;
  color: var(--muted);
  direction: ltr;
  unicode-bidi: isolate;
}

/* Tabs */
.tabs {
  position: sticky;
  top: var(--topbar-h, 67px);
  z-index: 19;
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(7, 11, 21, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 700;
  transition: 0.18s ease;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.active {
  color: #211a06;
  background: linear-gradient(145deg, #f6d271, #dcab34);
  box-shadow: 0 6px 18px rgba(240, 194, 75, 0.2);
}

/* Sections */
.view { animation: fade-in 0.25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 18px;
}
.section-head p { margin-top: 4px; font-size: 0.88rem; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
.req { color: var(--gold); }
.hint { color: var(--muted); font-size: 0.76rem; margin-top: 6px; }

.card {
  background: linear-gradient(180deg, rgba(20, 32, 58, 0.9), rgba(16, 26, 46, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stack { display: flex; flex-direction: column; gap: 12px; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label { font-size: 0.84rem; font-weight: 700; color: #cfd8ea; }

input, select, textarea {
  width: 100%;
  background: rgba(5, 9, 18, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(240, 194, 75, 0.7);
  box-shadow: 0 0 0 3px rgba(240, 194, 75, 0.12);
}
input[type="file"] { padding: 9px; background: rgba(5, 9, 18, 0.42); }
input[type="file"]::file-selector-button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 0;
  border-radius: 9px;
  padding: 7px 12px;
  margin-inline-end: 10px;
  cursor: pointer;
}
input[type="file"].file-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  opacity: 0;
  border: 0;
  pointer-events: none;
}
.file-field {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(5, 9, 18, 0.42);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.file-field:hover, .file-field:focus-visible {
  border-color: rgba(240, 194, 75, 0.6);
  outline: none;
}
.file-field-btn {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 9px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
}
.file-field-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
  color: var(--muted);
}
.file-field.has-file .file-field-name { color: var(--text); }
select { cursor: pointer; }
textarea {
  min-height: 230px;
  resize: vertical;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.8;
}

.check-field { justify-content: center; }
.check { display: flex; align-items: center; gap: 9px; font-size: 0.88rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form input, .inline-form select { flex: 1 1 150px; width: auto; min-width: 120px; }
.inline-form button { flex: 0 0 auto; }

.plain-textarea {
  min-height: 96px;
  direction: rtl;
  text-align: right;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.7;
}

/* Filters */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.filter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 190px;
  min-width: 150px;
}
.filter-field > span { font-size: 0.76rem; font-weight: 700; color: var(--muted); }
.filter-field select { padding: 9px 12px; }

/* Buttons */
button { cursor: pointer; }
.primary, .secondary, .danger, .ghost {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 10px 17px;
  font-weight: 800;
  font-size: 0.88rem;
  transition: transform 0.12s ease, filter 0.16s ease, background 0.16s ease;
}
.primary {
  background: linear-gradient(145deg, #f6d271, #dcab34);
  color: #1f1805;
  box-shadow: 0 8px 24px rgba(240, 194, 75, 0.22);
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text);
}
.secondary:hover { background: rgba(255, 255, 255, 0.1); }

.danger { background: rgba(224, 87, 106, 0.16); border-color: rgba(224, 87, 106, 0.35); color: #ffb6c1; }
.danger:hover { background: rgba(224, 87, 106, 0.26); }

.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.small-btn { padding: 7px 11px; font-size: 0.78rem; }
.icon-btn { padding: 4px 10px; font-size: 1.35rem; line-height: 1; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid rgba(240, 194, 75, 0.25);
  color: #f7d98a;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.78rem; font-weight: 800; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status[data-status="queued_transcribe"], .status[data-status="queued_render"] { color: var(--muted); }
.status[data-status="transcribing"], .status[data-status="translating"], .status[data-status="rendering"] { color: var(--blue); }
.status[data-status="transcribing"]::before, .status[data-status="translating"]::before, .status[data-status="rendering"]::before { animation: pulse 1.4s infinite; }
.status[data-status="awaiting_review"] { color: var(--gold); }
.status[data-status="done"] { color: var(--green); }
.status[data-status="failed"] { color: var(--red); }
.status[data-status="cancelled"], .status[data-status="expired"] { color: #7b8499; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Preview */
.preview-wrap { margin-top: 2px; }
#cover-preview {
  display: block;
  width: 100%;
  max-width: 300px;
  border-radius: 16px;
  border: 1px solid var(--line);
  margin: 0 auto;
}
.preview-placeholder {
  display: grid;
  place-items: center;
  min-height: 150px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  color: var(--muted);
  font-size: 0.84rem;
  background: rgba(5, 9, 18, 0.32);
}

/* Progress */
.progress-line { display: flex; align-items: center; gap: 12px; }
.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #d6a22c, #f6d271);
  transition: width 0.4s ease;
}

/* Job cards */
.job-card {
  background: linear-gradient(180deg, rgba(20, 32, 58, 0.86), rgba(16, 26, 46, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.job-card:hover { border-color: rgba(240, 194, 75, 0.3); transform: translateY(-1px); }
.job-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.job-title { font-weight: 800; font-size: 0.96rem; }
.job-sub { color: var(--muted); font-size: 0.79rem; margin-top: 2px; }
.job-meta { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; color: var(--muted); font-size: 0.76rem; }
.job-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.job-progress { margin-top: 11px; display: flex; align-items: center; gap: 10px; }
.job-progress .progress-track { height: 6px; }
.job-progress span { font-size: 0.72rem; color: var(--muted); min-width: 34px; text-align: left; direction: ltr; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2, 5, 12, 0.72); backdrop-filter: blur(6px); }
.modal-card {
  position: relative;
  width: min(100%, 860px);
  max-height: 92vh;
  overflow: auto;
  background: linear-gradient(180deg, #121d33, #0d1526);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 29, 51, 0.94);
  backdrop-filter: blur(10px);
}
.modal-body { padding: 18px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.detail-item { background: rgba(5, 9, 18, 0.36); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.detail-item .label { display: block; color: var(--muted); font-size: 0.72rem; margin-bottom: 2px; }
.detail-item .value { font-size: 0.86rem; font-weight: 700; word-break: break-word; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 14px 0; }
.error-box {
  border: 1px solid rgba(224, 87, 106, 0.35);
  background: rgba(224, 87, 106, 0.1);
  color: #ffc1ca;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 0.83rem;
  margin-bottom: 14px;
  white-space: pre-wrap;
}
.timeline { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.timeline h4 { margin: 0 0 8px; font-size: 0.84rem; color: var(--muted); font-weight: 700; }
.event { display: flex; gap: 10px; font-size: 0.79rem; padding: 5px 0; }
.event .dot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; margin-top: 8px; background: var(--muted); }
.event[data-level="success"] .dot { background: var(--green); }
.event[data-level="error"] .dot { background: var(--red); }
.event[data-level="warning"] .dot { background: var(--gold); }
.event time { color: var(--muted); font-size: 0.7rem; white-space: nowrap; }

/* Tables / admin */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 640px; font-size: 0.82rem; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 0.76rem; background: rgba(5, 9, 18, 0.3); }
tr:last-child td { border-bottom: 0; }
td input { padding: 6px 9px; border-radius: 8px; max-width: 120px; }
.role-pill, .status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
}
.role-pill[data-role="super_admin"] { color: #f7d98a; border-color: rgba(240, 194, 75, 0.3); background: var(--gold-soft); }
.status-pill[data-status="active"] { color: var(--green); }
.status-pill[data-status="blocked"] { color: var(--red); }
.status-pill[data-status="pending"] { color: var(--gold); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card { background: linear-gradient(180deg, rgba(20, 32, 58, 0.9), rgba(16, 26, 46, 0.92)); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat-card .num { display: block; font-size: 1.5rem; font-weight: 900; color: var(--gold); }
.stat-card .cap { color: var(--muted); font-size: 0.76rem; }
.breakdown-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.83rem; }
.breakdown-row:last-child { border-bottom: 0; }

.empty { text-align: center; color: var(--muted); padding: 38px 16px; font-size: 0.86rem; border: 1px dashed rgba(255, 255, 255, 0.12); border-radius: 16px; }

/* Misc */
.center-screen { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.center-screen p { color: var(--muted); margin-top: 12px; }
.spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--gold); animation: spin 0.9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.denied-card { max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 32px 24px; box-shadow: var(--shadow); }
.denied-card h2 { margin: 14px 0 8px; }
.denied-card p { margin-top: 6px; }

.toast {
  position: fixed;
  z-index: 80;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #f7e3a8;
  color: #1e1705;
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.error { background: #ffc4cd; color: #3a0710; }

/* Stories */
.story-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(12px, 1.4vw, 20px);
  width: 100%;
}
.story-card {
  background: linear-gradient(180deg, rgba(20, 32, 58, 0.9), rgba(16, 26, 46, 0.94));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.story-card:hover { border-color: rgba(240, 194, 75, 0.32); transform: translateY(-2px); }
.story-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 20%, rgba(240, 194, 75, 0.18), rgba(10, 16, 30, 0.9));
  color: var(--gold);
  font-weight: 900;
  font-size: 1.5rem;
  overflow: hidden;
}
.story-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-cover.large { width: 130px; min-width: 130px; aspect-ratio: 3 / 4; border-radius: 16px; border: 1px solid var(--line); font-size: 1.1rem; }
.story-badges {
  position: absolute;
  top: 9px;
  inset-inline-start: 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: calc(100% - 18px);
}
.story-badge {
  background: rgba(7, 11, 21, 0.78);
  border: 1px solid var(--line);
  color: #f7d98a;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.7rem;
  font-weight: 700;
  backdrop-filter: blur(6px);
  white-space: nowrap;
}
.story-badge.state {
  color: #b9f4da;
  border-color: rgba(53, 196, 139, 0.35);
  background: rgba(9, 38, 30, 0.8);
}
.story-badge.state[data-status="paused"] { color: #f7d98a; border-color: rgba(240, 194, 75, 0.3); background: rgba(46, 35, 9, 0.8); }
.story-badge.state[data-status="completed"] { color: #c7d3e8; border-color: var(--line); background: rgba(7, 11, 21, 0.8); }
.story-body { padding: 12px 14px; }
.story-body .job-meta { margin-top: 7px; }
.series-cover-editor { display: flex; align-items: flex-start; gap: 14px; }
.new-cover {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(5, 9, 18, 0.3);
}
.new-cover .story-cover.large { width: 96px; min-width: 96px; }
.new-cover .story-cover img { width: 100%; height: 100%; object-fit: cover; }

/* 9:16 episode cover preview in the «افزودن ویدیو» tab */
.episode-cover {
  position: relative;
  width: 132px;
  min-width: 132px;
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 20%, rgba(240, 194, 75, 0.18), rgba(10, 16, 30, 0.9));
  color: var(--gold);
  font-weight: 900;
  font-size: 1.1rem;
  transition: opacity 0.15s ease;
}
.episode-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.episode-cover.is-loading { opacity: 0.55; }

/* Branding editor */
.branding-editor { display: flex; align-items: flex-start; gap: 16px; }
.brand-preview {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  min-width: 92px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(145deg, #f6d271, #d6a22c);
  color: #1c1605;
  font-weight: 900;
  font-size: 1.5rem;
  box-shadow: 0 10px 30px rgba(240, 194, 75, 0.24);
}
.brand-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Messages */
.message-composer textarea {
  min-height: 96px;
  direction: rtl;
  text-align: right;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.7;
}
.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
  max-height: 58vh;
  overflow-y: auto;
  padding: 4px 2px;
}
.thread-list { max-height: 46vh; }
.message-bubble {
  max-width: min(86%, 560px);
  align-self: flex-start;
  background: rgba(20, 32, 58, 0.92);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 5px;
  padding: 9px 13px;
}
.message-bubble[data-own="1"] {
  align-self: flex-end;
  background: rgba(240, 194, 75, 0.14);
  border-color: rgba(240, 194, 75, 0.28);
  border-radius: 16px 16px 5px 16px;
}
.message-author { font-size: 0.7rem; font-weight: 800; color: var(--gold); margin-bottom: 2px; }
.message-body { font-size: 0.88rem; white-space: normal; overflow-wrap: anywhere; }
.message-time { font-size: 0.66rem; color: var(--muted); margin-top: 4px; text-align: left; direction: ltr; }
.thread-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 32, 58, 0.86), rgba(16, 26, 46, 0.9));
  cursor: pointer;
  transition: border-color 0.16s ease, transform 0.16s ease;
}
.thread-row:hover { border-color: rgba(240, 194, 75, 0.32); transform: translateY(-1px); }
.thread-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 14px;
  background: rgba(240, 194, 75, 0.14);
  color: var(--gold);
  font-weight: 900;
}
.thread-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

a.primary, a.secondary { display: inline-block; text-decoration: none; }
a.primary:hover, a.secondary:hover { text-decoration: none; }
.series-episodes { border-top: 1px solid var(--line); margin-top: 18px; }
.episode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.episode-row:last-child { border-bottom: 0; }
.ep-thumb {
  width: 52px;
  height: 66px;
  flex: 0 0 auto;
  border-radius: 9px;
  overflow: hidden;
  background: rgba(240, 194, 75, 0.12);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 800;
}
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ep-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.published-tag { color: var(--green); }

/* Settings */
.secret-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.secret-row:last-child { border-bottom: 0; }
.secret-info { flex: 1 1 210px; min-width: 0; }
.secret-controls { display: flex; align-items: center; gap: 7px; flex: 1 1 280px; }
.secret-controls input { flex: 1; min-width: 120px; padding: 8px 10px; font-size: 0.82rem; }

.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 9, 18, 0.4);
  margin-bottom: 14px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: 0.82rem;
  font-weight: 700;
}
.seg button.active { background: var(--gold-soft); color: #f7d98a; }

.viewer-hero { text-align: center; padding: 38px 22px; }
.viewer-hero .brand-mark { margin: 0 auto 14px; }
.viewer-hero h2 { margin-bottom: 8px; }
.viewer-hero p { max-width: 520px; margin-inline: auto; }

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

@media (max-width: 640px) {
  .container { padding: 14px 12px 48px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-height: 94vh; border-radius: 22px 22px 0 0; width: 100%; }
  .section-head { flex-direction: column; }
  .tabs { top: var(--topbar-h, 65px); }
  .user-name { display: none; }
  h2 { font-size: 1.2rem; }
  .story-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .story-card { display: flex; align-items: stretch; }
  .story-card .story-cover {
    width: 118px;
    flex: 0 0 118px;
    aspect-ratio: 3 / 4;
  }
  .story-card .story-badges { top: 6px; inset-inline-start: 6px; gap: 4px; }
  .story-card .story-badge { font-size: 0.6rem; padding: 2px 6px; }
  .story-card .story-body { flex: 1; min-width: 0; padding: 10px 12px; }
  .series-cover-editor { flex-direction: column; }
  .episode-row { flex-wrap: wrap; }
  .ep-actions { width: 100%; justify-content: flex-start; }
  .seg { width: 100%; }
  .seg button { flex: 1; }
}

/* ------------------------------------------------- viewer watch / player */

.watch-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.watch-cover {
  width: 108px;
  flex: 0 0 108px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 20%, rgba(240, 194, 75, 0.18), rgba(10, 16, 30, 0.9));
  display: grid;
  place-items: center;
  color: var(--gold);
  font-weight: 900;
}
.watch-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.watch-info { min-width: 0; flex: 1; }
.watch-info h3 { margin: 2px 0 4px; font-size: 1.05rem; }
.watch-info p { margin: 6px 0 10px; font-size: 0.84rem; line-height: 1.9; }
.watch-en { direction: ltr; text-align: right; color: var(--muted); font-size: 0.78rem; }

.watch-episode {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(5, 9, 18, 0.42);
  color: var(--text);
  font: inherit;
  text-align: right;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.watch-episode:hover, .watch-episode:focus-visible {
  border-color: rgba(240, 194, 75, 0.55);
  background: rgba(240, 194, 75, 0.06);
  outline: none;
}
.watch-ep-number {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 800;
  font-size: 0.85rem;
}
.watch-ep-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.watch-ep-title { font-weight: 700; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-ep-sub { color: var(--muted); font-size: 0.76rem; }
.watch-ep-play { flex: 0 0 auto; color: var(--gold); font-weight: 700; font-size: 0.82rem; }

.watch-foot { display: flex; justify-content: flex-start; margin-top: 6px; }

.player-shell {
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  border: 1px solid var(--line);
}
.viewer-player {
  width: 100%;
  max-height: 58vh;
  background: #000;
  display: block;
}
.player-meta { padding: 12px 2px 4px; }

.gate-card {
  text-align: center;
  padding: 26px 16px 20px;
  border: 1px dashed rgba(240, 194, 75, 0.35);
  border-radius: 18px;
  background: rgba(240, 194, 75, 0.05);
}
.gate-lock { font-size: 1.8rem; margin-bottom: 6px; }
.gate-card h3 { margin: 0 0 8px; font-size: 1.02rem; }
.gate-card p { margin: 0 auto 16px; max-width: 380px; font-size: 0.84rem; line-height: 1.9; }
.gate-actions { justify-content: center; }

@media (max-width: 700px) {
  .watch-hero { gap: 12px; }
  .watch-cover { width: 86px; flex-basis: 86px; }
  .viewer-player { max-height: 46vh; }
}

@media (max-width: 700px) {
  .episode-cover { width: 104px; min-width: 104px; }
}

/* ------------------------------------------------------- theatre player */

.player-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  background: #000;
}
.player-screen[hidden] { display: none; }
.player-screen-video {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  background: #000;
  object-fit: contain;
}
.player-screen-close {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: 12px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.player-screen-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: #05070d;
  color: #fff;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.player-screen-title { font-weight: 700; font-size: 0.95rem; }
.player-screen-meta { margin-top: 2px; font-size: 0.78rem; color: rgba(255, 255, 255, 0.6); }
.player-screen-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 700px) {
  .player-screen-bar { flex-direction: column; align-items: stretch; }
  .player-screen-actions > * { flex: 1; }
}
