:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #6b7280;
  --border: #dde1e6;
  --accent: #d6002a;
  --accent-text: #ffffff;
  --hover: #f0f1f4;
  --ok: #16a34a;
  --off: #9ca3af;
  --error: #c0262d;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --card: #1b1e24;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #2d323b;
    --accent: #ff4d5e;
    --accent-text: #111317;
    --hover: #242830;
    --ok: #4ade80;
    --off: #6b7280;
    --error: #ff7b7b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }

.status { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--off); }
.dot.on { background: var(--ok); }

main { max-width: 880px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.narrow { max-width: 380px; margin: 48px auto; }
.notice { color: var(--muted); }

label { display: block; margin-bottom: 6px; font-size: .9rem; color: var(--muted); }

input[type=password], input[type=text], input:not([type]) {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  font: inherit;
  font-size: .95rem;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  margin: 0;
}
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.ghost { background: transparent; color: var(--muted); border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, .button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#login-form button { margin-top: 12px; width: 100%; }

.row { display: flex; gap: 8px; }
.row input { flex: 1; letter-spacing: .3em; font-variant-numeric: tabular-nums; }

.error { color: var(--error); min-height: 1.2em; margin: 8px 0 0; font-size: .9rem; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }

.crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; margin-bottom: 12px; }
.crumbs button { background: transparent; color: var(--accent); min-height: 32px; padding: 4px 6px; }
.crumbs span { color: var(--muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
#space { margin-left: auto; }

.progress-box { margin: 8px 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; }
.progress-label { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: .9rem; gap: 8px; }
.progress-label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }

.drop { border: 2px dashed transparent; border-radius: var(--radius); padding: 4px; transition: border-color .15s; }
.drop.over { border-color: var(--accent); background: var(--hover); }
.hint { margin-top: 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.list li:last-child { border-bottom: 0; }
.list li:hover { background: var(--hover); }
.name {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: transparent;
  color: var(--text);
  justify-content: flex-start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 4px;
}
.name.dir { font-weight: 600; }
a.name { text-decoration: none; display: block; line-height: 28px; }
.icon { width: 1.4em; text-align: center; flex: none; }
.size { color: var(--muted); font-size: .85rem; flex: none; min-width: 5.5em; text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 2px; flex: none; }
.actions button, .actions a {
  min-height: 34px;
  padding: 4px 8px;
  font-size: .85rem;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.actions .danger { color: var(--error); }

@media (max-width: 560px) {
  main { padding: 10px; }
  .card { padding: 12px; }
  .size { display: none; }
  .actions button, .actions a { padding: 4px 6px; }
  #space { width: 100%; margin-left: 0; }
}
