/* EpisodeFlow — styles. Fonts self-hosted (IBM Plex Sans Arabic, OFL). */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200E, U+2010-2011, U+204F, U+2E41; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(../fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --font: "Plex Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --radius: 14px; --radius-sm: 10px;
  --sidebar-w: 248px;
  --bottom-h: 64px;
  --ease: cubic-bezier(.2,.7,.2,1);
}
[data-theme="dark"] {
  --bg: #0e1220; --bg-2: #121829; --surface: #171e31; --surface-2: #1d2640; --surface-3: #242e4c;
  --border: #283150; --border-2: #323c5e;
  --text: #e8eaf4; --text-2: #c3c8dc; --muted: #8e97b3;
  --accent: #8b7cf6; --accent-2: #a99cfb; --accent-ink: #ffffff; --accent-soft: rgba(139,124,246,.16); --accent-soft-2: rgba(139,124,246,.28);
  --success: #3ecf8e; --success-soft: rgba(62,207,142,.14);
  --warning: #f5b94a; --warning-soft: rgba(245,185,74,.14);
  --danger: #f47272; --danger-soft: rgba(244,114,114,.14);
  --info: #6fb3f7; --info-soft: rgba(111,179,247,.14);
  --shadow: 0 10px 30px rgba(0,0,0,.35); --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --overlay: rgba(6,8,16,.66);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f4f5fa; --bg-2: #eceef6; --surface: #ffffff; --surface-2: #f5f6fb; --surface-3: #eceef7;
  --border: #e1e4ef; --border-2: #d3d7e6;
  --text: #1a1f33; --text-2: #3b4260; --muted: #697291;
  --accent: #6c5ce7; --accent-2: #5b4bd6; --accent-ink: #ffffff; --accent-soft: rgba(108,92,231,.10); --accent-soft-2: rgba(108,92,231,.2);
  --success: #14a36b; --success-soft: rgba(20,163,107,.11);
  --warning: #c98a0c; --warning-soft: rgba(201,138,12,.12);
  --danger: #dc4a4a; --danger-soft: rgba(220,74,74,.1);
  --info: #2f7fd1; --info-soft: rgba(47,127,209,.1);
  --shadow: 0 10px 30px rgba(30,35,70,.12); --shadow-sm: 0 2px 8px rgba(30,35,70,.08);
  --overlay: rgba(20,24,40,.45);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }
img { max-width: 100%; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 2rem; text-align: center; }

svg.i { width: 20px; height: 20px; flex: none; }
svg.i.sm { width: 16px; height: 16px; }
svg.i.lg { width: 26px; height: 26px; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* boot / loading */
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); font-weight: 500; cursor: pointer; transition: background .15s, border-color .15s, transform .08s, opacity .15s; white-space: nowrap; text-decoration: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled], .icon-btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); background: transparent; border-color: transparent; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.loading { pointer-events: none; opacity: .75; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; -webkit-tap-highlight-color: transparent; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.sm { width: 34px; height: 34px; }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-size: 13.5px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text); transition: border-color .15s, box-shadow .15s; }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.7; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input[dir="ltr"] { text-align: left; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.file-pick { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px dashed var(--border-2); border-radius: var(--radius-sm); background: var(--bg-2); }
.file-pick .preview { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.file-pick .preview img { width: 100%; height: 100%; object-fit: cover; }
.file-pick .meta { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* layout */
.layout { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }
.main { padding: 16px 14px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; animation: fadeIn .2s var(--ease); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; position: sticky; top: 0; z-index: 30; background: var(--bg); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #5b8def); display: grid; place-items: center; color: #fff; }
.bottom-nav { position: fixed; left: 0; right: 0; inset-inline: 0; bottom: 0; z-index: 40; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 500; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color .15s; }
.nav-item.active { color: var(--accent-2); }
.nav-item.active svg { filter: drop-shadow(0 0 6px var(--accent-soft-2)); }
body.route-editor .bottom-nav { display: none; }
body.route-editor .main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .topbar.mobile-only, .bottom-nav { display: none !important; }
  .sidebar { display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; padding: 20px 14px; background: var(--bg-2); border-inline-end: 1px solid var(--border); }
  .sidebar .brand { padding: 4px 8px 18px; }
  .side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
  .side-link:hover { background: var(--surface); color: var(--text); }
  .side-link.active { background: var(--accent-soft); color: var(--accent-2); }
  .sidebar .spacer { flex: 1; }
  .sidebar .user-box { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 6px; }
  .sidebar .user-email { font-size: 12.5px; color: var(--muted); padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
  .main { padding: 28px 32px 48px; width: 100%; }
  body.route-editor .main { padding-bottom: 120px; }
}

/* page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 4px 0 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 700; line-height: 1.35; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; white-space: pre-wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; margin-bottom: 8px; }
.back-link:hover { color: var(--text); }
@media (min-width: 900px) { .page-head h1 { font-size: 26px; } }

/* cards */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); animation: fadeUp .22s var(--ease); }
.card.pad { padding: 16px; }
.project-card { display: flex; flex-direction: column; overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; }
.project-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.project-cover { height: 130px; background: linear-gradient(135deg, var(--accent-soft-2), var(--info-soft)); display: grid; place-items: center; color: var(--accent-2); position: relative; }
.project-cover img { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; inset: 0; }
.project-body { padding: 14px 16px 12px; display: grid; gap: 6px; flex: 1; }
.project-body h3 { margin: 0; font-size: 17px; font-weight: 600; }
.project-body .desc { color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.project-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 10px 16px; border-top: 1px solid var(--border); }
.meta-line { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.meta-line span { display: inline-flex; align-items: center; gap: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip.in_progress { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.chip.planned { background: var(--info-soft); color: var(--info); border-color: transparent; }
.chip.high { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip.medium { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.chip.low { background: var(--surface-2); }
.chip.overdue { color: var(--danger); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: grid; justify-items: center; gap: 10px; border: 1px dashed var(--border-2); border-radius: var(--radius); background: var(--surface); }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); }
.empty h3 { margin: 0; color: var(--text); font-size: 17px; }
.empty p { margin: 0; max-width: 420px; }

/* episode list */
.ep-list { display: grid; gap: 10px; }
.ep-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 12px; align-items: start; }
.ep-num { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; background: var(--accent-soft); color: var(--accent-2); font-size: 16px; }
.ep-main { min-width: 0; display: grid; gap: 6px; }
.ep-title { font-weight: 600; font-size: 16px; color: var(--text); text-decoration: none; overflow-wrap: anywhere; display: inline-flex; gap: 6px; align-items: center; }
.ep-title:hover { color: var(--accent-2); }
.ep-actions { display: flex; flex-wrap: wrap; gap: 2px; margin-inline-start: -6px; }
.status-select { min-height: 32px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--surface-2); font-size: 13px; cursor: pointer; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { padding: 12px 14px; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12.5px; color: var(--muted); }

/* characters */
.char-card { padding: 14px; display: grid; gap: 12px; }
.char-head { display: flex; gap: 12px; align-items: center; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; overflow: hidden; flex: none; font-weight: 700; font-size: 20px; border: 2px solid var(--border-2); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-head h3 { margin: 0; font-size: 17px; }
.char-desc { color: var(--text-2); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ref-box { border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-2); overflow: hidden; }
.ref-box img { display: block; width: 100%; max-height: 220px; object-fit: contain; background: var(--bg-2); cursor: zoom-in; }
.ref-box .ref-actions { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border-top: 1px solid var(--border); }
.ref-empty { padding: 14px; font-size: 13px; color: var(--muted); text-align: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.search { position: relative; }
.search svg { position: absolute; right: 12px; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-inline-start: 40px; }

/* tasks */
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 14px; }
.tab { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--accent-soft); color: var(--accent-2); }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 12px 14px; align-items: start; }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border-2); background: transparent; display: grid; place-items: center; cursor: pointer; color: transparent; margin-top: 1px; transition: all .15s; }
.check.on { background: var(--success); border-color: var(--success); color: #fff; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task-desc { font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }

/* editor */
.editor-bar { position: sticky; top: 0; z-index: 30; margin: -16px -14px 12px; padding: 8px 10px; display: flex; align-items: center; gap: 6px; background: var(--bg); background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
@media (min-width: 900px) { .editor-bar { margin: -28px -32px 16px; padding: 10px 24px; } }
.editor-bar .title-wrap { flex: 1; min-width: 0; display: grid; }
.editor-bar .ep-name { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; padding: 0; text-align: start; cursor: pointer; color: var(--text); }
.editor-bar .ep-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.save-state.saved { color: var(--success); background: var(--success-soft); }
.save-state.saving { color: var(--info); background: var(--info-soft); }
.save-state.dirty { color: var(--warning); background: var(--warning-soft); }
.save-state.failed { color: var(--danger); background: var(--danger-soft); }
.editor-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.lock-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); margin-bottom: 12px; font-size: 14px; }
.doc { max-width: 820px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px 40px; min-height: 60vh; cursor: text; }
@media (min-width: 900px) { .doc { padding: 32px 40px 60px; } }
.tb { display: block; width: 100%; border: 0; outline: none; resize: none; overflow: hidden; background: transparent; color: var(--text); font-size: 17px; line-height: 1.95; padding: 0; margin: 0; min-height: 1.95em; white-space: pre-wrap; overflow-wrap: break-word; tab-size: 4; caret-color: var(--accent-2); }
@supports (field-sizing: content) { .tb { field-sizing: content; } }
.tb::placeholder { color: var(--muted); opacity: .8; }
.tb[readonly] { cursor: default; }
.img-block { margin: 10px 0; display: flex; justify-content: center; position: relative; }
.img-block .frame { position: relative; display: inline-block; max-width: min(100%, 480px); border-radius: 12px; overflow: hidden; border: 1px solid var(--border-2); background: var(--bg-2); cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.img-block .frame:hover, .img-block .frame:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.img-block img { display: block; max-width: 100%; width: auto; height: auto; max-height: 70vh; object-fit: contain; }
.img-block.pending .frame { min-width: 200px; min-height: 120px; display: grid; place-items: center; cursor: progress; color: var(--muted); }
.img-block.pending .frame .row { padding: 20px; }
.img-block.deleting { opacity: .45; pointer-events: none; }
.img-cap { position: absolute; left: 0; right: 0; inset-inline: 0; bottom: 0; padding: 4px 10px; font-size: 11.5px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.55)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; opacity: 0; transition: opacity .15s; }
.img-block .frame:hover .img-cap { opacity: 1; }
.editor-foot { max-width: 820px; margin: 10px auto 0; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.fab-bar { position: fixed; z-index: 35; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0; inset-inline: 0; display: flex; justify-content: space-between; gap: 10px; padding: 0 14px; pointer-events: none; }
.fab-bar > * { pointer-events: auto; }
.fab { display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 20px; border-radius: 999px; border: 0; font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: manipulation; transition: transform .1s, background .15s; }
.fab:active { transform: scale(.97); }
.fab.primary { background: var(--accent); color: #fff; }
.fab.primary:hover { background: var(--accent-2); }
.fab.secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); }
.fab[disabled] { opacity: .5; }
@media (min-width: 900px) { .fab-bar { right: var(--sidebar-w); inset-inline-start: var(--sidebar-w); padding: 0 32px; bottom: 24px; } }

/* modal / sheet */
.overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 100; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .15s; }
.modal { width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); animation: fadeUp .2s var(--ease); padding-bottom: env(safe-area-inset-bottom); }
@media (min-width: 640px) { .overlay { align-items: center; padding: 20px; } .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 6px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 8px 18px 6px; }
.modal-body p { margin: 0 0 10px; color: var(--text-2); white-space: pre-wrap; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 12px 18px 18px; flex-wrap: wrap; }
.modal-foot .btn { flex: 1; }
@media (min-width: 640px) { .modal-foot .btn { flex: none; min-width: 110px; } }
.sheet-list { display: grid; padding: 4px 8px 12px; }
.sheet-item { display: flex; align-items: center; gap: 12px; padding: 14px 12px; border-radius: 10px; border: 0; background: none; cursor: pointer; text-align: start; font-size: 15px; color: var(--text); text-decoration: none; }
.sheet-item:hover { background: var(--surface-2); }
.sheet-item.danger { color: var(--danger); }
.lightbox { position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 120; background: rgba(5,7,14,.92); display: flex; flex-direction: column; animation: fadeIn .15s; }
.lightbox-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; color: #fff; }
.lightbox-top .name { font-size: 13px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; }
.lightbox-top .icon-btn { color: #fff; }
.lightbox-top .icon-btn:hover { background: rgba(255,255,255,.12); }
.lightbox-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px 12px 20px; }
.lightbox-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }

/* toasts */
.toasts { position: fixed; z-index: 200; top: calc(12px + env(safe-area-inset-top)); left: 0; right: 0; inset-inline: 0; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 520px; width: fit-content; padding: 11px 16px; border-radius: 12px; background: var(--surface-3); color: var(--text); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 14px; animation: fadeUp .2s var(--ease); }
.toast.success svg { color: var(--success); }
.toast.error { border-color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, var(--border-2)); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--info); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .2s; }

/* auth */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(800px 400px at 80% -10%, var(--accent-soft-2), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 26px 22px; }
.auth-card .brand { justify-content: center; font-size: 22px; margin-bottom: 4px; }
.auth-card .tag { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 14px; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--accent-2); cursor: pointer; font-weight: 600; padding: 0 4px; }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; margin-bottom: 12px; }

/* settings / backup */
.section { padding: 18px; margin-bottom: 14px; }
.section h2 { margin: 0 0 4px; font-size: 17px; }
.section > p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.summary-list { display: grid; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.summary-list li { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.theme-toggle { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); }
.theme-toggle button { border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; cursor: pointer; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.theme-toggle button.active { background: var(--accent-soft); color: var(--accent-2); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
body.route-editor .topbar.mobile-only { display: none; }
.server-settings { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; text-align: center; }
.server-settings .server-box { text-align: start; margin-top: 12px; }
.server-toggle { display: inline-flex; align-items: center; gap: 6px; }
.img-failed { min-width: 160px; min-height: 90px; }
html.is-app .main { padding-top: max(16px, env(safe-area-inset-top)); }
