/* Folio Cloud library. White first, light + dark, one tint, 4-pt scale. Kind colours are Folio's own. */
:root {
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI Variable Text', 'Segoe UI', system-ui, sans-serif;
  --bg: #ffffff;
  --ink: #1b1d21;
  --ink-2: #5d636d;
  --ink-3: #747a84;
  --field: #f4f5f7;
  --field-hover: #eceef1;
  --hover: rgba(15, 23, 42, 0.05);
  --pop: #ffffff;
  --pop-shadow: 0 2px 6px rgba(15, 23, 42, 0.08), 0 12px 32px rgba(15, 23, 42, 0.14);
  --tint: #2f6bff;
  --tint-text: #2459e6;
  --tint-soft: rgba(47, 107, 255, 0.1);
  --danger: #d93a3a;
  --warn: #d99a1f;
  --toast-bg: #1b1d21;
  --toast-ink: #ffffff;
  --toast-act: #8fb1ff;
  --k-sheet: #1fa45b;
  --k-doc: #2f6bff;
  --k-slides: #f2711c;
  --k-pdf: #e5383b;
  --hit: 36px;
  --gut: 24px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1c1d20;
    --ink: #eceef1;
    --ink-2: #a7acb4;
    --ink-3: #8a909a;
    --field: #26272b;
    --field-hover: #2f3136;
    --hover: rgba(255, 255, 255, 0.06);
    --pop: #2e3034;
    --pop-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 14px 36px rgba(0, 0, 0, 0.5);
    --tint-text: #7ba3ff;
    --tint-soft: rgba(91, 141, 255, 0.18);
    --danger: #ff6b66;
    --toast-bg: #eceef1;
    --toast-ink: #1b1d21;
    --toast-act: #2459e6;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #1c1d20;
  --ink: #eceef1;
  --ink-2: #a7acb4;
  --ink-3: #8a909a;
  --field: #26272b;
  --field-hover: #2f3136;
  --hover: rgba(255, 255, 255, 0.06);
  --pop: #2e3034;
  --pop-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 14px 36px rgba(0, 0, 0, 0.5);
  --tint-text: #7ba3ff;
  --tint-soft: rgba(91, 141, 255, 0.18);
  --danger: #ff6b66;
  --toast-bg: #eceef1;
  --toast-ink: #1b1d21;
  --toast-act: #2459e6;
  color-scheme: dark;
}
@media (max-width: 640px), (pointer: coarse) {
  :root { --hit: 44px; }
}
@media (max-width: 640px) {
  :root { --gut: 16px; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: inherit; }
.ic { flex: none; display: block; }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 800px; margin-inline: auto; padding-inline: var(--gut); }

/* ---------- top: brand, actions, search, filters ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding-bottom: 4px; }
.bar { display: flex; align-items: center; gap: 8px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; color: inherit; text-decoration: none; min-width: 0; }
.brand .mark { flex: none; border-radius: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none;
  height: var(--hit); padding: 0 16px; border: 0; border-radius: 10px;
  background: var(--field); color: var(--ink); font-weight: 550; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--field-hover); }
.btn.primary { background: var(--tint); color: #fff; }
.btn.primary:hover { background: #4079ff; }
.btn.text { background: transparent; padding: 0 12px; }
.btn.text:hover { background: var(--hover); }
.btn.tint { color: var(--tint-text); }
.btn.danger { color: var(--danger); }
.btn .ic { margin-left: -2px; }
.icon-btn { display: grid; place-items: center; flex: none; width: var(--hit); height: var(--hit); border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--hover); color: var(--ink); }

.search { position: relative; display: block; }
.search .ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 44px; border: 0; border-radius: 12px; background: var(--field); padding: 0 12px 0 42px; color: var(--ink); outline-offset: 0; }
.search input::placeholder { color: var(--ink-3); }

.filters { display: flex; align-items: center; gap: 8px; min-height: 52px; padding-top: 8px; }
.chips { display: flex; gap: 4px; margin: 0 auto 0 -12px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: var(--hit); padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-weight: 550; }
.chip:hover { background: var(--hover); }
.chip[aria-pressed='true'] { background: var(--tint-soft); color: var(--tint-text); }
.filters .btn.text { margin-right: -12px; color: var(--ink-2); }

.note { display: flex; align-items: center; gap: 8px; padding: 8px 0 0; color: var(--ink-2); font-size: 13px; }
.note::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }

/* ---------- list ---------- */
.list { list-style: none; margin: 8px -8px 0; padding: 0; }
.row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-radius: 12px; }
.row:hover, .row.menu-open { background: var(--hover); }
.row-main {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; column-gap: 16px; align-items: center;
  min-height: 56px; padding: 12px 8px; border-radius: 12px; color: inherit; text-decoration: none; min-width: 0;
}
.row-main:focus-visible { outline-offset: -2px; }
.name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.meta { color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { margin-right: 4px; opacity: 0; }
.row:hover .more, .row:focus-within .more, .row.menu-open .more, .more:focus-visible { opacity: 1; }
@media (hover: none) { .more { opacity: 1; } }

.kind {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff; flex: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--kc) 88%, #fff), var(--kc));
}
.k-sheet { --kc: var(--k-sheet); }
.k-doc { --kc: var(--k-doc); }
.k-slides { --kc: var(--k-slides); }
.k-pdf { --kc: var(--k-pdf); }

.editing { grid-template-columns: 32px minmax(0, 1fr); }
.rename {
  width: 100%; min-width: 0; height: 36px; border: 0; border-radius: 8px; padding: 0 8px; margin-left: -8px;
  background: var(--bg); color: var(--ink); font-weight: 500; box-shadow: 0 0 0 2px var(--tint); outline: none;
}

.skel { display: grid; grid-template-columns: 32px 1fr; column-gap: 16px; align-items: center; padding: 12px 8px; }
.skel i { display: block; height: 32px; border-radius: 9px; background: var(--field); }
.skel b { display: block; height: 12px; border-radius: 6px; background: var(--field); width: var(--w, 60%); }
.skel { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

.state { display: grid; justify-items: start; gap: 8px; padding: 64px 0 32px; }
.state .big { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--field); color: var(--ink-3); margin-bottom: 8px; }
.state h2 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.state p { margin: 0; color: var(--ink-2); max-width: 36ch; }
.state .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.state h2, .state p { max-width: 100%; overflow-wrap: anywhere; }

.foot { padding: 32px 0 64px; }
.link { height: var(--hit); padding: 0; border: 0; background: none; color: var(--ink-3); }
.link:hover { color: var(--ink); }

/* ---------- trash + history ---------- */
.crumb { display: flex; align-items: center; height: 64px; }
.crumb .btn { margin-left: -12px; color: var(--ink-2); }
.head { padding-bottom: 16px; }
.head h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head p { margin: 4px 0 0; color: var(--ink-2); }
.trow {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; grid-template-areas: 'k n a'; column-gap: 16px; align-items: center;
  padding: 12px 8px; border-radius: 12px;
}
.trow:hover { background: var(--hover); }
.trow .kind, .trow .vnum { grid-area: k; }
.trow .stack { grid-area: n; min-width: 0; display: grid; }
.trow .acts { grid-area: a; display: flex; gap: 4px; }
.trow .acts .btn { padding: 0 12px; }
.vnum { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--field); color: var(--ink-2); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--tint-soft); color: var(--tint-text); font-size: 12px; font-weight: 600; vertical-align: 1px; }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; align-content: start; justify-items: start; max-width: 360px; margin: 0 auto; padding: 22vh var(--gut) 48px; }
.signin .mark { border-radius: 16px; margin-bottom: 24px; }
.signin h1 { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.signin .sub { margin: 4px 0 32px; color: var(--ink-2); min-height: 22px; }
.signin form { display: grid; gap: 12px; width: 100%; }
.field { position: relative; display: block; }
.field input { width: 100%; height: 48px; border: 0; border-radius: 12px; background: var(--field); padding: 0 52px 0 16px; color: var(--ink); outline-offset: 0; font-size: 16px; }
.field input::placeholder { color: var(--ink-3); }
.field input[aria-invalid='true'] { box-shadow: inset 0 0 0 2px var(--danger); }
.field .icon-btn { position: absolute; right: 2px; top: 2px; width: 44px; height: 44px; }
.signin .btn { height: 48px; width: 100%; border-radius: 12px; font-size: 16px; }
.signin .btn:disabled { opacity: 0.55; cursor: default; }
.err { min-height: 20px; margin: 0; color: var(--danger); font-size: 14px; }
.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--ink-2); }
.splash .mark { border-radius: 14px; }

/* ---------- menu, toast, dialog, drop ---------- */
.menu-backdrop { position: fixed; inset: 0; z-index: 29; }
.menu-backdrop.sheet { background: rgba(0, 0, 0, 0.32); }
.menu { position: fixed; z-index: 30; min-width: 208px; max-width: calc(100vw - 16px); padding: 6px; border-radius: 12px; background: var(--pop); box-shadow: var(--pop-shadow); }
.menu.sheet { left: 0; right: 0; bottom: 0; top: auto !important; min-width: 0; max-width: none; border-radius: 16px 16px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.menu-title { padding: 8px 12px 12px; color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; height: var(--hit); padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; text-decoration: none; font-weight: 500; white-space: nowrap; }
.menu-item .ic { color: var(--ink-2); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item.danger, .menu-item.danger .ic { color: var(--danger); }
.menu-item .kind { width: 24px; height: 24px; border-radius: 7px; }

.toasts { position: fixed; left: 0; right: 0; bottom: 16px; z-index: 40; display: grid; justify-items: center; gap: 8px; padding-inline: 16px; pointer-events: none; padding-bottom: env(safe-area-inset-bottom); }
.toast {
  display: flex; align-items: center; gap: 12px; pointer-events: auto; max-width: min(480px, 100%);
  padding: 8px 8px 8px 16px; min-height: 44px; border-radius: 12px; background: var(--toast-bg); color: var(--toast-ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22); animation: rise 0.18s ease-out;
}
.toast span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.toast button { flex: none; min-height: 36px; min-width: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--toast-act); font-weight: 650; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

dialog.dialog { width: min(380px, calc(100vw - 32px)); padding: 24px; border: 0; border-radius: 16px; background: var(--pop); color: var(--ink); box-shadow: var(--pop-shadow); }
dialog.dialog::backdrop { background: rgba(0, 0, 0, 0.36); }
.dialog h2 { margin: 0 0 8px; font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }
.dialog p { margin: 0 0 24px; color: var(--ink-2); }
.dialog form { display: flex; justify-content: flex-end; gap: 8px; }

.drop { position: fixed; inset: 12px; z-index: 50; display: grid; place-items: center; border-radius: 20px; pointer-events: none; background: color-mix(in srgb, var(--tint) 9%, var(--bg)); box-shadow: inset 0 0 0 2px var(--tint); color: var(--tint-text); font-size: 20px; font-weight: 650; }

/* ---------- phone ---------- */
@media (max-width: 640px) {
  .row-main { grid-template-columns: 32px minmax(0, 1fr); grid-template-areas: 'k n' 'k m'; row-gap: 0; min-height: 64px; }
  .row-main > .kind { grid-area: k; }
  .row-main > .name { grid-area: n; }
  .row-main > .meta { grid-area: m; }
  .more { opacity: 1; }
  .trow { grid-template-columns: 32px minmax(0, 1fr); grid-template-areas: 'k n' '. a'; row-gap: 4px; }
  .trow .acts { margin-left: -12px; }
  .head h1 { font-size: 24px; }
  .state { padding-top: 48px; }
}

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