:root {
  --bg: #f4f3ef;
  --card: #ffffff;
  --text: #1d1c1a;
  --muted: #7a776f;
  --line: #e6e3db;
  --hover: #f6f4ef;
  --accent: #ff6b2c;
  --accent-ink: #ffffff;
  --accent-soft: #fff0e8;
  --ok: #2f9e5b;
  --err: #d64545;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --card: #1e1d1b;
    --text: #ecebe6;
    --muted: #9a978f;
    --line: #2f2e2b;
    --hover: #262522;
    --accent-soft: #3a2418;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--muted); }
.wrap { max-width: 920px; margin: 0 auto; padding: 24px 16px 140px; }
.narrow { max-width: 520px; }
.center { text-align: center; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 22px; }
.brand a { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); position: relative; display: inline-block; }
.logo::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center/16px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4v11m-5-5 5 5 5-5M5 20h14' stroke='white' stroke-width='2.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 16px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

.form { display: grid; gap: 14px; margin-top: 18px; }
.form label { display: grid; gap: 6px; font-weight: 550; font-size: 14px; }
.form input, .form select {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit;
}
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.error { color: var(--err); margin: 0; }

.sub { margin: 2px 0 0; font-size: 14px; }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.wrap-any { word-break: break-all; }
.mine-main { display: flex; flex-direction: column; min-width: 0; }
.recent-list li.gone a { color: var(--muted); text-decoration: line-through; }
.recent-list li > .muted { white-space: nowrap; font-size: 14px; }

/* админка */
#admin { margin-top: 28px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.badge {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 650;
}
.muted-badge { background: var(--line); color: var(--muted); }
.danger-badge { background: color-mix(in srgb, var(--err) 14%, var(--card)); color: var(--err); }
.admin-head .row { flex-wrap: nowrap; }
.row.end { justify-content: flex-end; margin-top: 4px; }
.modal-bg {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { width: min(400px, 100%); margin: 0; }
.modal .search { margin: 14px 0 8px; font-size: 18px; letter-spacing: .2em; }
.modal .error { margin: 0 0 8px; font-size: 14px; }
.search {
  width: 100%; height: 42px; margin: 14px 0; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.btn.small { height: 32px; padding: 0 12px; font-size: 14px; }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: color-mix(in srgb, var(--err) 10%, var(--card)); border-color: var(--err); }
.admin-card { padding: 18px 20px; margin-bottom: 12px; }
.admin-card.gone { opacity: .6; }
.admin-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.admin-card-title { min-width: 0; }
.admin-card-title > a { font-weight: 650; font-size: 16px; text-decoration: none; word-break: break-word; }
.admin-card-title > a:hover { color: var(--accent); }
.admin-card-title p { margin: 2px 0 0; }
.author {
  display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px;
  margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px;
}
.author dt { color: var(--muted); }
.author dd { margin: 0; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.author-none { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.ext { color: var(--accent); text-decoration: none; font-size: 13px; }
.ext:hover { text-decoration: underline; }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 999px;
  padding: 1px 10px; font: inherit; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.raw { margin-top: 10px; }
.raw > summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.raw > summary:hover { color: var(--text); }
.raw .author { border-top: 0; padding-top: 4px; margin-top: 6px; }
@media (max-width: 560px) {
  .author { grid-template-columns: 1fr; gap: 0; }
  .author dt { margin-top: 6px; font-size: 12px; }
}

.recent-list { list-style: none; padding: 0; margin: 12px 0 0; }
.recent-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.recent-list a { font-weight: 550; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-list a:hover { color: var(--accent); }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff4dc; color: #6b4a00; border: 1px solid #f2d48a;
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; font-size: 14px;
}
.banner::before {
  content: "!"; flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: #e8a317; color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  .banner { background: #2e2410; color: #f2d48a; border-color: #5a4518; }
}

/* шапка дропа */
.drop-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.drop-title-wrap { min-width: 0; }
.drop-title-wrap h1 { word-break: break-word; }
.drop-head p { margin: 0; font-size: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* зона загрузки */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--card);
  padding: 34px 16px; text-align: center; margin-bottom: 16px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dz-icon { width: 44px; height: 44px; color: var(--accent); }
.dz-title { font-weight: 650; font-size: 17px; margin: 6px 0 0; }
.dropzone .muted { margin: 2px 0 16px; font-size: 14px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* дерево файлов */
.list-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.list-head .muted { font-size: 14px; }
.empty { text-align: center; padding: 26px 0 10px; margin: 0; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 22px; }
.tree summary { list-style: none; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary, .tree .file {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px;
  cursor: pointer; text-decoration: none; min-width: 0;
}
.tree summary:hover, .tree .file:hover { background: var(--hover); }
.tree .ico { flex: none; width: 20px; height: 20px; display: inline-flex; }
.tree .ico svg, .pitem .ico svg { width: 100%; height: 100%; fill: var(--line); stroke: var(--muted); stroke-width: 1.5; stroke-linejoin: round; }
.tree .ico.folder svg { fill: #ffc56b; stroke: #e0a03a; }
.tree details[open] > summary .ico.folder svg { fill: #ffd894; }
.tree .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree summary .name { font-weight: 550; }
.tree .meta { color: var(--muted); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tree .dl { flex: none; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; color: var(--muted); }
.tree .dl svg { width: 18px; height: 18px; }
.tree .dl:hover, .tree .file:hover .dl { color: var(--accent); }
.tree a.dl:hover { background: var(--accent-soft); }

/* оверлей перетаскивания */
#overlay {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  display: flex; align-items: center; justify-content: center;
  border: 3px dashed var(--accent);
}
.overlay-box { background: var(--accent); color: #fff; font-weight: 650; font-size: 18px; padding: 14px 22px; border-radius: 12px; box-shadow: var(--shadow); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
}

/* панель загрузок */
#panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 40;
  width: min(400px, calc(100vw - 32px));
  background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0,0,0,.18);
  border: 1px solid var(--line); display: flex; flex-direction: column; max-height: min(520px, 70vh);
}
.panel-head { display: flex; align-items: center; gap: 4px; padding: 12px 10px 4px 16px; }
.panel-title { flex: 1; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.small svg { width: 16px; height: 16px; }
#panel-toggle svg { transition: transform .2s; }
#panel.collapsed #panel-toggle svg { transform: rotate(180deg); }
#panel.collapsed .panel-list { display: none; }
.panel-progress { padding: 4px 16px 12px; border-bottom: 1px solid var(--line); }
#panel.collapsed .panel-progress { border-bottom: 0; }
.bar, .pbar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i, .pbar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .25s linear; }
#panel.has-errors .bar i { background: linear-gradient(90deg, var(--accent), var(--err)); }
.panel-stats { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-actions { display: flex; gap: 12px; white-space: nowrap; }
.panel-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
.pitem { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 16px; }
.pitem .ico { width: 22px; height: 22px; flex: none; }
.pbody { flex: 1; min-width: 0; }
.pname { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdir { color: var(--muted); }
.pbar { height: 4px; margin: 5px 0 3px; }
.pstatus { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pitem[data-status="done"] .pbar i { background: var(--ok); }
.pitem[data-status="done"] .pstatus { color: var(--ok); }
.pitem[data-status="error"] .pbar i { background: var(--err); }
.pitem[data-status="error"] .pstatus { color: var(--err); }
.pitem[data-status="canceled"] { opacity: .55; }
.pitem[data-status="queued"] .pbar i { width: 0 !important; }

@media (max-width: 560px) {
  h1 { font-size: 22px; }
  .actions, .actions .btn { width: 100%; }
  .actions .btn { flex: 1; }
  #panel { right: 16px; bottom: 16px; }
  .tree .tree { padding-left: 14px; }
}
