:root {
  --bg: #0E0E0D;
  --panel: #161614;
  --raised: #1D1D1A;
  --sunken: #121211;
  --line: #262522;
  --line-strong: #34322D;
  --text: #EFEFEB;
  --muted: #9A9791;
  --faint: #85827B;
  --accent: #C4A97D;
  --accent-hi: #D6BE96;
  --accent-ink: #14120E;
  --accent-soft: rgb(196 169 125 / .12);
  --accent-line: rgb(196 169 125 / .42);
  --scrim: rgb(6 6 5 / .62);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .35);
  --shadow: 0 2px 6px rgb(0 0 0 / .28), 0 18px 48px rgb(0 0 0 / .38);
  --st-draft: #8C8983;
  --st-ready: #7E98B8;
  --st-scheduled: #C4A97D;
  --st-publishing: #C9935A;
  --st-published: #86A580;
  --st-error: #C8695C;
  --r: 14px;
  --r-sm: 12px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --t: 200ms;
  --serif: "Cormorant Garamond", "Cormorant", Georgia, serif;
  --sans: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F2EFE8;
  --panel: #F8F6F1;
  --raised: #FFFFFF;
  --sunken: #EAE6DD;
  --line: #E0DBD0;
  --line-strong: #CFC8BA;
  --text: #1F1D1A;
  --muted: #6B665E;
  --faint: #736D63;
  --accent: #A4472B;
  --accent-hi: #B85636;
  --accent-ink: #FFFFFF;
  --accent-soft: rgb(164 71 43 / .09);
  --accent-line: rgb(164 71 43 / .38);
  --scrim: rgb(40 34 26 / .32);
  --shadow-sm: 0 1px 2px rgb(60 45 25 / .08);
  --shadow: 0 2px 6px rgb(60 45 25 / .06), 0 18px 44px rgb(60 45 25 / .13);
  --st-draft: #8D877D;
  --st-ready: #4F74A3;
  --st-scheduled: #A07E45;
  --st-publishing: #B9762F;
  --st-published: #4F8A4A;
  --st-error: #B4472F;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid var(--bg); }
.muted { color: var(--muted); }
.ico { width: 18px; height: 18px; flex: none; display: block; }
kbd { font: 500 11px/1 var(--sans); padding: 3px 5px; border-radius: 5px; border: 1px solid currentColor; opacity: .55; }
.tnum { font-variant-numeric: tabular-nums; }
/* ---------- logo ---------- */
.logo-mask {
  display: block; width: 76px; aspect-ratio: 158 / 70; background: var(--accent);
  -webkit-mask: url(/img/wt-logo-mask.png) center / contain no-repeat;
  mask: url(/img/wt-logo-mask.png) center / contain no-repeat;
}

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease), opacity var(--t);
}
.btn:hover { border-color: var(--line-strong); background: var(--raised); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.gold { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.gold:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.gold kbd { border-color: currentColor; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn.quiet:hover { background: var(--panel); color: var(--text); }
.btn.danger { color: var(--st-error); }
.btn.danger:hover { border-color: color-mix(in srgb, var(--st-error) 45%, transparent); }
.btn.block { width: 100%; height: 42px; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn { width: 36px; padding: 0; }
.icon-btn.sm { width: 30px; height: 30px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; color: var(--muted); letter-spacing: .01em; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea, select {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--sunken); color: var(--text);
  transition: border-color var(--t) var(--ease), background var(--t) var(--ease);
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
input:hover, textarea:hover, select:hover { border-color: var(--line-strong); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-line); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, textarea:disabled { opacity: .6; }
.form-error { color: var(--st-error); min-height: 1.2em; margin: 0; font-size: 13px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--sunken); border: 1px solid var(--line); }
.seg button { height: 28px; padding: 0 12px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; transition: background var(--t) var(--ease), color var(--t) var(--ease); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm); }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; justify-content: center; height: 34px; }

.pill { --st: var(--st-draft); display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--st); background: color-mix(in srgb, var(--st) 13%, transparent); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--st); }
.st-draft { --st: var(--st-draft); } .st-ready { --st: var(--st-ready); } .st-scheduled { --st: var(--st-scheduled); }
.st-publishing { --st: var(--st-publishing); } .st-published { --st: var(--st-published); } .st-error { --st: var(--st-error); }

.ava { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; display: block; background: var(--raised); }
.ava-letter { display: grid; place-items: center; font: 600 13px var(--sans); color: var(--accent); border: 1px solid var(--accent-line); }

/* ---------- sign-in ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(120% 70% at 50% 0%, var(--panel), var(--bg) 70%); }
.auth-card { width: min(380px, 100%); display: grid; gap: 16px; padding: 36px 32px 30px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-logo { width: 92px; margin: 0 auto 4px; }
.auth-card h1 { font: 500 30px/1.1 var(--serif); text-align: center; margin: 0; letter-spacing: -.01em; }
.auth-card h1 em, .bar-title h1 em, .empty h2 em, .set-sec h2 em { color: var(--accent); font-style: italic; }
.auth-card p.muted { text-align: center; margin: -6px 0 6px; font-size: 13px; }

/* ================= W&T Диск ================= */
.shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 64px; padding: 0 24px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand .logo-mask { width: 58px; }
.brand-name { font: 500 22px/1 var(--serif); padding-left: 12px; border-left: 1px solid var(--line-strong); }
.top-actions { display: flex; align-items: center; gap: 4px; }
.usage { display: grid; gap: 5px; width: 140px; white-space: nowrap; margin-right: 12px; font-size: 12px; color: var(--muted); }
.usage .bar { height: 4px; border-radius: 4px; background: var(--sunken); overflow: hidden; border: 1px solid var(--line); }
.usage .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.apps { position: relative; }
.menu { position: absolute; z-index: 60; background: var(--raised); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; }
.apps-menu { right: 0; top: 44px; display: grid; grid-template-columns: repeat(3, 96px); gap: 6px; padding: 10px; }
.app-tile { display: grid; justify-items: center; gap: 8px; padding: 14px 8px 12px; border-radius: 12px; text-decoration: none; color: var(--text); font-size: 13px; transition: background var(--t) var(--ease); }
.app-tile:hover { background: var(--panel); }
.app-tile.current { background: var(--accent-soft); }
.app-ico { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); font: 600 20px/1 var(--serif); color: var(--accent); }

.main { position: relative; flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 24px 120px; }
.head { display: grid; gap: 6px; margin-bottom: 26px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; color: var(--faint); min-height: 20px; }
.crumbs a { color: var(--muted); text-decoration: none; padding: 1px 4px; border-radius: 6px; }
.crumbs a:hover { color: var(--text); background: var(--panel); }
.crumbs span.sep { opacity: .6; }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.title { margin: 0; font: 500 40px/1.1 var(--serif); letter-spacing: -.01em; overflow-wrap: anywhere; }
.title em { font-style: italic; color: var(--accent); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.share-note { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.share-note .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st-published); }

.section-label { color: var(--faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin: 26px 0 12px; }
.section-label:first-child { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 16px; }
.card { position: relative; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; overflow: hidden; cursor: pointer;
  transition: border-color var(--t) var(--ease), transform var(--t) var(--ease), background var(--t) var(--ease); }
.card:hover { border-color: var(--line-strong); }
.card.dragging { opacity: .4; }
.card.drop-into { border-color: var(--accent); background: var(--accent-soft); }
.card .thumb { position: relative; aspect-ratio: 16 / 10; background: var(--sunken) center / cover no-repeat; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.card .thumb .ext { font: 500 24px/1 var(--serif); color: var(--faint); text-transform: uppercase; }
.card .thumb .badge { position: absolute; right: 8px; bottom: 8px; background: rgb(0 0 0 / .66); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
.card .thumb .state { position: absolute; inset: auto 8px 8px 8px; display: grid; gap: 5px; padding: 8px 10px; border-radius: 10px; background: rgb(14 14 13 / .82); color: #EFEFEB; font-size: 12px; }
.card .thumb .state .bar { height: 3px; border-radius: 3px; background: rgb(255 255 255 / .15); overflow: hidden; }
.card .thumb .state .bar i { display: block; height: 100%; background: var(--accent); transition: width 600ms var(--ease); }
.card .thumb .state.err { color: var(--st-error); }
.card .body { display: flex; align-items: flex-start; gap: 6px; padding: 10px 6px 12px 12px; }
.card .name { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .sub { color: var(--faint); font-size: 12px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.card .more { flex: none; width: 28px; height: 28px; margin-top: -3px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.card .more:hover { background: var(--raised); color: var(--text); }
.card .linked { position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 20px; background: rgb(14 14 13 / .78); color: #EFEFEB; font-size: 11.5px; }
.card .linked::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--st-published); }

.folder-card .thumb { aspect-ratio: auto; height: 96px; background: var(--sunken); }
.folder-card .thumb.has-cover { background-size: cover; background-position: center; }
.folder-card .thumb.has-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 30%, rgb(0 0 0 / .45)); }
.folder-glyph { width: 44px; height: 36px; color: var(--accent); opacity: .85; }

.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 72px 16px; border: 1px dashed var(--line-strong); border-radius: 18px; color: var(--muted); }
.empty h2 { margin: 0; font: 500 28px/1.15 var(--serif); color: var(--text); }
.empty h2 em { color: var(--accent); font-style: italic; }

.drop-hint { position: fixed; inset: 64px 0 0 0; z-index: 25; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); pointer-events: none; }
.drop-hint div { padding: 28px 40px; border: 1.5px dashed var(--accent); border-radius: 18px; background: var(--panel); font: 500 26px/1.2 var(--serif); }

.uploads { position: fixed; right: 24px; bottom: 24px; z-index: 40; width: min(380px, calc(100vw - 32px)); background: var(--raised); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.uploads-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.uploads-list { max-height: 300px; overflow: auto; }
.up { display: grid; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.up:last-child { border-bottom: 0; }
.up-row { display: flex; justify-content: space-between; gap: 10px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-pct { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.up .bar { height: 3px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.up .bar i { display: block; height: 100%; background: var(--accent); transition: width 300ms linear; }
.up.done .bar i { background: var(--st-published); }
.up.err .up-pct { color: var(--st-error); }
.up.err .bar i { background: var(--st-error); }

.ctx { min-width: 210px; display: grid; }
.ctx button { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.ctx button:hover { background: var(--panel); }
.ctx button.danger { color: var(--st-error); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.dialog { width: min(440px, calc(100vw - 32px)); max-width: none; padding: 0; margin: auto; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dialog form { display: grid; gap: 12px; padding: 26px 24px 18px; }
.dialog h3 { margin: 0; font: 500 26px/1.15 var(--serif); letter-spacing: -.01em; overflow-wrap: anywhere; }
.dialog h3 em { color: var(--accent); font-style: italic; }
.dialog p { margin: 0; color: var(--muted); line-height: 1.5; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dialog.viewer { width: min(1100px, calc(100vw - 32px)); background: #000; border-color: var(--line); }
.viewer-body { display: grid; }
.viewer-body video, .viewer-body img { display: block; width: 100%; max-height: 80vh; object-fit: contain; background: #000; }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 16px; background: var(--panel); border-top: 1px solid var(--line); }
.viewer-bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-box { display: flex; gap: 8px; }
.link-box input { font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.folder-pick { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--sunken); padding: 4px; display: grid; }
.folder-pick button { display: flex; align-items: center; gap: 8px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; cursor: pointer; padding: 0 10px; }
.folder-pick button:hover { background: var(--panel); }
.folder-pick button.on { background: var(--accent-soft); color: var(--accent); }
.folder-pick button:disabled { opacity: .4; cursor: default; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 90; transform: translate(-50%, 8px); max-width: min(420px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 12px;
  background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow); opacity: 0; transition: opacity var(--t) var(--ease), transform var(--t) var(--ease); }
.toast.in { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: color-mix(in srgb, var(--st-error) 40%, var(--line)); color: var(--st-error); }

@media (max-width: 720px) {
  .topbar { padding: 0 16px; height: 58px; }
  .brand .logo-mask { width: 48px; }
  .usage { display: none; }
  #logout-btn { display: none; }
  .main { padding: 20px 16px 120px; }
  .title { font-size: 32px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .uploads { right: 16px; bottom: 16px; }
}
a.btn { text-decoration: none; }
