/* www/app/app.css — файловый проводник, тема Nocturne
   Тема одна, тёмная: это осознанный выбор, а не упущение. Проводник серверных
   файлов живёт рядом с редактором кода, и светлый вариант ломал бы подсветку.
   Токены совпадают с макетом один в один. */

@font-face {
  font-family: 'InterVar';
  src: url('/fonts/web/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --frame:     #161826;
  --surface:   #232532;
  --surface-2: #2b2e3e;
  --track:     #3f424d;

  --fg:   #e9e9ed;
  --fg-2: rgba(233, 233, 237, 0.55);
  --fg-3: rgba(233, 233, 237, 0.38);

  --line:   rgba(233, 233, 237, 0.16);
  --line-2: #595d6c;

  --acc:       #9184d9;
  --acc-deep:  #423a6a;
  --acc-soft:  #d2cefd;
  --acc-wash:  rgba(145, 132, 217, 0.18);
  --acc-wash2: rgba(145, 132, 217, 0.10);

  --ok:       #6fbf8b;
  --warn:     #d9a84f;
  --bad:      #e0707a;
  --bad-wash: rgba(224, 112, 122, 0.14);

  --r: 8px;
  --r-s: 6px;

  --sans: 'InterVar', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'Cascadia Mono', 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --pad: 11px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--frame);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg.solid { fill: currentColor; stroke: none; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:where(button, a, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 2px;
}

/* ============ каркас ============ */

.app { height: 100%; display: flex; flex-direction: column; }
.app[hidden] { display: none; }

.hdr { display: flex; align-items: center; gap: 11px; padding: 10px var(--pad) 0; flex: none; }
.hdr-t { font-size: 17px; font-weight: 500; letter-spacing: -0.01em; margin: 0 auto 0 0; }

.ib {
  width: 32px; height: 32px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  flex: none; transition: background 120ms ease;
}
.ib:hover, .ib:active { background: rgba(233, 233, 237, 0.07); }
.ib.sm { width: 26px; height: 26px; }
.ib.bad { color: var(--bad); }
.ib:disabled { color: var(--fg-3); cursor: default; }
.ib:disabled:hover { background: none; }

/* строка бота */
.ident { display: flex; align-items: center; gap: 8px; padding: 10px var(--pad) 2px; flex: none; }
.dot { width: 7px; height: 7px; border-radius: 999px; background: var(--fg-3); flex: none; }
.dot.running { background: var(--ok); }
.dot.paused  { background: var(--warn); }
.dot.stopped { background: var(--bad); }
.ident-n { font-size: 13px; font-weight: 500; }
.ident-s { font-size: 12px; color: var(--fg-2); }
.pill {
  margin-left: auto; flex: none;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: var(--r-s);
  background: var(--acc-deep); color: #f5f4ff;
}

/* крошки */
.crumbs {
  display: flex; align-items: center; gap: 5px;
  padding: 10px var(--pad) 8px; flex: none;
  font-family: var(--mono); font-size: 12px; color: var(--fg-2);
  white-space: nowrap; overflow: hidden;
}
.crumbs .sep { color: var(--fg-3); flex: none; display: flex; }
.crumbs .c { flex: none; }
.crumbs .cur { color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumbs .ell {
  border: 1px solid var(--line); border-radius: var(--r-s);
  padding: 0 5px; line-height: 17px; flex: none; color: inherit;
}
.crumbs .ell:hover { border-color: var(--line-2); color: var(--fg); }

/* поиск */
.searchbar {
  display: flex; align-items: center; gap: 8px;
  margin: 0 var(--pad) 8px; padding: 0 9px; flex: none;
  border: 1px solid var(--line); border-radius: var(--r);
  color: var(--fg-2);
}
.searchbar input {
  flex: 1; min-width: 0; height: 36px;
  background: none; border: 0; color: var(--fg);
  font-family: var(--mono); font-size: 13px;
}
.searchbar input::placeholder { color: var(--fg-3); font-family: var(--sans); }
.searchbar input::-webkit-search-cancel-button { display: none; }

/* тулбар */
.bar { display: flex; align-items: center; gap: 6px; padding: 0 var(--pad) 9px; flex: none; }
.chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--r); flex: none;
}
.chip:hover { background: rgba(233, 233, 237, 0.07); }
.cnt { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--fg-2); }

/* ============ список ============ */

.list {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 2px var(--pad) 12px;
  display: flex; flex-direction: column; gap: 2px;
}

.grp {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--fg-3);
  padding: 12px 8px 4px;
}

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 8px; border-radius: var(--r);
  transition: background 120ms ease; text-align: left; width: 100%;
}
.row:hover { background: rgba(233, 233, 237, 0.05); }
.row.sel, .row.sel:hover { background: var(--acc-wash); }
.row.locked { cursor: default; }
.row.locked:hover { background: none; }

.thumb {
  width: 40px; height: 40px; border-radius: var(--r);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.thumb.dir  { color: var(--acc); }
.thumb.file { color: var(--fg); opacity: 0.75; }
.thumb.mut  { color: var(--fg-3); }

.check {
  width: 22px; height: 22px; border-radius: var(--r-s); flex: none;
  background: var(--acc); color: var(--frame);
  display: flex; align-items: center; justify-content: center;
}

.meta { flex: 1; min-width: 0; }
.nm {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nm.dim { color: var(--fg-2); }
.sub {
  font-size: 12px; color: var(--fg-2); margin-top: 2px;
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 4px; flex: none;
  border: 1px solid var(--line); color: var(--fg-2);
}
.tag.w { border-color: rgba(217, 168, 79, 0.4); color: var(--warn); }

/* карточки разделов */
.sec {
  display: flex; align-items: center; gap: 13px; width: 100%;
  padding: 14px 12px; border-radius: var(--r);
  border: 1px solid var(--line); text-align: left;
  transition: border-color 120ms ease, background 120ms ease;
}
.sec:hover { border-color: var(--acc); background: var(--acc-wash2); }
.sec-i {
  width: 42px; height: 42px; border-radius: var(--r); flex: none;
  background: var(--surface); color: var(--acc);
  display: flex; align-items: center; justify-content: center;
}
.sec-n { font-family: var(--mono); font-size: 14px; font-weight: 500; }
.sec-d { font-size: 12px; color: var(--fg-2); margin-top: 3px; }

/* пусто и ошибка */
.empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  padding: 40px 24px; text-align: center;
}
.empty-i { color: var(--fg-3); }
.empty-t { font-size: 14px; font-weight: 500; }
.empty-d { font-size: 12.5px; color: var(--fg-2); line-height: 1.55; max-width: 32ch; margin: 0; }

.note {
  display: flex; gap: 9px; padding: 10px 11px; margin-top: 10px;
  border-radius: var(--r); font-size: 12px; line-height: 1.55;
  border: 1px solid var(--line); color: var(--fg-2);
}
.note.w { border-color: rgba(217, 168, 79, 0.34); color: var(--warn); }
.note .ni { flex: none; margin-top: 1px; }

.skel {
  height: 58px; border-radius: var(--r);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ============ доки ============ */

.dock {
  margin: 0 var(--pad) 9px; padding: 9px 12px; flex: none;
  border-radius: var(--r); background: var(--surface);
  box-shadow: 0 0 0 1px var(--line-2), 0 6px 18px rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.dock-l { font-size: 12px; font-weight: 600; }
.dock-acts { display: flex; gap: 2px; }

.foot {
  padding: 0 var(--pad) calc(11px + var(--safe-b));
  display: flex; flex-direction: column; gap: 7px; flex: none;
}
.btn-row { display: flex; gap: 7px; }
.btn-row > * { flex: 1; }

.btn {
  height: 46px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 500;
  background: transparent; border: 1px solid var(--acc); color: var(--acc);
  transition: background 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--acc-wash2); }
.btn.fill { background: var(--acc); border-color: var(--acc); color: #161826; }
.btn.fill:hover:not(:disabled) { background: #7f71ce; }
.btn.ghost { border-color: var(--line); color: var(--fg); }
.btn.ghost:hover:not(:disabled) { background: rgba(233, 233, 237, 0.07); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: var(--bad-wash); }
.btn.sm { height: 40px; font-size: 13px; }
.btn:disabled { border-color: var(--line); color: var(--fg-3); cursor: default; }

/* ============ редактор ============ */

.editor {
  position: fixed; inset: 0; z-index: 40;
  background: var(--frame);
  display: flex; flex-direction: column;
}
.editor[hidden] { display: none; }

.ed-hd {
  display: flex; align-items: center; gap: 10px;
  padding: 9px var(--pad); border-bottom: 1px solid var(--line); flex: none;
}
.ed-meta { flex: 1; min-width: 0; }
.ed-nm { font-family: var(--mono); font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-path { font-family: var(--mono); font-size: 11px; color: var(--fg-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unsaved { width: 7px; height: 7px; border-radius: 999px; background: var(--warn); flex: none; }

.ed-area {
  flex: 1; width: 100%; resize: none;
  padding: 12px var(--pad);
  background: var(--frame); color: var(--fg);
  border: 0; outline: none;
  font-family: var(--mono); font-size: 13px; line-height: 1.7;
  tab-size: 4; white-space: pre; overflow: auto;
}

.ed-bar {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 8px var(--pad); border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--fg-2);
}
.ed-bar .sep { color: var(--fg-3); }
.ed-state { margin-left: auto; }
.ed-state.dirty { color: var(--warn); }
.ed-state.saved { color: var(--ok); }

/* ============ шит и диалог ============ */

.veil { position: fixed; inset: 0; z-index: 50; background: rgba(10, 11, 18, 0.62); }
.veil[hidden] { display: none; }

.sheet, .dlg {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--surface);
  border-top-left-radius: 14px; border-top-right-radius: 14px;
  box-shadow: 0 -1px 0 var(--line-2), 0 -14px 40px rgba(0, 0, 0, 0.6);
  padding: 8px var(--pad) calc(12px + var(--safe-b));
  animation: rise 180ms ease;
}
.sheet[hidden], .dlg[hidden] { display: none; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.grab { width: 34px; height: 3px; border-radius: 999px; background: var(--track); margin: 2px auto 8px; }

.sheet-hd { display: flex; align-items: center; gap: 12px; padding: 2px 8px 10px; }
.sheet-meta { flex: 1; min-width: 0; }
.sheet-nm { font-family: var(--mono); font-size: 13.5px; font-weight: 500; word-break: break-all; }
.sheet-sub { font-size: 12px; color: var(--fg-2); margin-top: 3px; font-variant-numeric: tabular-nums; }

.act {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 8px; border-radius: var(--r);
  font-size: 14px; text-align: left;
  transition: background 120ms ease;
}
.act:hover { background: rgba(233, 233, 237, 0.06); }
.act .k { flex: 1; }
.act.bad { color: var(--bad); }
.act.bad:hover { background: var(--bad-wash); }
.act:disabled { color: var(--fg-3); cursor: default; }
.act:disabled:hover { background: none; }
.act-i { width: 22px; display: flex; justify-content: center; flex: none; }

.divider { height: 1px; background: var(--line); margin: 6px 8px; }

.dlg { padding: 16px 14px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.dlg-hd { display: flex; align-items: flex-start; gap: 11px; }
.dlg-i { flex: none; margin-top: 1px; color: var(--bad); }
.dlg-t { font-size: 15px; font-weight: 600; }
.dlg-b { font-size: 13px; line-height: 1.6; color: var(--fg-2); margin-top: 5px; }
.dlg-b code { font-family: var(--mono); font-size: 0.92em; color: var(--fg); word-break: break-all; }

/* ============ очередь загрузки ============ */

.queue {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--surface);
  border-top-left-radius: 14px; border-top-right-radius: 14px;
  box-shadow: 0 -1px 0 var(--line-2), 0 -14px 40px rgba(0, 0, 0, 0.6);
  padding: 10px var(--pad) calc(14px + var(--safe-b));
  max-height: 70%; display: flex; flex-direction: column;
  animation: rise 180ms ease;
}
.queue[hidden] { display: none; }

.q-hd { display: flex; align-items: center; gap: 8px; padding: 0 4px 8px; flex: none; }
.q-t { font-size: 14px; font-weight: 600; margin-right: auto; }
.q-list { overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px 4px; }

.prog { display: flex; flex-direction: column; gap: 7px; }
.prog-l { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; font-variant-numeric: tabular-nums; }
.prog-l .f { font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-l .p { color: var(--fg-2); flex: none; }
.prog.err .f, .prog.err .p { color: var(--bad); }
.prog-e { font-size: 11.5px; color: var(--bad); line-height: 1.5; }

.track { height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.fillb { height: 100%; border-radius: inherit; background: var(--acc); transition: width 200ms ease; }
.fillb.ok { background: var(--ok); }
.fillb.err { background: var(--bad); }

/* ============ загрузка и тост ============ */

.boot {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--frame); padding: 24px; text-align: center;
}
.boot[hidden] { display: none; }
.boot-spin {
  width: 26px; height: 26px; border-radius: 999px;
  border: 2px solid var(--acc-deep); border-top-color: var(--acc);
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-t { font-size: 13.5px; color: var(--fg-2); line-height: 1.6; margin: 0; max-width: 34ch; }
.boot.error .boot-spin { display: none; }
.boot.error .boot-t { color: var(--bad); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + var(--safe-b)); z-index: 90;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 14px; border-radius: var(--r);
  background: var(--surface-2); color: var(--fg);
  box-shadow: 0 0 0 1px var(--line-2), 0 8px 24px rgba(0, 0, 0, 0.5);
  font-size: 13px; line-height: 1.45;
  animation: rise 160ms ease;
}
.toast[hidden] { display: none; }
.toast.bad { color: var(--bad); }
.toast.ok  { color: var(--ok); }

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