:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #1d2428;
  --muted: #68747b;
  --line: #dfe4e1;
  --accent: #176b5d;
  --accent-strong: #0c4f45;
  --danger: #a93636;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111615;
  --panel: #19211f;
  --ink: #edf4f1;
  --muted: #aab7b2;
  --line: #2d3935;
  --accent: #5ec5ad;
  --accent-strong: #8ee2cf;
  --danger: #d45d5d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
a { color: var(--accent-strong); text-decoration: none; }
h1, h2 { margin: 0 0 16px; font-weight: 700; }
input, button, select, textarea {
  font: inherit;
  border-radius: 6px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 10px 12px;
  background: var(--panel);
  color: var(--ink);
}
textarea {
  min-height: 136px;
  resize: vertical;
}
button {
  border: 0;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { background: var(--accent-strong); }
button.ghost {
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent-strong);
  white-space: nowrap;
}
button.secondary:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.theme-toggle {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}
.theme-toggle:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.danger { background: var(--danger); }
label { display: grid; gap: 8px; color: var(--muted); }
code { font-size: 12px; overflow-wrap: anywhere; }

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}
.auth-tools {
  position: fixed;
  top: 16px;
  right: 16px;
}
.stack { display: grid; gap: 16px; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  color: var(--ink);
  font-weight: 800;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.brand-face {
  color: var(--accent-strong);
  font-weight: 700;
}
.topbar nav {
  display: flex;
  gap: 18px;
  align-items: center;
}
.topbar form { margin: 0; }
.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto;
}
.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 18px;
  margin-bottom: 28px;
}
.upload-zone {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  display: grid;
  gap: 16px;
}
.compact-form {
  max-width: 520px;
  margin-bottom: 18px;
}
.check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}
.check input {
  width: auto;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 560px;
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.switch {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 10px;
  color: var(--ink);
}
.switch input {
  width: auto;
}
.drop {
  min-height: 140px;
  align-content: center;
  border: 1px dashed #aab5b0;
  border-radius: 8px;
  padding: 18px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pager a,
.pager strong,
.pager span {
  min-width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
}
.pager strong {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pager span {
  color: var(--muted);
  background: var(--bg);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}
.stat-card {
  min-height: 116px;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.stat-card-wide {
  grid-column: span 2;
}
.stat-card span,
.stat-card small {
  color: var(--muted);
}
.stat-card span {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 700;
}
.stat-card strong {
  font-size: 28px;
  line-height: 1.1;
}
.stat-card progress {
  width: 100%;
  height: 8px;
  accent-color: var(--accent);
}
.bulk-form {
  display: grid;
  gap: 10px;
}
.bulk-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bulk-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}
tr:last-child td { border-bottom: 0; }
.select-cell {
  width: 40px;
}
.select-cell input {
  width: auto;
}
.link-copy {
  min-width: 360px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.link-copy input {
  min-width: 0;
}
.preview-cell {
  width: 96px;
}
.thumb {
  width: 72px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}
.thumb img {
  width: 72px;
  height: 54px;
  max-width: 72px;
  max-height: 54px;
  object-fit: contain;
  display: block;
  background: var(--bg);
}
.error {
  color: #7a2222;
  background: #fff0f0;
  border: 1px solid #efcaca;
  padding: 10px 12px;
  border-radius: 6px;
}
.success {
  color: #155846;
  background: #eaf8f1;
  border: 1px solid #bfe8d5;
  padding: 10px 12px;
  border-radius: 6px;
}
.uploaded-links {
  display: grid;
  gap: 10px;
}
.muted { color: var(--muted); }

@media (max-width: 760px) {
  .topbar {
    height: auto;
    padding: 16px;
    align-items: flex-start;
  }
  .topbar nav {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .upload-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card-wide { grid-column: span 1; }
}
