/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --ink-950: #0a0c0f;
  --ink-900: #12151a;
  --ink-850: #171b21;
  --ink-800: #1c212a;
  --line: #262c36;
  --line-soft: #1d222b;
  --paper: #e8eaed;
  --muted: #8891a1;
  --muted-dim: #5c6473;
  --brass: #c99a4b;
  --brass-soft: #a9823f;
  --brass-wash: rgba(201, 154, 75, 0.1);
  --ok: #4fb286;
  --ok-wash: rgba(79, 178, 134, 0.12);
  --danger: #e2604f;
  --danger-wash: rgba(226, 96, 79, 0.12);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--ink-950);
  color: var(--paper);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brass); text-decoration: none; }
a:hover { color: #ddb063; }

button, input {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.mono { font-family: var(--font-mono); }

.icon { width: 16px; height: 16px; flex-shrink: 0; vertical-align: -3px; }

/* ── Flash toasts ───────────────────────────────────────────────────────── */
.flash-stack {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted-dim);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  animation: flash-in 0.25s ease;
}
.flash-error { border-left-color: var(--danger); }
.flash-success { border-left-color: var(--ok); }

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Vault dial (signature element) ────────────────────────────────────── */
.dial-ring-outer, .dial-ring-inner {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.dial-tick { stroke: var(--muted-dim); stroke-width: 0.6; }
.dial-tick-major { stroke: var(--muted); stroke-width: 0.9; }
.dial-progress {
  fill: none;
  stroke: var(--brass);
  stroke-width: 2.4;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50px 50px;
  transition: stroke-dashoffset 0.6s ease;
}
.dial-faint { opacity: 0.5; }
.dial-faint .dial-ring-outer, .dial-faint .dial-ring-inner { stroke: var(--line-soft); }
.dial-faint .dial-tick, .dial-faint .dial-tick-major { stroke: var(--line-soft); }

/* ── Auth screens (login / 2FA / setup) ───────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 24px;
}

.auth-backdrop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
  pointer-events: none;
}

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 340px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .icon { width: 20px; height: 20px; color: var(--brass); }
.brand-name {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper);
}

.auth-title { margin: 0; font-size: 19px; font-weight: 600; }
.auth-subtitle { margin: -12px 0 0; color: var(--muted); font-size: 13.5px; }
.auth-subtitle-tight { margin-top: -8px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"], input[type="password"], input[type="search"] {
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--paper);
  transition: border-color 0.15s ease;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="search"]:focus {
  border-color: var(--brass);
}

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: var(--brass);
  color: var(--ink-950);
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.15s ease, opacity 0.15s ease;
}
button:hover, .btn:hover { background: #ddb063; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--ink-800); border-color: var(--muted-dim); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: var(--danger-wash); }

.btn-block { width: 100%; }

.auth-foot { text-align: center; font-size: 12.5px; color: var(--muted-dim); }

/* ── 2FA digit input ────────────────────────────────────────────────────── */
.otp-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.otp-digit {
  width: 40px;
  height: 48px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 20px;
  padding: 0;
}
.otp-hidden { position: absolute; opacity: 0; pointer-events: none; height: 0; width: 0; }
.otp-alt { text-align: center; font-size: 12.5px; color: var(--muted); }
.otp-digit-wide { width: 180px; letter-spacing: 0.08em; font-size: 15px; }
.hidden { display: none; }

/* ── Setup 2FA / backup codes ──────────────────────────────────────────── */
.setup-card { width: 400px; }
.qr-frame {
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-frame img { display: block; width: 176px; height: 176px; }

.secret-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  word-break: break-all;
}
.secret-box .icon { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }
.secret-box button { background: transparent; color: var(--muted); padding: 4px; }
.secret-box button:hover { color: var(--brass); }

.backup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 14px;
}
.backup-grid span { color: var(--paper); }
.backup-warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--danger-wash);
  border: 1px solid rgba(226, 96, 79, 0.35);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: #f2b3aa;
}
.backup-warning .icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--danger); margin-top: 1px; }

.confirm-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--muted);
}
.confirm-check input { margin-top: 3px; }

/* ── App shell ──────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-900);
}
.topbar .brand-name { font-size: 14px; }

.gauge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12.5px;
}
.gauge .dial { flex-shrink: 0; }
.gauge-text .used { color: var(--paper); font-family: var(--font-mono); }

/* ── Search + nav ───────────────────────────────────────────────────────── */
.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--muted-dim);
  flex: 0 1 320px;
  margin-left: auto;
}
.search-form.search-form-end { margin-left: 20px; }
.search-form .icon { width: 15px; height: 15px; flex-shrink: 0; }
.search-form input {
  background: none;
  border: none;
  color: var(--paper);
  width: 100%;
  padding: 2px 0;
}
.search-form input:focus { outline: none; }
.search-form:focus-within { border-color: var(--brass); }

.nav-icons { display: flex; gap: 2px; margin-left: 16px; }
.nav-icons-end { margin-left: auto; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
}
.icon-btn:hover { color: var(--paper); background: var(--ink-800); border-color: var(--line); }
.icon-btn .icon { width: 18px; height: 18px; }

.breadcrumbs {
  padding: 14px 28px 0;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-mono);
}
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brass); }
.breadcrumbs .sep { margin: 0 8px; color: var(--muted-dim); }
.breadcrumbs .current { color: var(--paper); }

.toolbar {
  display: flex;
  gap: 14px;
  padding: 16px 28px;
  flex-wrap: wrap;
  align-items: stretch;
}

.dropzone {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 18px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  font-size: 13.5px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.dropzone .icon { width: 18px; height: 18px; }
.dropzone.drag { border-color: var(--brass); background: var(--brass-wash); color: var(--paper); }

.mkdir-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.mkdir-form input { width: 180px; }

/* ── Bulk selection bar ─────────────────────────────────────────────────── */
.bulk-bar {
  display: none;
  align-items: center;
  gap: 12px;
  margin: 0 28px 14px;
  padding: 10px 16px;
  background: var(--brass-wash);
  border: 1px solid var(--brass-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.bulk-bar.open { display: flex; }
.bulk-bar #bulk-count { color: var(--paper); font-weight: 600; margin-right: auto; }
.bulk-bar button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; }
.bulk-bar .icon { width: 15px; height: 15px; }

.col-check { width: 36px; }
.sort-link { display: inline-flex; align-items: center; gap: 3px; color: inherit; }
.sort-link:hover { color: var(--brass); }
.icon-sm { width: 11px; height: 11px; }
.path-hint { display: block; color: var(--muted-dim); font-size: 11.5px; font-family: var(--font-mono); margin-top: 1px; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--paper);
  font-weight: 400;
  font-size: inherit;
  cursor: pointer;
  text-align: left;
}
.link-btn:hover { color: var(--brass); background: none; }

.row-actions-visible { opacity: 1; }

.panel {
  margin: 0 28px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ink-900);
}

table.files { width: 100%; border-collapse: collapse; }
table.files th, table.files td {
  padding: 11px 20px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
table.files thead th {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--ink-850);
  border-bottom: 1px solid var(--line);
}
table.files tbody tr:last-child td { border-bottom: none; }
table.files tbody tr:hover { background: var(--ink-850); }

.file-name { display: flex; align-items: center; gap: 10px; }
.file-name .icon { width: 17px; height: 17px; color: var(--muted); flex-shrink: 0; }
.file-name a { color: var(--paper); }
.file-name a:hover { color: var(--brass); }
td.col-size, td.col-date { color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; white-space: nowrap; }
td.col-actions { text-align: right; white-space: nowrap; }

.row-actions { display: inline-flex; gap: 4px; opacity: 0; transition: opacity 0.1s ease; }
table.files tbody tr:hover .row-actions,
table.files tbody tr:focus-within .row-actions { opacity: 1; }
.row-actions form { display: inline; }

.empty-state {
  padding: 64px 24px;
  text-align: center;
  color: var(--muted);
}
.empty-state .dial { margin: 0 auto 16px; opacity: 0.6; }
.empty-state p { margin: 0; font-size: 13.5px; }

/* ── Modal (delete confirm) ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 9, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  width: 340px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-card h2 { margin: 0; font-size: 16px; }
.modal-card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-card select {
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--paper);
  width: 100%;
}

.modal-card-lg { width: min(720px, 92vw); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { word-break: break-all; padding-right: 12px; }
.preview-body {
  max-height: 70vh;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--ink-950);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.preview-body img { max-width: 100%; display: block; border-radius: 4px; }
.preview-body embed { width: 100%; height: 65vh; border: none; }
.preview-text {
  width: 100%;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--paper);
}

/* ── Settings page ──────────────────────────────────────────────────────── */
.settings-wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.settings-wrap-wide { max-width: 980px; }
.settings-wrap-wide .panel { margin: 0 0 24px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-title { margin: 0; font-size: 20px; }

.col-link { width: 220px; max-width: 220px; }
.share-url { display: flex; align-items: center; gap: 6px; min-width: 0; }
.share-url-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-url .icon-btn { flex-shrink: 0; }
.js-copy-link.copied { color: var(--ok); }
.row-warning { background: var(--danger-wash); }
.activity-table td { font-size: 13px; }
.settings-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}
.settings-back:hover { color: var(--brass); }

.card {
  background: var(--ink-900);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.card-danger { border-left-color: var(--danger); }
.card h2 { margin: 0 0 4px; font-size: 15px; }
.card .card-desc { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.card form { display: flex; flex-direction: column; gap: 12px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-on { background: var(--ok-wash); color: var(--ok); }
.status-off { background: var(--danger-wash); color: var(--danger); }
.status-pill .icon { width: 12px; height: 12px; }

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.meta-note { color: var(--muted); font-size: 12.5px; }
.icon-btn-end { margin-left: auto; }

/* ── Error page ─────────────────────────────────────────────────────────── */
.error-code { font-family: var(--font-mono); font-size: 40px; color: var(--brass); margin: 0; }
.auth-card-center { text-align: center; }
.brand-center { justify-content: center; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; row-gap: 10px; }
  .gauge { display: none; }
  .search-form { order: 4; flex-basis: 100%; margin-left: 0; }
  .nav-icons { margin-left: auto; }
  .breadcrumbs { padding: 12px 16px 0; }
  .toolbar { padding: 14px 16px; }
  .panel { margin: 0 16px 20px; overflow-x: auto; }
  table.files { min-width: 480px; }
  .row-actions { opacity: 1; }
}

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