:root {
  --mist: #f5f6f5;
  --paper: #ffffff;
  --ink: #18211f;
  --slate: #6b7471;
  --rule: #e4e7e5;
  --rule-strong: #d5d9d7;
  --hover: #f3f5f4;
  --pine: #1f5c51;
  --pine-hi: #2b7466;
  --pine-lo: #184a41;
  --pine-edge: #143e36;
  --pine-wash: #e8f1ee;
  --signal: #b42318;
  --signal-wash: #fdf0ee;
  --radius: 10px;
  --row: 52px;
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--mist);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Top bar */
.top-inner {
  max-width: 1000px; margin: 0 auto; padding: 0 20px; height: 56px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
/* A quiet maker's mark rather than a logo lockup. */
.brand {
  display: flex; align-items: center; gap: 7px; color: var(--slate); text-decoration: none;
  font: 600 12px/1 "Doto", ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: -0.02em;
  opacity: .6; transition: opacity 160ms ease;
}
.brand:hover, .brand:focus-visible { opacity: .9; }
/* The otter is drawn in the text colour: its PNG is only used as a stencil. */
.brand-otter {
  display: block; width: 16px; height: 13px; flex-shrink: 0; background: currentColor;
  -webkit-mask: url(/otter.png) center / contain no-repeat; mask: url(/otter.png) center / contain no-repeat;
}
.help {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px 0 8px; margin-right: -8px;
  border: 0; border-radius: 8px; background: none; color: var(--slate); font-size: 14px; cursor: pointer;
}
.help:hover { background: var(--hover); color: var(--ink); }
.help:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
.help svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 520px) { .help span { display: none; } .help { padding: 0 7px; } }

.invalid { max-width: 1000px; margin: 64px auto; padding: 0 20px; font-size: 17px; }

.app { max-width: 1000px; margin: 0 auto; padding: 28px 20px 140px; }

/* Breadcrumbs */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 24px; font-size: 14px; color: var(--slate); }
.crumbs a { color: var(--slate); text-decoration: none; padding: 2px 6px; margin: 0 -2px; border-radius: 6px; }
.crumbs a:hover { color: var(--ink); background: var(--hover); }
.crumbs a.drop-target { background: var(--pine-wash); color: var(--pine); }
.crumbs .sep { width: 14px; height: 14px; opacity: .5; }

.head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 6px 0 22px; min-height: 40px;
}
h1 {
  margin: 0; font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.count { color: var(--slate); font-size: 14px; margin-right: 6px; font-variant-numeric: tabular-nums; }

/* Buttons. The primary one is meant to feel physical: a lit top edge, a dark rim, and a press that sinks. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: var(--radius);
  font-size: 15px; font-weight: 500; letter-spacing: -0.005em; white-space: nowrap;
  cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms ease, box-shadow 120ms ease, transform 60ms ease, border-color 120ms ease;
}
.btn:focus-visible, .icon-btn:focus-visible, .link:focus-visible, .row:focus-visible, .crumbs a:focus-visible, .menu button:focus-visible {
  outline: 2px solid var(--pine); outline-offset: 2px;
}
.btn-primary {
  color: #fff;
  border: .5px solid var(--pine-edge);
  background: linear-gradient(180deg, var(--pine-hi) 0%, var(--pine) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .22),
    inset 0 -1px 0 rgba(0, 0, 0, .08),
    0 1px 1px rgba(20, 62, 54, .14),
    0 2px 4px -2px rgba(20, 62, 54, .16);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .14);
}
.btn-primary:hover { background: linear-gradient(180deg, #318070 0%, #226556 100%); }
.btn-primary:active {
  transform: translateY(1px);
  background: linear-gradient(180deg, var(--pine-lo) 0%, var(--pine) 100%);
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, .22),
    inset 0 0 0 1px rgba(0, 0, 0, .04),
    0 0 0 rgba(20, 62, 54, 0);
  transition-duration: 30ms;
}
.btn-outline {
  color: var(--ink); background: var(--paper);
  border: .5px solid var(--rule-strong);
  box-shadow: 0 1px 1px rgba(24, 33, 31, .03);
}
.btn-outline:hover { background: #fafbfa; border-color: #c8cdca; }
.btn-outline:active { background: var(--hover); transform: translateY(.5px); box-shadow: none; }
.btn-danger { color: var(--signal); }
.btn-primary.btn-danger {
  color: #fff; border-color: #8f1c13;
  background: linear-gradient(180deg, #c8382c 0%, var(--signal) 100%);
}
.btn-primary.btn-danger:active { background: linear-gradient(180deg, #9d1f15 0%, var(--signal) 100%); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; margin-left: -3px; fill: none; stroke: currentColor; stroke-width: 1; stroke-linecap: round; stroke-linejoin: round; }
.btn-outline svg { opacity: .75; }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }

.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; flex-shrink: 0;
  border: 0; border-radius: 8px; background: transparent; color: var(--slate); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg, .crumbs svg, .picker-crumbs svg, .row svg, .menu svg, .tray svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; }

.link { border: 0; padding: 0; background: none; color: var(--pine); font-weight: 500; cursor: pointer; text-decoration: underline; text-decoration-color: rgba(31, 92, 81, .3); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--pine); }

/* File table */
.table { background: var(--paper); border: .5px solid var(--rule); border-radius: 14px; overflow: hidden; }
.thead, .row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 96px 132px 48px; align-items: center;
}
.thead { height: 46px; border-bottom: .5px solid var(--rule); color: var(--slate); font-size: 13px; }
.sort {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; border: 0; background: none;
  font: inherit; color: inherit; cursor: pointer; border-radius: 4px;
}
.sort:hover, .sort.on { color: var(--ink); }
.sort:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
.num .sort { flex-direction: row-reverse; }
.sort svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: transform 160ms ease, opacity 120ms ease; }
.sort:hover svg { opacity: .4; }
.sort.on svg { opacity: 1; }
.sort.desc svg { transform: rotate(180deg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.date { padding-left: 24px; font-variant-numeric: tabular-nums; }
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  height: var(--row); border-bottom: .5px solid var(--rule); cursor: default; position: relative;
  user-select: none; -webkit-user-select: none;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: #fafbfa; }
.row[aria-selected="true"] { background: var(--pine-wash); }
.row.drop-target { background: var(--pine-wash); box-shadow: inset 0 0 0 1px var(--pine); }
.row.dragging { opacity: .45; }
.row .size, .row .when { color: var(--slate); font-size: 14px; }

.check {
  width: 18px; height: 18px; margin-left: 16px; border-radius: 5px; border: 1px solid var(--rule-strong);
  background: var(--paper); display: grid; place-items: center; cursor: pointer; padding: 0;
  opacity: 0; transition: opacity 100ms ease;
}
.row:hover .check, .thead:hover .check, .selecting .check, .check:focus-visible { opacity: 1; }
.row[aria-selected="true"] .check, .check[data-state="all"], .check[data-state="some"] { background: var(--pine); border-color: var(--pine); color: #fff; }
.check svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.row[aria-selected="true"] .check svg, .check[data-state="all"] svg, .check[data-state="some"] svg { visibility: visible; }
@media (hover: none) { .check { opacity: 1; } }

.name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.kind { width: 20px; height: 32px; flex-shrink: 0; display: grid; place-items: center; color: var(--slate); }
.kind svg { width: 20px; height: 20px; stroke-width: .75; }
.kind.folder { color: var(--pine); }
.label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.is-folder .label { font-weight: 500; }
.more { opacity: 0; }
.row:hover .more, .row[aria-selected="true"] .more, .more:focus-visible, .more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .more { opacity: 1; } }

.rename {
  font: inherit; color: var(--ink); width: 100%; max-width: 420px; height: 32px; padding: 0 10px; margin-left: -11px;
  border: .5px solid var(--pine); border-radius: 8px; outline: none; background: var(--paper);
  box-shadow: 0 0 0 3px rgba(31, 92, 81, .14);
}

/* Upload rows sit in the list while they travel. */
.row.pending .label { color: var(--slate); }
.row.pending .bar { position: absolute; left: 44px; right: 0; bottom: -1px; height: 2px; background: transparent; }
.row.pending .bar span { display: block; height: 100%; background: var(--pine); width: var(--p, 0%); transition: width 300ms linear; }
.row.pending.failed .label { color: var(--signal); }

.empty { padding: 72px 24px 80px; text-align: center; }
.empty-mark {
  width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 16px; border: 1px dashed var(--rule-strong);
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%236b7471" stroke-width="1.1" stroke-linecap="round" stroke-linejoin="round"><path d="M12 16V5M7 10l5-5 5 5M5 19h14"/></svg>') center / 22px no-repeat;
}
.empty-title { margin: 0 0 6px; font-weight: 600; font-size: 17px; }
.empty-sub { margin: 0; color: var(--slate); }
.hint { margin: 0; padding: 14px 20px; border-top: .5px solid var(--rule); color: var(--slate); font-size: 13px; }
.hint:empty { display: none; }

/* Whole-window drop state */
.drop-ring {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  display: grid; place-items: end center; padding-bottom: 40px;
  box-shadow: inset 0 0 0 1.5px var(--pine);
  background: rgba(232, 241, 238, .35);
  opacity: 0; transition: opacity 120ms ease;
}
.drop-ring span {
  background: var(--pine); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 500;
  box-shadow: 0 8px 24px -8px rgba(20, 62, 54, .5); transform: translateY(6px); transition: transform 160ms ease;
}
body.dragging-files .drop-ring { opacity: 1; }
body.dragging-files .drop-ring span { transform: none; }

/* Menus, after the reference: white sheet, hairline border, muted header, full-width rules, red last item. */
.menu {
  position: fixed; z-index: 60; min-width: 220px; max-width: 300px;
  background: var(--paper); border: .5px solid #e3e5e4; border-radius: 12px;
  box-shadow: 0 12px 32px -8px rgba(24, 33, 31, .18), 0 2px 6px rgba(24, 33, 31, .05);
  padding: 6px 0; font-size: 15px;
  transform-origin: top left; animation: menu-in 110ms ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: scale(.97) translateY(-2px); } }
.menu .menu-head { padding: 6px 16px 10px; color: var(--slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu hr { border: 0; border-top: .5px solid var(--rule); margin: 6px 0; }
.menu .menu-head + hr { margin-top: 0; }
.menu button {
  display: flex; align-items: center; justify-content: space-between; width: calc(100% - 12px);
  margin: 0 6px; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button.danger { color: var(--signal); }
.menu button:disabled { color: #a9b0ad; cursor: default; background: none; }

/* Dialogs */
.dialog {
  border: .5px solid var(--rule); border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: 0 24px 64px -16px rgba(24, 33, 31, .3); color: var(--ink);
}
.dialog::backdrop { background: rgba(24, 33, 31, .28); }
.dialog[open] { animation: menu-in 140ms ease-out; }
.dialog-body { padding: 22px 22px 8px; }
.dialog h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.dialog p { margin: 0; color: var(--slate); }
.link-field {
  width: 100%; margin-top: 14px; height: 38px; padding: 0 12px; border: .5px solid var(--rule-strong); border-radius: 8px;
  font: inherit; font-size: 13px; color: var(--ink); background: var(--mist); outline: none; text-overflow: ellipsis;
}
.link-field:focus { border-color: var(--pine); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 22px 20px; }
.picker { margin: 14px -22px 0; border-top: .5px solid var(--rule); border-bottom: .5px solid var(--rule); max-height: 300px; overflow: auto; }
.picker-crumbs { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; padding: 10px 16px; font-size: 14px; color: var(--slate); border-bottom: .5px solid var(--rule); }
.picker-crumbs .sep { width: 14px; height: 14px; opacity: .5; }
.picker-crumbs button { border: 0; background: none; color: var(--slate); padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.picker-crumbs button:hover { background: var(--hover); color: var(--ink); }
.picker-crumbs button:last-child { color: var(--ink); font-weight: 500; }
.picker ul { list-style: none; margin: 0; padding: 6px 0; }
.picker li button {
  display: flex; align-items: center; gap: 10px; width: calc(100% - 16px); margin: 0 8px; padding: 8px 14px;
  border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer;
}
.picker li button:hover { background: var(--hover); }
.picker li button:disabled { color: #a9b0ad; cursor: default; background: none; }
.picker li svg { width: 20px; height: 20px; fill: none; stroke: var(--pine); stroke-width: .75; stroke-linejoin: round; stroke-linecap: round; }
.picker .none { padding: 16px 22px; color: var(--slate); }

/* Upload tray */
.tray {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 360px;
  background: var(--paper); border: .5px solid var(--rule); border-radius: 14px;
  box-shadow: 0 16px 40px -12px rgba(24, 33, 31, .22), 0 2px 6px rgba(24, 33, 31, .05);
  overflow: hidden; animation: menu-in 160ms ease-out;
}
.tray { transition: border-radius 300ms cubic-bezier(.2, .8, .2, 1); }
.tray-check { display: none; }
.tray.mini { width: auto; left: auto; border-radius: 999px; cursor: pointer; }
.tray.mini .tray-head { padding: 9px 16px 9px 12px; gap: 8px; }
.tray.mini .tray-check {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--pine); color: #fff;
}
.tray.mini .tray-check svg { width: 12px; height: 12px; stroke-width: 1.6; }
.tray.mini .tray-text strong { font-size: 14px; font-weight: 500; white-space: nowrap; }
.tray.mini .tray-text span, .tray.mini .meter, .tray.mini .tray-body, .tray.mini .icon-btn { display: none; }
.tray.mini:hover { box-shadow: 0 16px 40px -12px rgba(24, 33, 31, .26), 0 2px 6px rgba(24, 33, 31, .06); }
.tray.mini:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }
.tray-head { display: flex; align-items: center; gap: 4px; padding: 12px 10px 10px 16px; }
.tray-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tray-text strong { font-weight: 600; font-size: 15px; }
.tray-text span { color: var(--slate); font-size: 13px; font-variant-numeric: tabular-nums; }
.meter { height: 3px; background: var(--rule); margin: 0 16px 14px; border-radius: 2px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--pine); border-radius: 2px; transition: width 300ms linear; }
.tray[data-state="done"] .meter span { background: var(--pine); }
.tray-body { height: 0; overflow: hidden; }
.tray.open .tray-body { height: auto; }
.tray-list {
  list-style: none; margin: 0; padding: 4px 0 8px; max-height: 260px; overflow: auto; border-top: .5px solid var(--rule);
  opacity: 0; transform: translateY(-4px); transition: opacity 180ms ease, transform 280ms cubic-bezier(.2, .8, .2, 1);
}
.tray.open .tray-list { opacity: 1; transform: none; }
#tray-toggle svg { transition: transform 280ms cubic-bezier(.2, .8, .2, 1); }
.tray.open #tray-toggle svg { transform: rotate(180deg); }
.tray-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 7px 16px; font-size: 14px; }
.tray-list .t-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-list .t-status { color: var(--slate); font-variant-numeric: tabular-nums; font-size: 13px; }
.tray-list .t-dir { grid-column: 1 / -1; color: var(--slate); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-list .failed .t-status { color: var(--signal); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4); animation: menu-in 140ms ease-out; max-width: calc(100vw - 32px);
}

@media (hover: none) { .hint { display: none; } }

@media (max-width: 720px) {
  .brand { white-space: nowrap; }
  .app { padding-top: 20px; }
  h1 { font-size: 24px; }
  .head { flex-wrap: wrap; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
  .thead, .row { grid-template-columns: 40px minmax(0, 1fr) 76px 44px; }
  .date { display: none; }
  .check { margin-left: 12px; }
  .tray { left: 12px; right: 12px; bottom: 12px; width: auto; }
}

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