/* ============================================================
   Dinter — brand system + components
   Palette verified from dinter.tv (The7 css-vars.css).
   Rule: white/gray/ink 95% of the time; orange only where
   something is moving or selected.
   ============================================================ */

:root {
  --brand-orange: #F0661D;        /* verified accent — non-text UI only */
  --brand-orange-deep: #C8500F;   /* AA text/buttons (4.56:1 on white) */
  --brand-orange-deeper: #A84208; /* hover/active */
  --ink: #18191B;
  --text: #303030;
  --text-secondary: #6B6E76;
  --text-placeholder: #8B8D94;
  --bg: #F8F8F9;
  --surface: #FFFFFF;
  --surface-hover: #F3F4F6;
  --selected-bg: #FDF0E8;
  --border: #E4E5E9;
  --border-strong: #C9CBD1;
  --danger: #B42318;
  --danger-bg: #FEF3F2;
  --success: #067647;
  --success-bg: #ECFDF3;
  --warning: #B54708;
  --warning-bg: #FFFAEB;
  --focus-ring: #F0661D;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow-card: 0 1px 2px rgba(24, 25, 27, 0.06);
  --shadow-float: 0 8px 24px rgba(24, 25, 27, 0.16);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Varela Round", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

@font-face {
  font-family: "Varela Round";
  src: url("/fonts/varela-round-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100%; }

button { font: inherit; cursor: pointer; }
input { font: inherit; }
a { color: var(--brand-orange-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

:is(button, input, a, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- shared bits ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: none; border-radius: var(--radius-s);
  font-size: 15px; font-weight: 600;
  background: var(--brand-orange-deep); color: #fff;
}
.btn:hover { background: var(--brand-orange-deeper); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn.ghost:hover { background: var(--surface-hover); }
.btn.icon { padding: 0 10px; }

.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.banner {
  border-radius: 8px; padding: 10px 12px;
  font-size: 13px; line-height: 1.5;
  margin-bottom: 16px;
}
.banner.error { background: var(--danger-bg); color: var(--danger); }
.banner.warn { background: var(--warning-bg); color: var(--warning); }
.banner.neutral { background: var(--bg); color: var(--text); border: 1px solid var(--border); }

svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ---------- sign-in ---------- */

.login-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 16px;
}
.login-card {
  width: 400px; max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  padding: 40px 40px 32px;
}
.login-card .logo { display: block; width: 64px; height: 64px; margin: 0 auto 16px; }
.login-card h1 {
  font-family: var(--font-brand); font-weight: 400;
  font-size: 28px; line-height: 36px;
  color: var(--ink); text-align: center;
}
.login-card .tagline {
  font-size: 13px; color: var(--text-secondary);
  text-align: center; margin: 4px 0 32px;
}
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 6px; color: var(--text);
}
.field .control { position: relative; }
.field input {
  width: 100%; height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
}
.field input::placeholder { color: var(--text-placeholder); }
.field .eye {
  position: absolute; right: 6px; top: 6px;
  width: 32px; height: 32px;
  border: none; background: transparent;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.login-card .btn.submit { width: 100%; height: 44px; justify-content: center; margin-top: 8px; }
.login-help {
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary);
  text-align: center;
}
.login-footer {
  margin-top: 24px; font-size: 12px;
  color: var(--text-secondary); text-align: center;
}

@media (max-width: 767px) {
  .login-page { justify-content: flex-start; padding-top: 48px; }
}

/* ---------- app shell ---------- */

.shell { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  height: 64px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header .inner {
  max-width: 1120px; margin: 0 auto; height: 100%;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.wordmark {
  display: flex; align-items: center; gap: 10px;
  border: none; background: none; padding: 4px;
}
.wordmark img { width: 32px; height: 32px; }
.wordmark .name {
  font-family: var(--font-brand); font-size: 18px; color: var(--ink);
}
.wordmark .name span { color: var(--text-secondary); }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-right .who { font-size: 13px; color: var(--text-secondary); }
.signout {
  border: none; background: none;
  font-size: 13px; font-weight: 600; color: var(--text);
  padding: 6px 8px; border-radius: 4px;
}
.signout:hover { text-decoration: underline; }

.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 24px 64px; }

/* ---------- toolbar / breadcrumb / selection bar ---------- */

.toolbar {
  min-height: 56px; padding: 12px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.crumbs {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  font-size: 15px; min-width: 0;
}
.crumbs a, .crumbs button.crumb {
  border: none; background: none; padding: 2px 4px;
  color: var(--text-secondary); font-size: 15px;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 4px;
}
.crumbs a:hover, .crumbs button.crumb:hover { color: var(--brand-orange-deep); text-decoration: underline; }
.crumbs .sep { color: var(--text-secondary); }
.crumbs .current {
  font-weight: 600; color: var(--ink); padding: 2px 4px;
  max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.filter-box { position: relative; }
.filter-box input {
  width: 240px; height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-s);
  background: var(--surface);
}

.selection-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--brand-orange);
  border-radius: var(--radius-s);
  animation: slidein 0.15s ease-out;
}
@keyframes slidein { from { transform: translateY(-4px); opacity: 0; } }
.selection-bar .count { font-weight: 600; }
.selection-bar .zipnote {
  flex-basis: 100%;
  font-size: 12px; color: var(--text-secondary);
}
.selection-actions { display: flex; gap: 8px; }

/* ---------- file table ---------- */

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
table.files { width: 100%; border-collapse: collapse; }
table.files th {
  height: 44px; padding: 0 12px;
  text-align: left; vertical-align: middle;
  font-size: 12px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
table.files th.sortable { cursor: pointer; }
table.files th.sortable:hover { color: var(--ink); }
table.files td {
  height: 48px; padding: 0 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 15px;
}
table.files tr:last-child td { border-bottom: none; }
table.files tbody tr { cursor: default; }
table.files tbody tr:hover { background: var(--surface-hover); }
table.files tbody tr.selected {
  background: var(--selected-bg);
  box-shadow: inset 3px 0 0 var(--brand-orange);
}
.col-check { width: 44px; }
.col-icon { width: 40px; }
.col-size { width: 110px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.col-mtime { width: 170px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.col-action { width: 56px; text-align: right; }
td.col-size { text-align: right; }

.name-cell {
  display: flex; align-items: center; gap: 4px;
  min-width: 0; max-width: 560px;
}
.name-cell .fname {
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: var(--ink);
}
.name-cell button.open {
  border: none; background: none; text-align: left;
  color: var(--ink); font-size: 15px; font-weight: 600;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  padding: 2px 0;
}
.name-cell button.open:hover { color: var(--brand-orange-deep); text-decoration: underline; }
tr .row-dl {
  visibility: hidden;
  border: none; background: none; color: var(--text-secondary);
  width: 36px; height: 36px; border-radius: var(--radius-s);
  display: inline-flex; align-items: center; justify-content: center;
}
tr:hover .row-dl, tr:focus-within .row-dl { visibility: visible; }
.row-dl:hover { color: var(--brand-orange-deep); background: var(--surface-hover); }

.icon-folder { color: var(--brand-orange-deep); }
.icon-file { color: var(--text-secondary); }

input[type="checkbox"].rowcheck {
  width: 16px; height: 16px;
  accent-color: var(--brand-orange-deep);
}

/* ---------- states ---------- */

.state-block { padding: 64px 24px; text-align: center; }
.state-block .glyph { color: var(--text-placeholder); margin-bottom: 12px; }
.state-block .glyph svg { width: 48px; height: 48px; stroke-width: 1.2; }
.state-block h2 {
  font-family: var(--font-brand); font-weight: 400;
  font-size: 20px; color: var(--ink); margin-bottom: 6px;
}
.state-block p { font-size: 15px; color: var(--text-secondary); max-width: 420px; margin: 0 auto 16px; }

.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.skeleton-row .sk { background: var(--border); border-radius: 4px; animation: shimmer 1.2s ease-in-out infinite; }
.skeleton-row .sk.circle { width: 24px; height: 24px; border-radius: 50%; }
.skeleton-row .sk.bar { height: 12px; flex: 1; max-width: 380px; }
.skeleton-row .sk.bar.short { max-width: 90px; }
@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------- toasts ---------- */

.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  width: 360px; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--ink); color: #fff;
  border-radius: 8px; padding: 12px 14px;
  font-size: 13px; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 10px;
  box-shadow: var(--shadow-float);
}
.toast.error { box-shadow: inset 3px 0 0 var(--danger), var(--shadow-float); }
.toast .close {
  margin-left: auto; border: none; background: none; color: #fff;
  opacity: 0.7; font-size: 16px; line-height: 1; padding: 2px;
}
.toast .close:hover { opacity: 1; }
.toast .action {
  border: none; background: none; color: #fff;
  font-weight: 600; text-decoration: underline; padding: 0;
}

/* ---------- transfer panel ---------- */

.transfer-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  width: 360px; max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
.transfer-panel header {
  height: 44px; padding: 0 8px 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600; color: var(--ink);
}
.transfer-panel header .hbtns { display: flex; }
.transfer-panel header button {
  border: none; background: none; width: 32px; height: 32px;
  color: var(--text-secondary); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.transfer-panel header button:hover { background: var(--surface-hover); }
.transfer-list { max-height: 276px; overflow-y: auto; }
.transfer-item { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.transfer-item:last-child { border-bottom: none; }
.transfer-item .row1 {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.transfer-item .tname {
  flex: 1; min-width: 0;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: var(--ink);
}
.transfer-item .tstatus { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.transfer-item .tstatus.done { color: var(--success); }
.transfer-item .tstatus.failed { color: var(--danger); }
.transfer-item .retry {
  border: none; background: none; color: var(--brand-orange-deep);
  font-size: 12px; font-weight: 600; padding: 0;
}
.progress {
  margin-top: 6px; height: 4px; border-radius: 999px;
  background: var(--border); overflow: hidden;
}
.progress > div {
  height: 100%; border-radius: 999px;
  background: var(--brand-orange);
  transition: width 0.3s linear;
}
.progress.done > div { background: var(--success); }
.transfer-item .stats {
  margin-top: 4px; font-size: 12px; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ---------- modal ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(24, 25, 27, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  width: 440px; max-width: 100%;
  background: var(--surface); border-radius: var(--radius-m);
  box-shadow: var(--shadow-float);
  padding: 24px;
}
.modal h2 {
  font-family: var(--font-brand); font-weight: 400;
  font-size: 20px; color: var(--ink); margin-bottom: 8px;
}
.modal p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.modal ul {
  margin: 0 0 20px 18px; font-size: 13px; color: var(--text);
  max-height: 120px; overflow-y: auto;
}
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

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

.drop-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(248, 248, 249, 0.92);
  display: flex; align-items: center; justify-content: center;
}
.drop-overlay .inner {
  position: absolute; inset: 16px;
  border: 2px dashed var(--brand-orange);
  border-radius: var(--radius-m);
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center;
  color: var(--ink); font-size: 18px; font-family: var(--font-brand);
  text-align: center; padding: 24px;
}
.drop-overlay svg { width: 48px; height: 48px; color: var(--brand-orange-deep); }

/* ---------- mobile ---------- */

.mobile-hint {
  font-size: 12px; color: var(--warning);
  background: var(--warning-bg);
  border-radius: var(--radius-s);
  padding: 8px 12px; margin-bottom: 12px;
  display: none;
}

@media (max-width: 767px) {
  .app-header { height: 56px; }
  .app-header .inner { padding: 0 16px; }
  .main { padding: 0 16px 96px; }
  .header-right .who { display: none; }
  .filter-box input { width: 140px; }
  .mobile-hint { display: block; }
  .col-mtime, .col-check, th.col-action { display: none; }
  td.col-action { display: table-cell; }
  table.files td { height: 56px; }
  .selection-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
    margin: 0; border-radius: 0;
    border-left: none; border-top: 3px solid var(--brand-orange);
  }
  .transfer-panel { right: 0; bottom: 0; width: 100%; max-width: 100%; border-radius: var(--radius-m) var(--radius-m) 0 0; }
  .toasts { top: 8px; right: 8px; }
}
