/* Light, matching App.Shawn's palette (src/App.Shawn/App.xaml). */
:root {
  --canvas: #F4F7FB;
  --surface: #FFFFFF;
  --sidebar: #FBFCFE;
  --field: #F7F9FC;
  --border: #E3E9F1;
  --text: #162033;
  --muted: #667085;
  --dim: #8A94A6;
  --accent: #2867E8;
  --accent-hover: #1F58CD;
  --accent-soft: #EAF1FF;
  --success: #168A5B;
  --danger: #C83D4D;
  --off: #C0C7D2;
  --row-hover: rgba(22, 32, 51, 0.035);
  --row-press: rgba(22, 32, 51, 0.06);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 13.5px/1.4 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* Press feedback lands on pointer-down and lets go fast. */
button, .button, .up, .row, .crumbs a {
  transition: transform 180ms var(--ease-out), background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}
button:active, .button:active, .up:active { transform: scale(0.97); transition-duration: 90ms; }
.row:active { transform: scale(0.992); background: var(--row-press); transition-duration: 90ms; }

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

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

.login {
  width: min(340px, calc(100% - 32px));
  margin: 18vh auto 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login .mark { color: var(--accent); }
.login h1 { margin: 4px 0 14px; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; }
.login label { color: var(--muted); font-size: 12.5px; }
.login input {
  height: 44px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.login input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(40, 103, 232, 0.14); }
.error { color: var(--danger); min-height: 1.4em; margin: 0; }

.primary {
  position: relative;
  height: 42px; border: 0; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 500;
}
@media (hover: hover) and (pointer: fine) { .primary:hover { background: var(--accent-hover); } }
.primary .spinner {
  position: absolute; inset: 0; margin: auto; width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%;
  opacity: 0; transform: scale(0.6);
  transition: opacity 160ms ease, transform 200ms var(--ease-out);
  animation: spin 700ms linear infinite;
}
.primary span { transition: opacity 120ms ease, filter 160ms ease; }
.primary.busy span { opacity: 0; filter: blur(2px); }
.primary.busy .spinner { opacity: 1; transform: none; }
@keyframes spin { to { rotate: 360deg; } }

/* ---------- layout ---------- */

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr) 300px;
}
.app.no-detail { grid-template-columns: 248px minmax(0, 1fr); }

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 12px 12px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 18px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand svg { color: var(--accent); }
.section { font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--dim); padding: 16px 10px 6px; }
.brand + .section { padding-top: 0; }
.grow { flex-grow: 1; }
.hint { margin: 12px 10px 4px; font-size: 12px; color: var(--dim); }
.quiet { height: 34px; border: 0; background: transparent; color: var(--muted); text-align: left; padding: 0 10px; border-radius: 8px; }

.machines { position: relative; display: flex; flex-direction: column; gap: 2px; }
/* One background that slides to whichever machine is chosen. */
.highlight {
  position: absolute; left: 0; top: 0; z-index: 0;
  border-radius: 10px; background: var(--accent-soft);
  opacity: 0; pointer-events: none; will-change: transform;
}
.machine {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 52px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; text-align: left;
}
.machine .name { font-weight: 500; display: block; }
.machine .state { font-size: 12px; color: var(--muted); display: block; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--off); transition: background-color 300ms ease; }
.dot.on { background: var(--success); }
.dot.checking { background: var(--dim); animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.3; } }

.place {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: 34px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.place svg { color: var(--muted); flex-shrink: 0; }

@media (hover: hover) and (pointer: fine) {
  .machine:not([aria-current="true"]):hover, .place:hover, .quiet:hover { background: var(--row-hover); }
}

/* ---------- main ---------- */

.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.progress-track { position: absolute; top: 0; left: 0; right: 0; height: 2px; z-index: 5; pointer-events: none; overflow: hidden; }
.progress { height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); opacity: 0; }

.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.up {
  width: 36px; height: 36px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 9px; color: var(--text);
}
.up[aria-disabled="true"] { color: var(--off); pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .up:hover { background: var(--row-hover); } }

.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; flex-grow: 1; overflow: hidden; white-space: nowrap; }
.crumbs a { color: var(--muted); text-decoration: none; padding: 4px 6px; border-radius: 6px; flex-shrink: 0; }
.crumbs a:last-child { color: var(--text); font-weight: 600; flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; }
.crumbs .sep { color: var(--dim); }
@media (hover: hover) and (pointer: fine) { .crumbs a:hover { background: var(--row-hover); } }

.filter {
  display: flex; align-items: center; gap: 8px;
  width: 260px; height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--field); color: var(--dim);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}
.filter:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px rgba(40, 103, 232, 0.12); }
.filter input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--text); }

.cols, .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 132px 44px;
  align-items: center;
}
.cols { padding: 10px 36px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.list { flex-grow: 1; overflow-y: auto; padding: 6px 12px; transition: opacity 200ms ease, filter 200ms ease; }
/* Waiting on the next folder: the current one steps back instead of vanishing. */
.list.pending { opacity: 0.45; filter: saturate(0.6); pointer-events: none; }

.row {
  min-height: 42px; padding: 0 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; cursor: default;
}
a.row { cursor: pointer; }
.row[aria-selected="true"] { background: var(--accent-soft); }
@media (hover: hover) and (pointer: fine) { .row:not([aria-selected="true"]):hover { background: var(--row-hover); } }
.row .label { display: flex; align-items: center; gap: 12px; min-width: 0; }
.row .label > div { min-width: 0; overflow: hidden; }
.row .label span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .label .meta { display: none; }
.row .num { color: var(--muted); }
.row.hidden-file .label span { color: var(--muted); }
.row .get {
  justify-self: end; width: 32px; height: 32px;
  display: grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
  transition: transform 180ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.row .get:active { transform: scale(0.9); transition-duration: 90ms; }
@media (hover: hover) and (pointer: fine) { .row .get:hover { background: var(--surface); color: var(--accent); } }

.icon-dir { color: var(--accent); fill: var(--accent-soft); flex-shrink: 0; }
.icon-file { color: var(--dim); flex-shrink: 0; }

/* Placeholder rows while a slow machine answers. */
.skel { pointer-events: none; animation: skel-in 300ms var(--ease-out) backwards; }
.skel i { display: block; border-radius: 6px; background: linear-gradient(90deg, #EDF1F6 0%, #F6F8FB 40%, #EDF1F6 80%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.sk-icon { width: 18px; height: 18px; flex-shrink: 0; border-radius: 5px !important; }
.sk-line { height: 10px; }
.sk-short { width: 48px; margin-left: auto; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
@keyframes skel-in { from { opacity: 0; } }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }

.foot { padding: 10px 24px; font-size: 12px; color: var(--dim); border-top: 1px solid var(--border); }

/* ---------- detail ---------- */

.detail {
  background: var(--surface); border-left: 1px solid var(--border);
  padding: 24px; overflow-y: auto;
}
.detail-body { display: flex; flex-direction: column; gap: 18px; }
.grip { display: none; }
.preview {
  aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  background: var(--field); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--dim);
}
.preview.loading-shimmer { background: linear-gradient(90deg, #EFF3F8 0%, #F8FAFC 40%, #EFF3F8 80%) 0 0 / 300% 100%; animation: shimmer 1.4s linear infinite; }
.preview img, .preview video { width: 100%; height: 100%; object-fit: contain; background: var(--field); }
.preview pre { margin: 0; padding: 12px; width: 100%; height: 100%; overflow: hidden; font: 11.5px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text); white-space: pre-wrap; word-break: break-all; place-self: stretch; background: var(--field); }
/* A preview arrives by coming into focus, not popping in. */
.appear { opacity: 0; filter: blur(6px); transform: scale(1.02); transition: opacity 320ms ease, filter 360ms var(--ease-out), transform 420ms var(--ease-out); }
.appear.in { opacity: 1; filter: none; transform: none; }
.detail h2 { margin: 0; font-size: 15px; font-weight: 600; word-break: break-all; letter-spacing: -0.005em; }
.detail .kind { color: var(--muted); margin-top: 4px; }
.detail dl { margin: 0; display: grid; grid-template-columns: 84px minmax(0, 1fr); row-gap: 8px; font-size: 12.5px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; word-break: break-all; }
.actions { display: flex; flex-direction: column; gap: 8px; }
.button {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; border-radius: 10px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.button span { display: inline-block; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
@media (hover: hover) and (pointer: fine) {
  .button:not(.primary):hover { background: var(--field); }
  .button.primary:hover { background: var(--accent-hover); }
}
.close-detail { display: none; }
.scrim { display: none; }

/* ---------- phone ---------- */

@media (max-width: 760px) {
  body { font-size: 15px; }
  .app, .app.no-detail { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }

  .sidebar {
    position: relative; z-index: 3;
    flex-direction: row; gap: 8px; padding: max(12px, env(safe-area-inset-top)) 16px 10px;
    border-right: 0; background: rgba(255, 255, 255, 0.72);
    -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand, .section, .places, .grow, .hint, .quiet, .machine .state { display: none; }
  .machines { flex-direction: row; gap: 8px; }
  .highlight { border-radius: 18px; background: var(--accent); }
  .machine {
    width: auto; min-height: 36px; height: 36px; padding: 0 14px; gap: 6px;
    border: 1px solid var(--border); border-radius: 18px; background: transparent; white-space: nowrap;
    transition: transform 180ms var(--ease-out), color 220ms ease, border-color 220ms ease;
  }
  .machine .name { font-weight: 400; font-size: 14px; }
  .machine[aria-current="true"] { border-color: transparent; color: #fff; }
  .machine[aria-current="true"] .dot { background: #fff; }
  .dot { width: 7px; height: 7px; }

  .bar { padding: 8px 12px; flex-wrap: wrap; }
  .up { width: 44px; height: 44px; }
  .filter { width: 100%; height: 40px; order: 3; }
  .cols { display: none; }
  .list { padding: 8px; }
  .row { grid-template-columns: minmax(0, 1fr) 44px; min-height: 56px; padding: 0 10px; border-radius: 10px; }
  .row:active { transform: scale(0.985); }
  .row .label { gap: 14px; }
  .row .label > div { display: flex; flex-direction: column; min-width: 0; }
  .row .label .meta { display: block; font-size: 12.5px; color: var(--muted); }
  .row .num { display: none; }
  .row .get { width: 44px; height: 44px; }

  .scrim {
    display: block; position: fixed; inset: 0; z-index: 9;
    background: rgba(22, 32, 51, 0.28); opacity: 0;
  }
  .detail {
    position: fixed; inset: auto 0 0 0; z-index: 10; max-height: 86dvh;
    border-left: 0; border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 40px rgba(22, 32, 51, 0.14);
    padding: 8px 16px max(20px, env(safe-area-inset-bottom));
    touch-action: pan-y; will-change: transform;
  }
  .grip { display: block; width: 100%; height: 22px; position: relative; cursor: grab; touch-action: none; }
  .grip::after { content: ""; position: absolute; left: 50%; top: 8px; width: 38px; height: 5px; margin-left: -19px; border-radius: 3px; background: #D5DBE4; }
  .close-detail { display: flex; }
  .foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; animation-iteration-count: 1 !important; }
  .list.pending { opacity: 0.6; }
}
@media (prefers-reduced-transparency: reduce) {
  .sidebar { background: var(--surface) !important; backdrop-filter: none !important; }
}
.icon-drive { color: var(--muted); flex-shrink: 0; }

.back { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; margin-bottom: 4px; border-radius: 8px; color: var(--muted); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .back:hover { background: var(--row-hover); } }
.brand span { font-size: 20px; letter-spacing: -0.015em; }
@media (max-width: 760px) { .back { flex-shrink: 0; height: 36px; margin: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); } .sidebar .brand { display: none; } }

/* Disk space under a shortcut: a hairline meter and "783 GB of 1 TB". */
.place { height: auto; min-height: 34px; padding: 6px 10px; align-items: flex-start; }
.place svg { margin-top: 2px; }
.place-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.space { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--dim); opacity: 0; transition: opacity 240ms ease; }
.space:empty { display: none; }
.space.in { opacity: 1; }
.meter { display: block; height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; }
.meter b { display: block; height: 100%; border-radius: 2px; background: var(--accent); transform-origin: left; animation: fill 600ms cubic-bezier(0.23, 1, 0.32, 1) both; }
@keyframes fill { from { transform: scaleX(0); } }
.row .num[data-drive] { color: var(--muted); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { .meter b { animation: none; } }

/* ---------- long press / right-click menu ---------- */
.row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.row.holding { transform: scale(0.975); background: var(--row-press); transition: transform 450ms cubic-bezier(0.32, 0.72, 0, 1), background-color 450ms ease; }
.ctx-scrim { position: fixed; inset: 0; z-index: 40; background: transparent; }
.ctx {
  position: fixed; z-index: 41; min-width: 230px; padding: 6px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 16px 48px rgba(22, 32, 51, 0.2), 0 0 0 1px rgba(22, 32, 51, 0.06);
  display: flex; flex-direction: column;
}
.ctx-head { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ctx-head strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.ctx-head span { font-size: 12px; color: var(--muted); }
.ctx button { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; color: var(--text); }
.ctx button svg { color: var(--accent); flex-shrink: 0; }
@media (hover: hover) and (pointer: fine) { .ctx button:hover { background: var(--accent-soft); } }
.ctx button:focus-visible { outline: none; background: var(--accent-soft); }
.ctx.sheet { left: 8px !important; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); top: auto !important; border-radius: 22px; padding: 8px; }
.ctx.sheet button { height: 52px; font-size: 16px; }
@media (prefers-reduced-transparency: reduce) { .ctx { background: var(--surface); backdrop-filter: none; } }

.confirm { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(22, 32, 51, 0.28); }
.confirm-card { width: min(380px, 100%); background: var(--surface); border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 24px 60px rgba(22, 32, 51, 0.25); }
.confirm-card strong { font-size: 16px; font-weight: 600; word-break: break-word; }
.confirm-card p { margin: 0 0 8px; color: var(--muted); }
.confirm-actions { display: flex; gap: 8px; }
.confirm-actions .button { flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 60;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 20px; background: var(--text); color: #fff; font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(22, 32, 51, 0.18); transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  transition: transform 360ms cubic-bezier(0.23, 1, 0.32, 1), opacity 240ms ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
