/* ستوري VERTEX — clean clinical white, deep black type, one accent per state. */
:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --ink: #111111;
  --ink-2: #4a4744;
  --ink-3: #8a857f;
  --line: #e7e2da;
  --line-2: #d9d3c9;
  --dark: #111111;
  --dark-2: #1d1c1b;
  --on-dark: #f4f1ec;
  --on-dark-2: #a9a49d;
  --amber: #e8b65a;
  --mint: #bfe3d6;
  --ice: #d6eaf5;
  --ok: #1f8a5b;
  --ok-bg: #e3f3eb;
  --warn: #a8670f;
  --warn-bg: #fbf0dc;
  --bad: #c43d3d;
  --bad-bg: #fbe7e5;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 8px 24px -12px rgba(17, 17, 17, .12);
  --font: "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------------------------------------------------------------- brand */
.brand { display: inline-flex; align-items: baseline; gap: 8px; background: none; border: 0; padding: 0; }
.wordmark { font-family: "Arial Black", "Helvetica Neue", Arial, sans-serif; font-weight: 900; font-style: italic; letter-spacing: -.02em; font-size: 22px; line-height: 1; direction: ltr; }
.brand-sub { font-weight: 500; font-size: 15px; color: var(--ink-2); }
.brand-lg .wordmark { font-size: 34px; }
.brand-lg .brand-sub { font-size: 18px; }

/* ---------------------------------------------------------------- layout */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.top-end { display: flex; align-items: center; gap: 8px; min-width: 0; }
.view { max-width: 640px; margin: 0 auto; padding: 4px 16px calc(96px + var(--safe-b)); }
.loading { display: grid; place-items: center; min-height: 50vh; }

.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 180px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 6px 4px; border-radius: 12px; color: var(--ink-3); font-size: 12px; font-weight: 500;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--ink); }
.tab.active svg { stroke-width: 2.2; }

/* ---------------------------------------------------------------- pieces */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); font-weight: 500; font-size: 15px; white-space: nowrap;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-dark); }
.btn-light { background: var(--on-dark); border-color: var(--on-dark); color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost-dark { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.14); color: var(--on-dark); }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }
.btn svg, .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-btn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); flex: none; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.chip-warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.chip-bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.chip-dark { background: rgba(255,255,255,.1); border-color: transparent; color: var(--on-dark); }
.account-chip { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; direction: ltr; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 28px 2px 12px; }
.section-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.section-head .muted { font-size: 13px; }
.muted { color: var(--ink-3); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(-22px); }
.switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.hero .switch span { background: rgba(255,255,255,.2); }
.hero .switch input:checked + span { background: #34c27f; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--ink); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- hero (today) */
.hero {
  position: relative; overflow: hidden;
  background: var(--dark); color: var(--on-dark); border-radius: 24px; padding: 20px;
  box-shadow: 0 18px 40px -22px rgba(17,17,17,.6);
}
.hero::before {
  content: ""; position: absolute; width: 240px; height: 240px; inset-inline-end: -80px; top: -110px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.08);
  background: radial-gradient(circle at 50% 50%, rgba(232,182,90,.12), transparent 65%);
}
.hero-top { position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero-kicker { font-size: 12px; letter-spacing: .08em; color: var(--on-dark-2); font-family: ui-monospace, "SF Mono", Menlo, monospace; direction: ltr; text-align: right; }
.hero-title { margin: 6px 0 2px; font-size: 24px; font-weight: 600; line-height: 1.3; }
.hero-sub { margin: 0; color: var(--on-dark-2); font-size: 14px; }
.hero-count { position: relative; display: flex; align-items: baseline; gap: 6px; margin: 18px 0 10px; }
.hero-count b { font-size: 44px; font-weight: 600; line-height: 1; }
.hero-count span { color: var(--on-dark-2); }
.bar { position: relative; height: 8px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .b-ok { background: #34c27f; }
.bar .b-bad { background: #ef6b6b; }
.bar .b-run { background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.hero-steps { display: flex; gap: 6px; margin-top: 16px; }
.hero-steps i { height: 3px; flex: 1; border-radius: 3px; background: rgba(255,255,255,.14); }
.hero-steps i.on:nth-child(1) { background: var(--amber); }
.hero-steps i.on:nth-child(2) { background: var(--mint); }
.hero-steps i.on:nth-child(3) { background: var(--ice); }
.hero-actions { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.hero-toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.hero-note { position: relative; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.07); font-size: 13.5px; color: var(--on-dark); }

/* ---------------------------------------------------------------- folders */
.folders { display: grid; gap: 10px; }
.folder {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px;
  padding: 12px; text-align: start; width: 100%; color: inherit;
}
.folder.off { opacity: .55; }
.folder-thumbs { position: relative; width: 58px; height: 76px; flex: none; }
.folder-thumbs img, .folder-thumbs .ph { position: absolute; width: 44px; height: 70px; object-fit: cover; border-radius: 9px; border: 2px solid var(--surface); background: var(--surface-2); box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.folder-thumbs > :nth-child(1) { inset-inline-start: 0; top: 0; z-index: 3; }
.folder-thumbs > :nth-child(2) { inset-inline-start: 7px; top: 3px; z-index: 2; transform: rotate(-6deg); }
.folder-thumbs > :nth-child(3) { inset-inline-start: 13px; top: 5px; z-index: 1; transform: rotate(-11deg); }
.folder-thumbs .ph { display: grid; place-items: center; color: var(--ink-3); }
.folder-name { font-weight: 600; font-size: 16px; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.folder-order { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 8px; background: var(--ink); color: var(--on-dark); font-size: 12px; font-weight: 600; }
.folder-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--ink-3); }
.chev { width: 20px; height: 20px; fill: none; stroke: var(--ink-3); stroke-width: 2; }
.drag-handle { display: none; width: 40px; height: 40px; place-items: center; color: var(--ink-3); touch-action: none; }
.drag-handle svg { width: 22px; height: 22px; fill: currentColor; }
.ordering .drag-handle { display: inline-grid; }
.ordering .folder .chev { display: none; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: 0 16px 30px -12px rgba(0,0,0,.35); }

.empty { text-align: center; padding: 36px 20px; }
.empty-art { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-2); border: 1px dashed var(--line-2); }
.empty-art svg { width: 28px; height: 28px; fill: none; stroke: var(--ink-3); stroke-width: 1.8; }
.empty h3 { margin: 0 0 4px; font-size: 16px; }
.empty p { margin: 0 0 16px; color: var(--ink-3); font-size: 14px; }

/* ---------------------------------------------------------------- folder page */
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 4px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-sub { margin: 0 0 16px; color: var(--ink-3); font-size: 14px; }
.back svg { transform: scaleX(-1); }

.drop {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; text-align: start;
  border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: var(--surface);
}
.drop.over { border-color: var(--ink); background: var(--surface-2); }
.drop-ic { width: 48px; height: 48px; border-radius: 14px; background: var(--ink); color: var(--on-dark); display: grid; place-items: center; flex: none; }
.drop-ic svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.drop b { display: block; font-size: 15px; font-weight: 600; }
.drop span { font-size: 13px; color: var(--ink-3); }

.uploads { display: grid; gap: 8px; margin-top: 10px; }
.upload-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; }
.upload-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-bar { width: 90px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; flex: none; }
.upload-bar i { display: block; height: 100%; background: var(--ink); transition: width .2s; }

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 16px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { position: relative; aspect-ratio: 9 / 16; border-radius: 14px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); padding: 0; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .badge { position: absolute; top: 6px; inset-inline-start: 6px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 8px; background: rgba(17,17,17,.82); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; backdrop-filter: blur(6px); }
.tile .kind { position: absolute; bottom: 6px; inset-inline-end: 6px; height: 22px; padding: 0 7px; border-radius: 7px; background: rgba(17,17,17,.72); color: #fff; font-size: 11px; display: flex; align-items: center; gap: 4px; direction: ltr; }
.tile .kind svg { width: 12px; height: 12px; fill: currentColor; }
.tile .veil { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 8px; font-size: 12px; font-weight: 500; }
.tile.off img { filter: grayscale(1) opacity(.45); }
.tile.off .veil { color: var(--ink-2); }
.tile.processing .veil { background: rgba(244,241,236,.85); color: var(--ink-2); gap: 6px; align-content: center; }
.tile.error { border-color: var(--bad); }
.tile.error .veil { background: rgba(251,231,229,.92); color: var(--bad); }
.grid.ordering .tile { animation: wiggle .3s ease-in-out infinite alternate; }
.grid.ordering .tile:nth-child(2n) { animation-delay: .15s; }
@keyframes wiggle { from { transform: rotate(-.8deg); } to { transform: rotate(.8deg); } }

.order-bar { position: sticky; bottom: calc(76px + var(--safe-b)); margin-top: 16px; display: flex; gap: 8px; padding: 10px; border-radius: 999px; background: var(--ink); color: var(--on-dark); align-items: center; box-shadow: var(--shadow); }
.order-bar span { flex: 1; font-size: 13.5px; padding-inline-start: 8px; }

/* ---------------------------------------------------------------- log */
.log { display: grid; gap: 8px; }
.log-row { display: grid; grid-template-columns: auto auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; }
.log-pos { width: 28px; text-align: center; font-weight: 600; color: var(--ink-3); font-size: 13px; }
.log-thumb { width: 36px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.log-text { min-width: 0; font-size: 13.5px; }
.log-text small { display: block; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { padding: 14px; text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 600; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--ink-3); }

/* ---------------------------------------------------------------- settings */
.rows { overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-label { min-width: 0; }
.row-label b { display: block; font-weight: 500; }
.row-label small { display: block; color: var(--ink-3); font-size: 13px; }
.input { height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 12px; min-width: 0; }
.input:focus { outline: 2px solid var(--ink); outline-offset: 0; border-color: transparent; }
.input-time { width: 120px; text-align: center; direction: ltr; }
.input-num { width: 90px; text-align: center; }
select.input { flex: none; min-width: 148px; padding-inline: 12px 8px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); font-size: 18px; line-height: 1; }
.stepper output { min-width: 34px; text-align: center; font-weight: 600; font-size: 17px; }
.checks { display: grid; gap: 8px; }
.check { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 12px 14px; align-items: start; }
.check-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; }
.check-ic svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.check.ok .check-ic { background: var(--ok-bg); color: var(--ok); }
.check.warn .check-ic { background: var(--warn-bg); color: var(--warn); }
.check.bad .check-ic { background: var(--bad-bg); color: var(--bad); }
.check b { font-weight: 500; }
.check p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
.ig-card { display: flex; align-items: center; gap: 14px; padding: 16px; }
.ig-avatar { width: 48px; height: 48px; border-radius: 50%; background: conic-gradient(from 210deg, #f9ce34, #ee2a7b, #6228d7, #f9ce34); display: grid; place-items: center; flex: none; }
.ig-avatar span { width: 42px; height: 42px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; }

/* ---------------------------------------------------------------- sheet */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(17,17,17,.42); animation: fade .18s ease; }
.sheet-panel {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding: 8px 20px calc(20px + var(--safe-b));
  animation: up .24s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 640px) { .sheet { align-items: center; } .sheet-panel { border-radius: 24px; padding-bottom: 20px; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 5px; background: var(--line-2); margin: 4px auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 19px; font-weight: 600; }
.sheet p.lead { margin: 0 0 16px; color: var(--ink-3); font-size: 14px; }
.sheet .actions { display: grid; gap: 8px; margin-top: 16px; }
.sheet .field { display: grid; gap: 6px; margin-bottom: 12px; font-size: 14px; color: var(--ink-2); }
.sheet .field .input { width: 100%; color: var(--ink); }
.menu { display: grid; gap: 2px; margin: 0 -8px; }
.menu button { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border: 0; background: none; border-radius: 12px; text-align: start; font-size: 15px; }
.menu button:active { background: var(--surface-2); }
.menu button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.menu .danger { color: var(--bad); }
.preview { display: grid; place-items: center; background: var(--dark); border-radius: 18px; overflow: hidden; margin-bottom: 14px; }
.preview img, .preview video { max-height: 56vh; width: auto; }
.pick-list { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.pick-list button { text-align: start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; z-index: 60; inset-inline: 0; bottom: calc(84px + var(--safe-b)); display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; max-width: 480px; padding: 12px 18px; border-radius: 14px; background: var(--ink); color: var(--on-dark); font-size: 14px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); animation: up .2s ease; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------------------------------------------------------------- sign-in */
body.auth { display: grid; place-items: center; padding: 24px 16px; min-height: 100svh; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 24px; box-shadow: var(--shadow); }
.auth-title { font-size: 17px; font-weight: 500; color: var(--ink-2); margin: 10px 0 24px; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
.auth-form input { height: 48px; border-radius: 12px; border: 1px solid var(--line-2); padding: 0 14px; font-size: 16px; background: var(--surface); }
.auth-form input:focus { outline: 2px solid var(--ink); border-color: transparent; }
.auth-error { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 14px; }
.auth-note { margin: 0 0 4px; color: var(--ink-2); font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
