:root {
  /* Haier brand blue, sampled from the logo. */
  --brand: #005ca9;

  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1c1f23;
  --muted: #6b7280;
  --accent: var(--brand);
  --accent-text: #ffffff;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.06);
}

/* Dark palette: applied when the system asks for it and the viewer has not
   pinned light mode, or when the viewer picks dark explicitly. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f1115;
    --panel: #171a21;
    --border: #262b34;
    --muted: #949ba6;
    --text: #e8eaed;
    --accent: #4a9eea;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme='dark'] {
  --bg: #0f1115;
  --panel: #171a21;
  --border: #262b34;
  --muted: #949ba6;
  --text: #e8eaed;
  --accent: #4a9eea;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

/* Our own `display` rules would otherwise beat the browser default for
   [hidden], leaving the login screen on top of the explorer. */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 16px;
  cursor: pointer;
  transition: filter 0.15s ease, background 0.15s ease;
}
button:hover { filter: brightness(0.95); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.primary { background: var(--accent); color: var(--accent-text); }
.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.link { background: none; border: none; color: var(--accent); padding: 4px 6px; }
.link.danger { color: var(--danger); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px;
  line-height: 0;
  display: grid;
  place-items: center;
}

/* Offer the theme you would switch TO: a moon while light, a sun while dark. */
.icon-sun { display: none; }
.icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .icon-sun { display: block; }
  :root:not([data-theme='light']) .icon-moon { display: none; }
}
:root[data-theme='dark'] .icon-sun { display: block; }
:root[data-theme='dark'] .icon-moon { display: none; }

input[type="password"],
input[type="text"] {
  font: inherit;
  width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
input:focus-visible,
button:focus-visible,
tr:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); margin: 0; font-size: 14px; }

/* ------------------------------------------------------- header / footer */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { height: 30px; width: auto; border-radius: 4px; display: block; }
.team {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 16px;
  font-size: 13px;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); text-decoration: underline; }

/* ---------------------------------------------------------------- login */

.gate {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 24px;
}
.login {
  width: 100%;
  max-width: 340px;
  padding: 32px 28px;
  display: grid;
  gap: 14px;
  text-align: center;
}
.login-icon { font-size: 40px; }
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0; }

/* -------------------------------------------------------------- explorer */

#app { flex: 1; display: flex; flex-direction: column; }

.wrap {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 22px 20px 40px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 14px; }
.breadcrumb button { padding: 4px 6px; background: none; border: none; color: var(--accent); }
.breadcrumb span { color: var(--muted); }
.breadcrumb .current { color: var(--text); padding: 4px 6px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 26px;
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
  background: var(--panel);
}
.dropzone p { margin: 0; }
.dropzone-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.uploads { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.uploads li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: grid;
  gap: 6px;
  font-size: 14px;
}
.uploads .row { display: flex; justify-content: space-between; gap: 12px; }
.uploads .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 4px; border-radius: 4px; background: var(--border); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 0.2s ease; }
.uploads li.failed .bar > i { background: var(--danger); }

.listing { width: 100%; border-collapse: collapse; }
.listing th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.listing td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.listing tr:last-child td { border-bottom: none; }
.listing tbody tr[draggable='true'] { cursor: grab; }
.listing tbody tr.dragging { opacity: 0.45; }
.listing .entry { display: flex; align-items: center; gap: 9px; min-width: 0; }
.listing .entry button,
.listing .entry a {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.listing .entry a:hover, .listing .entry button:hover { color: var(--accent); text-decoration: underline; }
.col-size, .col-when { width: 120px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-actions { width: 150px; text-align: right; }
td.col-actions { text-align: right; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; margin: 0; }

/* ------------------------------------------------------- drag-in overlay */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(2px);
}
.drop-overlay-card {
  border: 3px dashed var(--accent);
  border-radius: 16px;
  background: var(--panel);
  padding: 36px 52px;
  display: grid;
  gap: 8px;
  justify-items: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.drop-overlay-icon { font-size: 34px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--panel);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: var(--shadow);
  z-index: 30;
}

@media (max-width: 620px) {
  /* Narrow screens: keep only the name and the two essential actions. */
  .col-when, .col-size { display: none; }
  .col-actions { width: auto; }
  .act-copy { display: none; }
  .wrap { padding: 16px 12px 32px; }
  .listing th, .listing td { padding: 11px 10px; }
  .listing .entry { max-width: 46vw; }
  .link { padding: 4px 3px; }
  .topbar { padding: 10px 12px; }
  .team { font-size: 12px; line-height: 1.25; white-space: normal; }
  .logo { height: 20px; }
  .topbar-actions { gap: 8px; }
  .topbar .ghost { padding: 8px 11px; }
  .footer { padding: 12px; font-size: 12px; }
}
