/* PI-VIDEO Content Studio — the h3studio "ruby" pixel look: dark darkroom reds, square boxes, hard pixel shadows,
   8-bit bevels, Unixel (Persian pixel font) for titles and labels, film sprocket holes on the sidebar. */
@font-face { font-family: "UnixelB"; src: url("/fonts/UnixelBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "UnixelR"; src: url("/fonts/UnixelRegular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "VazirMedium"; src: url("/fonts/VazirMedium.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "VazirBold"; src: url("/fonts/VazirBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "VazirExtraBold"; src: url("/fonts/VazirExtraBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "VazirBlack"; src: url("/fonts/VazirBlack.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "LalezarAr"; src: url("/fonts/LalezarAr.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "LalezarLat"; src: url("/fonts/LalezarLat.ttf") format("truetype"); font-display: swap; }

:root {
  --bg: #0c0808; --bg-2: #110b0c; --panel: #160f10; --panel-2: #1e1416; --line: #2c1e20; --line-2: #3d2a2d;
  --ink: #dad3cf; --ink-2: #bfb6b3; --muted: #a49698; --muted-2: #978a8c;
  --accent: #a41c2a; --accent-2: #b8212f; --hot: #d43b45; --accent-text: #e5646b; --shade: #37060d;
  --gold: #ffd166; --ok: #4ade80; --warn: #facc15; --cool: #67e8f9;
  --f-ui: "VazirMedium", "VazirBold", Tahoma, sans-serif;
  --f-bold: "VazirBold", "VazirBlack", Tahoma, sans-serif;
  --f-px: "UnixelB", "VazirBlack", "LalezarLat", Tahoma, sans-serif;
  --checker: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Crect width='2' height='2' fill='%23fff' fill-opacity='.14'/%3E%3Crect x='2' y='2' width='2' height='2' fill='%23fff' fill-opacity='.14'/%3E%3C/svg%3E");
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--f-ui); font-size: 15px; line-height: 1.75; }
body { -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }
html { scrollbar-color: var(--line-2) var(--bg); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 2px solid var(--bg); }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .25; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes stripes { to { background-position: 28px 0; } }

.boot { display: flex; gap: 12px; align-items: center; justify-content: center; height: 100vh; font-family: var(--f-px); color: var(--muted); }
.boot-mark, .mark { width: 12px; height: 12px; background: var(--hot); box-shadow: 0 0 12px rgb(164 28 42 / .6); animation: blink 1.1s infinite; display: inline-block; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; width: 240px; flex: none; background: var(--bg-2); border-inline-start: 2px solid var(--line); display: flex; flex-direction: column; padding: 22px 14px; gap: 6px; z-index: 5; }
.nav::after { content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(180deg, var(--line-2) 0 6px, transparent 6px 14px) 4px 0 / 3px 100% no-repeat; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-family: var(--f-px); font-size: 22px; color: #fff; text-decoration: none; }
.brand small { display: block; font-size: 12px; color: var(--muted); font-family: var(--f-ui); }
.brand img { width: 30px; height: 30px; image-rendering: pixelated; }
.nav a.item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; color: var(--ink-2); text-decoration: none; border: 2px solid transparent; font-family: var(--f-px); font-size: 15.5px; }
.nav a.item:hover { background: var(--panel); border-color: var(--line); }
.nav a.item.active { background: var(--panel-2); border-color: var(--hot); color: #fff; box-shadow: -4px 4px 0 var(--shade); }
.nav a.item .ico { width: 26px; height: 26px; image-rendering: pixelated; flex: none; }
.nav .grow { flex: 1; }
.week { border: 2px solid var(--line-2); background: var(--panel); padding: 12px; font-size: 13px; color: var(--muted); }
.week b { font-family: var(--f-px); font-size: 22px; color: #fff; }
.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 120px; }
.dock { display: none; }
@media (max-width: 900px) {
  .nav { display: none; }
  .dock { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--bg-2); border-top: 2px solid var(--line-2); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .dock a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--f-px); font-size: 11px; color: var(--muted); text-decoration: none; padding: 4px 6px; }
  .dock a.active { color: #fff; }
  .dock a .ico { width: 24px; height: 24px; image-rendering: pixelated; }
  .main { padding: 18px 14px 110px; }
}

/* ---------------------------------------------------------------- type */
h1 { font-family: var(--f-px); font-weight: 400; font-size: 30px; color: #fff; margin: 0 0 6px; text-shadow: -2px 2px 0 var(--shade); }
h1::after { content: ''; display: inline-block; width: .42em; height: .12em; margin-inline-start: .2em; vertical-align: .06em; background: var(--hot); animation: blink 1.1s infinite; }
h2 { font-family: var(--f-px); font-weight: 400; font-size: 21px; color: #fff; margin: 0 0 12px; }
h3 { font-family: var(--f-px); font-weight: 400; font-size: 17px; color: #fff; margin: 0 0 8px; }
.lead { color: var(--muted); margin: 0 0 22px; max-width: 760px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.px { font-family: var(--f-px); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.spacer { flex: 1; }
hr { border: 0; border-top: 2px dashed var(--line); margin: 18px 0; }

/* ---------------------------------------------------------------- boxes */
.panel { background: var(--panel); border: 2px solid var(--line-2); box-shadow: -6px 6px 0 rgb(0 0 0 / .35); padding: 18px; }
.panel.tight { padding: 12px; }
.panel + .panel { margin-top: 16px; }
.win { background: var(--panel); border: 2px solid var(--line-2); box-shadow: -6px 6px 0 rgb(0 0 0 / .35); }
.win > .bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel-2); border-bottom: 2px solid var(--line-2);
  background-image: repeating-linear-gradient(180deg, rgb(218 211 207 / .07) 0 2px, transparent 2px 6px); font-family: var(--f-px); color: var(--ink-2); }
.win > .bar .lamps { display: flex; gap: 6px; margin-inline-start: auto; direction: ltr; }
.win > .bar .lamps i { width: 10px; height: 10px; display: block; }
.win > .bar .lamps i:nth-child(1) { background: var(--hot); } .win > .bar .lamps i:nth-child(2) { background: var(--gold); } .win > .bar .lamps i:nth-child(3) { background: var(--accent-text); }
.win > .body { padding: 16px; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; min-height: 42px; border: 2px solid var(--line-2); background: var(--panel-2); color: var(--ink);
  cursor: pointer; font-family: var(--f-px); font-size: 15px; text-decoration: none; white-space: nowrap; user-select: none;
  box-shadow: inset -2px -2px 0 rgb(0 0 0 / .22), inset 2px 2px 0 rgb(218 211 207 / .07); }
.btn:hover:not(:disabled) { border-color: var(--muted-2); }
.btn:active:not(:disabled) { box-shadow: inset 2px 2px 0 rgb(0 0 0 / .25); transform: translate(-1px, 1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--hot); color: #fff; box-shadow: inset -3px -3px 0 rgb(0 0 0 / .26), inset 3px 3px 0 rgb(255 255 255 / .2), -4px 4px 0 var(--shade); }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: #ff6b74; }
.btn.primary:active:not(:disabled) { transform: translate(-2px, 2px); box-shadow: inset 3px 3px 0 rgb(0 0 0 / .3), -2px 2px 0 var(--shade); }
.btn.big { min-height: 56px; font-size: 18px; padding: 10px 26px; }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.gold { background: var(--gold); color: #1a1a1a; border-color: #ffe39a; box-shadow: inset -3px -3px 0 rgb(0 0 0 / .18), -4px 4px 0 #6b4a00; }
.btn.danger:hover { border-color: var(--hot); color: var(--accent-text); }
.btn .ico { width: 20px; height: 20px; image-rendering: pixelated; }
.input, .select, .textarea { width: 100%; background: var(--bg-2); border: 2px solid var(--line-2); padding: 8px 12px; min-height: 42px; color: var(--ink);
  box-shadow: inset 2px 2px 0 rgb(0 0 0 / .25); outline: none; }
.textarea { min-height: 76px; resize: vertical; line-height: 1.8; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--hot); }
.select { appearance: none; background-image: linear-gradient(var(--accent-text), var(--accent-text)), linear-gradient(var(--accent-text), var(--accent-text)), linear-gradient(var(--accent-text), var(--accent-text));
  background-repeat: no-repeat; background-size: 10px 2px, 6px 2px, 2px 2px; background-position: left 14px top calc(50% - 3px), left 16px top calc(50% - 1px), left 18px top calc(50% + 1px); padding-inline-end: 34px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-family: var(--f-px); font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; min-height: 34px; border: 2px solid var(--line-2); background: var(--panel); cursor: pointer; font-family: var(--f-px); font-size: 13.5px; color: var(--ink-2); }
.chip.on { border-color: var(--hot); color: #fff; background-color: var(--panel-2); background-image: var(--checker); box-shadow: -3px 3px 0 var(--shade); }
.chip .n { color: var(--muted); font-size: 12px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch i { width: 46px; height: 24px; background: var(--bg-2); border: 2px solid var(--line-2); position: relative; flex: none; }
.switch i::after { content: ''; position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; background: var(--muted-2); transition: right .1s steps(2); }
.switch.on i { border-color: var(--hot); }
.switch.on i::after { right: 24px; background: var(--hot); }
.badge { display: inline-block; padding: 0 8px; font-size: 12px; font-family: var(--f-px); border: 2px solid var(--line-2); color: var(--ink-2); background: var(--bg-2); }
.badge.red { border-color: var(--hot); color: #fff; background: var(--accent); }
.badge.gold { border-color: #b98a1f; color: #1a1a1a; background: var(--gold); }
.badge.ok { border-color: #2f8f55; color: #062b14; background: var(--ok); }
.meter { height: 14px; background: var(--bg-2); border: 2px solid var(--line-2); position: relative; overflow: hidden; }
.meter i { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, #7a1420, var(--hot)); right: 0; left: auto;
  -webkit-mask-image: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px); mask-image: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px); }
.meter.run i { background-image: repeating-linear-gradient(-45deg, var(--hot) 0 7px, #7a1420 7px 14px); animation: stripes .6s linear infinite; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line-2); border-top-color: var(--hot); animation: spin .8s steps(8) infinite; display: inline-block; vertical-align: middle; }
.warn { border: 2px solid #8a6d00; background: rgb(250 204 21 / .1); color: var(--warn); padding: 10px 14px; }
.err { border: 2px solid var(--hot); background: rgb(212 59 69 / .12); color: #ffb3b8; padding: 10px 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; border: 2px dashed var(--line-2); }

/* ---------------------------------------------------------------- create page */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; padding: 22px; background: var(--panel); border: 2px solid var(--hot); box-shadow: -8px 8px 0 var(--shade); margin-bottom: 26px; position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; background-image: var(--checker); opacity: .35; pointer-events: none; }
.hero > * { position: relative; }
.hero h2 { font-size: 24px; }
.hero p { margin: 0; color: var(--ink-2); }
@media (max-width: 700px) { .hero { grid-template-columns: 1fr; } }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 2px solid var(--line-2); box-shadow: -6px 6px 0 rgb(0 0 0 / .35); padding: 16px; display: flex; flex-direction: column; gap: 8px; transition: transform .08s steps(2); }
.card:hover { border-color: var(--hot); transform: translate(2px, -2px); box-shadow: -8px 8px 0 var(--shade); }
.card .top { display: flex; align-items: center; gap: 12px; }
.card .top canvas, .card .top img { width: 44px; height: 44px; image-rendering: pixelated; flex: none; }
.card h3 { margin: 0; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; flex: 1; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 26px; align-items: start; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } .editor .pv { order: -1; } }
.pv { position: sticky; top: 16px; }
.phone { width: 100%; max-width: 360px; margin: 0 auto; background: #000; border: 10px solid #1b1213; outline: 2px solid var(--line-2); box-shadow: -8px 8px 0 rgb(0 0 0 / .45); position: relative; aspect-ratio: 9 / 16; }
.phone canvas { width: 100%; height: 100%; display: block; image-rendering: auto; }
.phone .busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; background: rgb(12 8 8 / .82); font-family: var(--f-px); color: var(--ink-2); text-align: center; padding: 20px; }
.transport { display: flex; align-items: center; gap: 8px; max-width: 360px; margin: 12px auto 0; }
.transport input[type=range] { flex: 1; accent-color: var(--hot); }
.time { font-family: var(--f-px); font-size: 13px; color: var(--muted); min-width: 78px; text-align: center; direction: ltr; }
.section { margin-bottom: 18px; }
.section > h3 { display: flex; align-items: center; gap: 8px; }
.textrow { display: flex; gap: 8px; align-items: stretch; }
.textrow .input { flex: 1; }
.clips { display: flex; gap: 10px; flex-wrap: wrap; }
.clip { width: 112px; border: 2px solid var(--line-2); background: var(--bg-2); position: relative; }
.clip img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.clip .acts { display: flex; }
.clip .acts button { flex: 1; border: 0; border-top: 2px solid var(--line-2); background: var(--panel-2); cursor: pointer; padding: 4px 0; font-family: var(--f-px); font-size: 12px; color: var(--ink-2); }
.clip .acts button + button { border-inline-start: 2px solid var(--line-2); }
.clip .acts button:hover { color: #fff; background: var(--accent); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 46px; height: 46px; border: 2px solid var(--line-2); cursor: pointer; position: relative; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); }
.sw.on { outline: 3px solid #fff; outline-offset: 2px; }
.sw span { display: block; }
.sw.auto { display: flex; align-items: center; justify-content: center; font-family: var(--f-px); font-size: 12px; background: var(--panel-2); }
.caption { white-space: pre-wrap; background: var(--bg-2); border: 2px solid var(--line-2); padding: 12px; font-size: 14px; max-height: 260px; overflow: auto; }

/* ---------------------------------------------------------------- outputs */
.outs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.out { background: var(--panel); border: 2px solid var(--line-2); box-shadow: -6px 6px 0 rgb(0 0 0 / .35); display: flex; flex-direction: column; }
.out.posted { border-color: #2f8f55; }
.out video, .out .ph { width: 100%; aspect-ratio: 9 / 16; background: #000; display: block; object-fit: cover; }
.out .ph { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: var(--muted); font-family: var(--f-px); padding: 14px; text-align: center; }
.out .info { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.out .info .t { font-family: var(--f-px); color: #fff; font-size: 15px; }
.out .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.batchhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 26px 0 12px; }
.batchhead h2 { margin: 0; }

/* ---------------------------------------------------------------- library */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.lib .it { background: var(--panel); border: 2px solid var(--line-2); position: relative; cursor: pointer; }
.lib .it:hover { border-color: var(--hot); }
.lib .it.sel { border-color: var(--gold); box-shadow: -4px 4px 0 #6b4a00; }
.lib .it .media { position: relative; aspect-ratio: 1 / 1; background: #000; overflow: hidden; }
.lib .it .media img, .lib .it .media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib .it .media .tag { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.lib .it .media .len { position: absolute; bottom: 6px; left: 6px; background: rgb(8 12 22 / .7); color: #fff; font-family: var(--f-px); font-size: 12px; padding: 0 6px; direction: ltr; }
.lib .it .p { padding: 6px 8px; font-size: 12.5px; color: var(--ink-2); height: 48px; overflow: hidden; line-height: 1.6; }
.lib .it .bot { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 6px; }
.stars { display: inline-flex; gap: 2px; direction: ltr; }
.stars button { width: 26px; height: 26px; border: 0; background: transparent; cursor: pointer; padding: 3px; }
.stars button svg { width: 100%; height: 100%; display: block; }
.rate { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
@media (max-width: 900px) { .rate { grid-template-columns: 1fr; } }
.rate video { width: 100%; max-height: 70vh; background: #000; border: 2px solid var(--line-2); display: block; }
.kbd { font-family: var(--f-px); border: 2px solid var(--line-2); padding: 0 6px; background: var(--bg-2); font-size: 12px; }
.bigstars button { width: 64px; height: 64px; }

/* ---------------------------------------------------------------- modal, toasts */
.overlay { position: fixed; inset: 0; background: rgb(0 0 0 / .72); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: min(1100px, 100%); max-height: 92vh; display: flex; flex-direction: column; background: var(--panel); border: 2px solid var(--line-2); box-shadow: -8px 8px 0 rgb(0 0 0 / .45); animation: pop .12s steps(3); }
.modal > .bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--panel-2); border-bottom: 2px solid var(--line-2); background-image: repeating-linear-gradient(180deg, rgb(218 211 207 / .07) 0 2px, transparent 2px 6px); font-family: var(--f-px); }
.modal > .body { padding: 16px; overflow: auto; }
.toasts { position: fixed; bottom: 18px; left: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: var(--panel-2); border: 2px solid var(--line-2); box-shadow: inset -4px 0 0 var(--hot), -5px 5px 0 rgb(0 0 0 / .4); padding: 10px 14px; animation: pop .12s steps(3); }
.toast.ok { box-shadow: inset -4px 0 0 var(--ok), -5px 5px 0 rgb(0 0 0 / .4); }
.toast.bad { box-shadow: inset -4px 0 0 var(--warn), -5px 5px 0 rgb(0 0 0 / .4); }
@media (max-width: 900px) { .toasts { bottom: 86px; } }

/* ---------------------------------------------------------------- guide */
.guide { max-width: 900px; }
.guide .panel h2 { margin-top: 0; }
.guide ul, .guide ol { padding-inline-start: 22px; margin: 6px 0; }
.guide li { margin: 4px 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { border: 2px solid var(--line-2); padding: 6px 10px; text-align: start; vertical-align: top; }
.tbl th { background: var(--panel-2); font-family: var(--f-px); font-weight: 400; color: #fff; }

.login { max-width: 380px; margin: 14vh auto; }
.slides { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.slides img { width: 100%; border: 2px solid var(--line-2); display: block; }

.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12vh auto 22px; color: var(--ink-2); }
.login-brand img { width: 44px; height: 44px; image-rendering: pixelated; }
.login-brand b { font-size: 26px; color: var(--ink); letter-spacing: 1px; }
.login-brand + .login { margin-top: 0; }
