/* ─── Студия · архитектурный крафт ───────────────────────────────────────────
   Крафт-бумага, чертёжная сетка, тонкие линии-рейсшины, кнопки «высокой
   печати» (смещённая тень = оттиск), моноширинные подписи как на чертеже. */

:root {
  --paper: #ECE3D2;
  --paper-2: #F5EFE3;
  --kraft: #CDB792;
  --kraft-deep: #A88F67;
  --ink: #221E1A;
  --ink-2: #4F4840;
  --ink-3: #807666;
  --rule: #B5A586;
  --grid: rgba(34, 30, 26, .055);
  --accent: #C4572E;
  --accent-ink: #FFF6EC;
  --ok: #5E6B3A;
  --warn: #B98320;
  --bad: #A23B24;
  --shadow: #221E1A;
  --radius: 4px;
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #1F1C19;
  --paper-2: #292521;
  --kraft: #4A4033;
  --kraft-deep: #6B5B45;
  --ink: #EFE6D6;
  --ink-2: #CDBFA8;
  --ink-3: #978A76;
  --rule: #4D453A;
  --grid: rgba(239, 230, 214, .045);
  --accent: #E07448;
  --accent-ink: #1F1C19;
  --ok: #9CAB6A;
  --warn: #D9A441;
  --bad: #E0694E;
  --shadow: #0D0B0A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font-sans);
  /* бумажное волокно + чертёжная сетка */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .13 0 0 0 0 .11 0 0 0 0 .09 0 0 0 .09 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>"),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 160px 160px, 24px 24px, 24px 24px;
  min-height: 100vh;
  overflow-x: hidden;
}

.mono { font-family: var(--font-mono); }
.sheet { max-width: 640px; margin: 0 auto; padding: 14px 16px calc(96px + var(--safe-b)); }

/* ── Шапка ── */
.masthead {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 6px 0 14px; border-bottom: 2px solid var(--ink); margin-bottom: 18px;
  position: relative;
}
.masthead::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; border-bottom: 1px solid var(--rule); }
.masthead__mark { color: var(--ink); display: grid; place-items: center; }
.masthead__kicker { font: 500 10px/1 var(--font-mono); letter-spacing: .18em; color: var(--ink-3); }
.masthead__title { margin: 4px 0 0; font: 700 26px/1 var(--font-cond); text-transform: uppercase; letter-spacing: .02em; }
.masthead__meta { font-size: 11px; color: var(--ink-3); text-align: right; }

/* ── Секции «как лист чертежа» ── */
.section { margin: 0 0 22px; }
.section__head {
  display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px;
  font: 600 13px/1 var(--font-cond); text-transform: uppercase; letter-spacing: .12em;
}
.section__num { font: 500 11px/1 var(--font-mono); color: var(--accent); letter-spacing: .05em; }
.section__head::after { content: ""; flex: 1; border-bottom: 1px dashed var(--rule); transform: translateY(-3px); }
.section__hint { margin: -4px 0 10px; color: var(--ink-3); font-size: 13px; }

.card {
  position: relative; background: var(--paper-2); border: 1px solid var(--ink);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  box-shadow: 0 1px 0 var(--rule), inset 0 0 0 3px var(--paper-2), inset 0 0 0 4px rgba(34,30,26,.06);
}
/* метки обреза по углам */
.card::before, .card::after {
  content: ""; position: absolute; width: 9px; height: 9px; border-color: var(--accent); border-style: solid; pointer-events: none;
}
.card::before { top: -5px; left: -5px; border-width: 1.5px 0 0 1.5px; }
.card::after { bottom: -5px; right: -5px; border-width: 0 1.5px 1.5px 0; }
.card--flat { box-shadow: none; }
.card__title { font: 600 16px/1.25 var(--font-cond); margin: 0 0 4px; }
.card__meta { font: 400 11.5px/1.4 var(--font-mono); color: var(--ink-3); }
.card__body { margin-top: 8px; color: var(--ink-2); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ── Кнопки высокой печати ── */
.btn {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 13px/1 var(--font-cond); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink); background: var(--paper-2);
  border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 11px 14px; min-height: 42px; white-space: nowrap;
  box-shadow: 0 3px 0 var(--shadow);
  transition: transform .06s ease, box-shadow .06s ease, background .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--shadow); }
.btn:disabled { opacity: .45; cursor: default; }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; box-shadow: none; border-style: dashed; }
.btn--ghost:active { transform: none; background: var(--kraft); }
.btn--danger { color: var(--bad); }
.btn--sm { padding: 7px 10px; min-height: 32px; font-size: 11.5px; box-shadow: 0 2px 0 var(--shadow); }
.btn--block { width: 100%; }

/* ── Плитки действий ── */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  -webkit-appearance: none; appearance: none; text-align: left; cursor: pointer; color: var(--ink);
  background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: var(--radius);
  padding: 12px 10px 10px; min-height: 108px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 4px 0 var(--shadow); transition: transform .06s, box-shadow .06s;
  -webkit-tap-highlight-color: transparent;
}
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--shadow); }
.tile__ico { width: 28px; height: 28px; stroke: var(--ink); fill: none; stroke-width: 1.6; }
.tile__ico .fill { fill: var(--accent); stroke: none; }
.tile__label { font: 700 14px/1.1 var(--font-cond); text-transform: uppercase; letter-spacing: .03em; }
.tile__sub { font: 400 10.5px/1.3 var(--font-mono); color: var(--ink-3); margin-top: 3px; }
.tile--accent { background: var(--accent); color: var(--accent-ink); }
.tile--accent .tile__ico { stroke: var(--accent-ink); }
.tile--accent .tile__ico .fill { fill: var(--accent-ink); }
.tile--accent .tile__sub { color: var(--accent-ink); opacity: .8; }

/* ── Ряды настроек ── */
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row__label { font-weight: 500; }
.row__sub { display: block; font: 400 11.5px/1.35 var(--font-mono); color: var(--ink-3); margin-top: 2px; }
.stack { display: grid; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.stack:last-child { border-bottom: 0; }

/* тумблер-рокер */
.switch { position: relative; flex: none; width: 52px; height: 30px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 2; }
.switch__track {
  position: absolute; inset: 0; border: 1.5px solid var(--ink); border-radius: 3px; background: var(--kraft);
  box-shadow: inset 0 2px 0 rgba(0,0,0,.12); transition: background .15s;
}
.switch__knob {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 21px; background: var(--paper-2);
  border: 1.5px solid var(--ink); border-radius: 2px; box-shadow: 0 2px 0 var(--shadow);
  transition: transform .16s cubic-bezier(.3,.7,.4,1);
}
.switch__knob::after { content: ""; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 1px; background: var(--ink-3); box-shadow: -3px 0 0 var(--ink-3), 3px 0 0 var(--ink-3); }
.switch input:checked ~ .switch__track { background: var(--accent); }
.switch input:checked ~ .switch__knob { transform: translateX(22px); }
.switch input:focus-visible ~ .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* сегментный переключатель */
.seg { display: flex; border: 1.5px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: var(--kraft); }
.seg button {
  -webkit-appearance: none; appearance: none; flex: 1; border: 0; background: transparent; color: var(--ink);
  font: 600 12px/1 var(--font-cond); text-transform: uppercase; letter-spacing: .05em; padding: 10px 6px; cursor: pointer;
  border-right: 1px solid var(--ink); min-height: 38px;
}
.seg button:last-child { border-right: 0; }
.seg button.is-on { background: var(--paper-2); box-shadow: inset 0 -3px 0 var(--accent); }

/* палитра пресетов */
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatch {
  -webkit-appearance: none; appearance: none; cursor: pointer; border: 1.5px solid var(--ink); border-radius: var(--radius);
  background: #2a2520; padding: 8px 4px 6px; display: grid; gap: 4px; justify-items: center; color: #fff;
  box-shadow: 0 2px 0 var(--shadow);
}
.swatch.is-on { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch__dots { display: flex; gap: 3px; }
.swatch__dots i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255,255,255,.4); }
.swatch__name { font: 500 9.5px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .06em; color: #e9e1d2; }

.color-row { display: flex; gap: 10px; }
.color-field { flex: 1; display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 6px 8px; background: var(--paper-2); }
.color-field input[type=color] { width: 34px; height: 28px; border: 1px solid var(--ink); padding: 0; background: none; border-radius: 2px; }
.color-field span { font: 500 12px var(--font-mono); }

/* превью кадра 9:16 */
.preview-wrap { display: flex; gap: 14px; align-items: flex-start; }
.frame {
  position: relative; flex: none; width: 132px; aspect-ratio: 9/16; border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden;
  background: linear-gradient(160deg, #6b5b48, #2c2620 60%, #1b1714); box-shadow: 0 4px 0 var(--shadow);
}
.frame__hook { position: absolute; left: 8%; top: 14%; font: 700 15px/1 Oswald, sans-serif; text-transform: uppercase; }
.frame__hook small { display: block; font-size: 8px; margin-bottom: 2px; }
.frame__subs { position: absolute; left: 8%; font-family: Oswald, sans-serif; line-height: .98; text-transform: none; }
.frame__subs b { display: block; font-weight: 700; }
.frame__subs span { display: block; font-weight: 400; }
.frame__logo { position: absolute; width: 22%; aspect-ratio: 1; border: 1px dashed rgba(255,255,255,.55); display: grid; place-items: center; font: 600 7px var(--font-mono); color: rgba(255,255,255,.7); background-size: contain; background-repeat: no-repeat; background-position: center; }
.frame__card { position: absolute; left: 7%; right: 7%; top: 6%; height: 11%; background: rgba(240,232,216,.92); border: 1px solid #221e1a; border-radius: 3px; border-left: 4px solid var(--accent); }
.preview-notes { font: 400 11.5px/1.5 var(--font-mono); color: var(--ink-3); }

/* позиция логотипа: сетка 2×2 */
.pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 92px; aspect-ratio: 9/12; border: 1.5px solid var(--ink); padding: 6px; border-radius: var(--radius); background: var(--kraft); }
.pos-grid button { -webkit-appearance: none; appearance: none; border: 1px dashed var(--ink-2); background: transparent; border-radius: 2px; cursor: pointer; }
.pos-grid button.is-on { background: var(--accent); border-style: solid; }

/* загрузка ассетов */
.asset { display: flex; gap: 12px; align-items: center; }
.asset__thumb { width: 56px; height: 56px; flex: none; border: 1.5px dashed var(--ink-2); border-radius: var(--radius); display: grid; place-items: center; background: var(--kraft) center/contain no-repeat; font: 500 10px var(--font-mono); color: var(--ink-2); }
.asset__thumb.has { border-style: solid; background-color: var(--paper-2); }
.asset__info { flex: 1; min-width: 0; }
.asset input[type=file] { display: none; }

/* загрузка клипов */
.upfile { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--rule); }
.upfile__n { font-size: 12px; color: var(--accent); font-weight: 600; }
.upfile__name { min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.upfile__act { display: flex; gap: 6px; }
.upbar { display: block; height: 6px; margin-top: 6px; border: 1px solid var(--ink); border-radius: 1px; background: var(--kraft); overflow: hidden; }
.upbar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* поля ввода */
.input, .textarea, select.input {
  width: 100%; font: 400 15px/1.4 var(--font-sans); color: var(--ink); background: var(--paper-2);
  border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 10px 12px; box-shadow: inset 0 2px 0 rgba(0,0,0,.06);
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.label { font: 500 11px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-bottom: 6px; display: block; }
.field { margin-bottom: 10px; }

/* чипы и статусы */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font: 500 10.5px/1 var(--font-mono); padding: 5px 7px; border: 1px solid var(--ink-2); border-radius: 2px; color: var(--ink-2); background: transparent; }
.chip--accent { border-color: var(--accent); color: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 6px; font: 600 10.5px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status--processing { color: var(--warn); }
.status--processing::before { animation: pulse 1.2s infinite; }
.status--waiting { color: var(--ink-3); }
.status--done, .status--ready { color: var(--ok); }
.status--error { color: var(--bad); }
@keyframes pulse { 50% { opacity: .25; } }

/* ── Запись голоса ── */
.recorder { display: grid; justify-items: center; gap: 10px; padding: 18px 0 8px; }
.rec-btn {
  -webkit-appearance: none; appearance: none; cursor: pointer; width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid var(--ink); background: radial-gradient(circle at 35% 30%, #e07a51, var(--accent) 55%, #9b4122);
  box-shadow: 0 6px 0 var(--shadow), inset 0 -4px 0 rgba(0,0,0,.18), inset 0 3px 0 rgba(255,255,255,.25);
  display: grid; place-items: center; transition: transform .07s, box-shadow .07s;
}
.rec-btn svg { width: 34px; height: 34px; fill: none; stroke: #fff6ec; stroke-width: 2; }
.rec-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--shadow), inset 0 -2px 0 rgba(0,0,0,.18); }
.rec-btn.is-rec { animation: recpulse 1.4s infinite; }
@keyframes recpulse { 50% { box-shadow: 0 6px 0 var(--shadow), 0 0 0 10px rgba(196,87,46,.18); } }
.rec-time { font: 600 22px/1 var(--font-mono); letter-spacing: .05em; }
.rec-hint { font: 400 12px var(--font-mono); color: var(--ink-3); text-align: center; }

/* ── Метры сервера (VU-шкала) ── */
.meter { margin: 6px 0 14px; }
.meter__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.meter__name { font: 600 13px/1 var(--font-cond); text-transform: uppercase; letter-spacing: .08em; }
.meter__val { font: 600 13px/1 var(--font-mono); }
.meter__bar { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; height: 18px; padding: 3px; border: 1.5px solid var(--ink); border-radius: 2px; background: var(--kraft); box-shadow: inset 0 2px 0 rgba(0,0,0,.1); }
.meter__bar i { background: rgba(34,30,26,.12); border-radius: 1px; }
.meter__bar i.on { background: var(--ok); }
.meter__bar i.on.w { background: var(--warn); }
.meter__bar i.on.b { background: var(--bad); }
.meter__sub { font: 400 11px var(--font-mono); color: var(--ink-3); margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--paper-2); }
.stat { padding: 10px 8px; border-right: 1px solid var(--rule); }
.stat:last-child { border-right: 0; }
.stat__v { font: 600 18px/1 var(--font-mono); }
.stat__k { font: 500 9.5px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-top: 5px; }

.jobs { width: 100%; border-collapse: collapse; font: 400 12px var(--font-mono); }
.jobs td { padding: 9px 4px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.jobs td:last-child { text-align: right; }
.jobs tr:last-child td { border-bottom: 0; }

/* календарь — лента дат */
.cal-day { display: grid; grid-template-columns: 58px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.cal-day__date { border: 1.5px solid var(--ink); border-radius: var(--radius); text-align: center; background: var(--paper-2); padding: 5px 0 6px; box-shadow: 0 2px 0 var(--shadow); align-self: start; }
.cal-day__d { font: 700 20px/1 var(--font-cond); }
.cal-day__m { font: 500 9.5px/1 var(--font-mono); text-transform: uppercase; color: var(--accent); margin-top: 3px; }
.cal-ev { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0 6px; }
.cal-ev__t { font-weight: 500; }

.empty { text-align: center; padding: 26px 12px; color: var(--ink-3); font: 400 13px var(--font-mono); border: 1.5px dashed var(--rule); border-radius: var(--radius); }
.note { font: 400 12px/1.5 var(--font-mono); color: var(--ink-3); border-left: 3px solid var(--accent); padding: 6px 0 6px 10px; margin: 8px 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mt { margin-top: 12px; }

/* ── Нижняя панель ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper-2); border-top: 2px solid var(--ink); padding: 6px 6px calc(6px + var(--safe-b));
  box-shadow: 0 -1px 0 var(--rule), 0 -6px 0 -4px var(--rule);
}
.tabbar button {
  -webkit-appearance: none; appearance: none; background: none; border: 0; color: var(--ink-3); cursor: pointer;
  display: grid; justify-items: center; gap: 3px; padding: 6px 2px; border-radius: var(--radius);
  font: 600 10px/1 var(--font-cond); text-transform: uppercase; letter-spacing: .07em;
  -webkit-tap-highlight-color: transparent;
}
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.tabbar button.is-active { color: var(--ink); background: var(--kraft); box-shadow: inset 0 2px 0 rgba(0,0,0,.12); }
.tabbar button.is-active svg { stroke: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); font: 500 12.5px var(--font-mono); padding: 10px 14px; border-radius: var(--radius);
  max-width: calc(100% - 32px); transition: .2s; z-index: 20; box-shadow: 0 3px 0 var(--accent);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles .tile:first-child { grid-column: span 2; min-height: 84px; }
  .swatches { grid-template-columns: repeat(3, 1fr); }
  .preview-wrap { flex-direction: column; }
}
