/* ==========================================================================
   Components — buttons, fields, chips, badges, avatars, cards, lists, menus,
   dialogs, drawers, toasts, tabs, empty states, skeletons.
   ========================================================================== */

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--r-md); border: 1px solid transparent; font-size: 14px; font-weight: 500; line-height: 1;
  white-space: nowrap; user-select: none; position: relative;
}
.btn-sm { height: 32px; padding: 0 12px; gap: 6px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { height: 48px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--olive); border-color: var(--olive); color: var(--on-olive);
  box-shadow: inset 0 1px 0 #ffffff59, 0 1px 2px #2a2a2a1f; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.04); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--e-1); }
.btn-secondary:hover:not(:disabled) { border-color: var(--line-strong); background: var(--hover); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--line); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 40%, transparent); }
.btn-danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-solid:hover:not(:disabled) { filter: brightness(1.06); }
.btn-dark { background: var(--ink); color: var(--surface); }
.btn-dark:hover:not(:disabled) { opacity: .9; }
.btn-ghost { color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; }
.btn-primary:disabled { opacity: 1; background: color-mix(in oklab, var(--olive) 45%, var(--page)); border-color: transparent;
  color: color-mix(in oklab, var(--on-olive) 55%, transparent); box-shadow: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in oklab, var(--ink) 25%, transparent); border-top-color: var(--ink);
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { border-color: #2a2a2a40; border-top-color: #2a2a2a; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm); color: var(--muted);
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.icon-btn-sm { width: 28px; height: 28px; }
.icon-btn-lg { width: 40px; height: 40px; border-radius: var(--r-md); }
.icon-btn.on-rail { color: var(--rail-muted); }
.icon-btn.on-rail:hover { background: #ffffff12; color: var(--rail-ink); }

.link { font-weight: 500; color: var(--olive-ink); }
.link:hover { text-decoration: underline; }
.link-muted { color: var(--muted); font-weight: 500; }
.link-muted:hover { color: var(--ink); }

/* ---- Fields ------------------------------------------------------------ */
.field + .field { margin-top: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row + .field, .field + .field-row { margin-top: 16px; }
.label { display: block; margin-bottom: 8px; font-size: var(--fs-label); font-weight: 500; letter-spacing: .012em; color: var(--ink); }
.label .opt { color: var(--faint); font-weight: 400; }
.hint { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.error-text { margin-top: 8px; font-size: 13px; color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.error-text .i { margin-top: 2px; }

.input, .select, .textarea {
  display: block; width: 100%; height: 44px; padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14.5px;
  transition: border-color var(--t-base) ease, box-shadow var(--t-base) ease;
}
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklab, var(--ink) 35%, var(--surface)); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--olive); box-shadow: var(--focus-ring); outline: none; }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input.is-invalid, .is-invalid .input { border-color: color-mix(in oklab, var(--danger) 50%, transparent); box-shadow: 0 0 0 3px var(--danger-soft); }
.input-sm, .select-sm { height: 36px; font-size: 13.5px; border-radius: var(--r-sm); }
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 44px; }
.input-group .input.has-icon { padding-left: 38px; }
.input-group > .i { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.input-group .input-addon { position: absolute; right: 6px; }

.search-field {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--e-1); flex: 1; min-width: 0;
  transition: border-color var(--t-base) ease, box-shadow var(--t-base) ease;
}
.search-field:focus-within { border-color: var(--olive); box-shadow: var(--focus-ring); }
.search-field .i { color: var(--muted); }
.search-field input { flex: 1; min-width: 0; height: 100%; font-size: 14px; outline: none; }

/* Checkbox (custom, keeps native semantics) */
.check { appearance: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong);
  background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; flex-shrink: 0;
  transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease; }
.check:hover { border-color: color-mix(in oklab, var(--ink) 40%, var(--surface)); }
.check::after { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-olive); border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform var(--t-fast) var(--ease-out); }
.check:checked { background: var(--olive); border-color: var(--olive); }
.check:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check:indeterminate { background: var(--olive); border-color: var(--olive); }
.check:indeterminate::after { width: 8px; height: 0; border-width: 0 0 2px; transform: none; }
.check:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.check-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; }
.check-row .check { margin-top: 1px; }

/* Toggle */
.toggle { appearance: none; position: relative; width: 44px; height: 26px; border-radius: 999px; cursor: pointer; flex-shrink: 0;
  background: color-mix(in oklab, var(--ink) 16%, var(--surface)); transition: background-color var(--t-base) ease; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px #00000040; transition: transform var(--t-slow) var(--ease-out); }
.toggle:checked { background: var(--olive); }
.toggle:checked::after { transform: translateX(18px); }
.toggle:disabled { opacity: .5; cursor: not-allowed; }
.toggle:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Segmented control (role / tabs / filters) */
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-tile); background: var(--chip); max-width: 100%; overflow-x: auto; }
.segmented > * { position: relative; height: 32px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.segmented > *:hover { color: var(--ink); }
.segmented > [aria-selected="true"], .segmented > [aria-current="page"], .segmented > .is-active,
.segmented label input:checked + span {
  background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px #00000014, 0 0 0 .5px var(--line);
}
.segmented-sm > * { height: 28px; padding: 0 10px; font-size: 12.5px; }
.segmented label { padding: 0; height: auto; }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span { height: 32px; padding: 0 12px; border-radius: 8px; display: inline-flex; align-items: center; cursor: pointer; }
.segmented label input:focus-visible + span { box-shadow: var(--focus-ring); }

/* Choice chips (multi-select pills) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap;
}
.chip:hover { border-color: var(--line-strong); }
.chip .count { font-size: 12px; color: var(--muted); font-weight: 500; }
.chip[aria-current="page"], .chip.is-active { background: var(--ink); color: var(--surface); border-color: transparent; }
.chip[aria-current="page"] .count, .chip.is-active .count { color: color-mix(in oklab, var(--surface) 70%, transparent); }
.chip.is-on { background: var(--olive); border-color: var(--olive); color: var(--on-olive); }

/* ---- Badges ------------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1; letter-spacing: .01em; white-space: nowrap; }
.badge-sm { height: 20px; padding: 0 8px; font-size: 11px; }
.badge-olive { background: var(--olive-soft); color: var(--olive-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-outline { border: 1px solid var(--line); color: var(--muted); }
.badge-neutral { background: var(--chip); color: var(--ink); }
.badge-solid { background: var(--olive); color: var(--on-olive); }

.access { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; min-width: 0; }
.access.is-on { color: var(--ink); }
.access.is-on .i { color: var(--olive-ink); }
.access.is-off { color: var(--muted); font-weight: 400; }
.access.is-off .i { color: var(--faint); }

/* ---- Avatars ------------------------------------------------------------ */
.avatar { display: inline-grid; place-items: center; flex-shrink: 0; border-radius: 50%; font-weight: 600; letter-spacing: .02em;
  width: 32px; height: 32px; font-size: 11.5px; user-select: none; }
.avatar-xs { width: 22px; height: 22px; font-size: 10px; }
.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-xl { width: 64px; height: 64px; font-size: 22px; }
.tone-0 { background: color-mix(in oklab, var(--olive) 26%, var(--surface)); color: var(--olive-ink); }
.tone-1 { background: color-mix(in oklab, var(--ink) 9%, var(--surface)); color: var(--ink); }
.tone-2 { background: color-mix(in oklab, #7d8c6a 22%, var(--surface)); color: var(--ink); }
.tone-3 { background: color-mix(in oklab, #8a8478 20%, var(--surface)); color: var(--ink); }
.avatar.is-disabled { opacity: .5; }
.avatar-stack { display: flex; align-items: center; }
.avatar-stack > * { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack > * + * { margin-left: -6px; }
.avatar-more { background: var(--surface-2); color: var(--muted); }
.avatar-group { background: var(--olive-soft); color: var(--olive-ink); }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-name { display: block; font-size: 14px; font-weight: 600; line-height: 1.3; }
.person-sub { display: block; font-size: 12.5px; color: var(--muted); }

/* ---- Cards ------------------------------------------------------------- */
.card { border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--e-1); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.card-head .sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.content > .card + .card, .stack-cards > .card + .card { margin-top: 24px; }
.admin-dash .card + .card { margin-top: 16px; }
.card-list { padding: 6px; }
@media (min-width: 640px) { .card-pad { padding: 24px; } }

.tile { display: inline-grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: var(--r-tile);
  background: var(--olive-soft); color: var(--olive-ink); }
.tile-sm { width: 32px; height: 32px; border-radius: 9px; }
.tile-md { width: 38px; height: 38px; border-radius: var(--r-md); }
.tile-lg { width: 56px; height: 56px; border-radius: 16px; }
.tile-xl { width: 72px; height: 72px; border-radius: 18px; }
.tile.neutral { background: var(--chip); color: var(--ink); }
.tile.warn { background: var(--warn-soft); color: var(--warn); }
.tile.danger { background: var(--danger-soft); color: var(--danger); }
/* file type tones */
.tile.t-folder { background: var(--olive-soft); color: var(--olive-ink); }
.tile.t-red { background: color-mix(in oklab, var(--t-red) 12%, var(--surface)); color: var(--t-red); }
.tile.t-orange { background: color-mix(in oklab, var(--t-orange) 12%, var(--surface)); color: var(--t-orange); }
.tile.t-blue { background: color-mix(in oklab, var(--t-blue) 12%, var(--surface)); color: var(--t-blue); }
.tile.t-green { background: color-mix(in oklab, var(--t-green) 12%, var(--surface)); color: var(--t-green); }
.tile.t-olive { background: var(--olive-soft); color: var(--olive-ink); }
.tile.t-sage { background: color-mix(in oklab, var(--t-sage) 14%, var(--surface)); color: var(--t-sage); }
.tile.t-amber { background: var(--warn-soft); color: var(--t-amber); }
.tile.t-neutral { background: var(--chip); color: var(--t-neutral); }

.callout { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; border-radius: 12px; padding: 12px 16px; font-size: 13.5px; }
.callout-olive { background: var(--olive-soft); border: 1px solid color-mix(in oklab, var(--olive) 45%, var(--surface)); }
.callout-olive > .i { color: var(--olive-ink); }
.callout-warn { background: var(--warn-soft); }
.callout-warn > .i { color: var(--warn); }
.callout-danger { background: var(--danger-soft); color: var(--danger); }
.callout .grow { min-width: 0; }

.stat { display: flex; align-items: center; gap: 16px; padding: 16px; }
.stat-value { font-size: 24px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.stat-label { font-size: 14px; font-weight: 500; }
.stat-line { display: flex; align-items: baseline; gap: 8px; }
.stat-sub { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.kpi { padding: 16px 20px; }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.kpi-label { margin-top: 8px; font-size: 13.5px; font-weight: 500; }
.kpi-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.danger { color: var(--danger); }

.meter { height: 6px; border-radius: 999px; background: color-mix(in oklab, var(--ink) 8%, var(--surface)); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--olive); transition: width var(--t-slow) var(--ease); }
.meter.is-warn > span { background: #d9a23a; }
.meter.is-full > span { background: var(--danger); }

/* ---- Generic list table (rows without borders, rounded hover) ---------- */
.list { padding: 6px; }
.list-head, .list-row { display: grid; align-items: center; column-gap: 16px; padding: 0 12px; }
.list-head { padding-top: 6px; padding-bottom: 8px; font-size: var(--fs-label); font-weight: 500; letter-spacing: .012em; color: var(--muted); }
.list-head .sort { display: inline-flex; align-items: center; gap: 4px; height: 26px; border-radius: 6px; color: var(--muted); }
.list-head .sort:hover, .list-head .sort.is-active { color: var(--ink); }
.list-head .sort .i { opacity: .8; }
.list-head .is-right, .list-row .is-right { text-align: right; justify-self: end; }
.list-row { min-height: 56px; padding-top: 8px; padding-bottom: 8px; border-radius: 12px; font-size: 13px; color: var(--muted);
  transition: background-color var(--t-fast) ease; }
.list-row.is-link { cursor: pointer; }
.list-row:hover { background: var(--hover); }
.list-row .cell-main { color: var(--ink); min-width: 0; }
.list-row .cell-title { font-size: 14px; font-weight: 500; color: var(--ink); }
.list-row .cell-title.strong { font-weight: 600; }
.list-row.is-dim { opacity: .55; }
.list-empty { padding: 48px 16px; text-align: center; font-size: 13.5px; color: var(--muted); }
.list-more { display: flex; justify-content: center; padding: 8px 0 4px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.pager .row { gap: 6px; }

/* ---- Menus (dropdown + context menu) ------------------------------------ */
.menu {
  position: fixed; z-index: 70; min-width: 224px; max-width: min(320px, calc(100vw - 16px)); padding: 6px;
  border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--e-3);
  transform-origin: var(--origin, top left); animation: menu-in 140ms var(--ease-out);
}
@supports (backdrop-filter: blur(1px)) {
  .menu { background: color-mix(in oklab, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); }
}
.menu.is-leaving { animation: menu-out 100ms ease forwards; }
@keyframes menu-in { from { opacity: 0; transform: scale(.96) translateY(-2px); } }
@keyframes menu-out { to { opacity: 0; transform: scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink); text-align: left; white-space: nowrap;
}
.menu-item .i { color: var(--muted); }
.menu-item:hover, .menu-item:focus-visible, .menu-item.is-focused { background: var(--hover); outline: none; }
.menu-item.is-danger, .menu-item.is-danger .i { color: var(--danger); }
.menu-item.is-danger:hover, .menu-item.is-danger:focus-visible { background: var(--danger-soft); }
.menu-item[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.menu-item .shortcut { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.menu-sep { height: 1px; margin: 4px 8px; background: var(--line); }
.menu-head { padding: 8px 10px 10px; }
.menu-head .name { font-size: 13.5px; font-weight: 600; }
.menu-head .sub { font-size: 12.5px; color: var(--muted); }
.menu-label { padding: 8px 10px 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; color: var(--faint); }
.menu .segmented { width: 100%; margin: 2px 0 6px; }
.menu .segmented > * { flex: 1; justify-content: center; }

/* ---- Dialog (centered) -------------------------------------------------- */
/* minmax(0, 1fr): the column never grows past the screen because of wide content inside a dialog. */
.overlay { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-columns: minmax(0, 1fr); place-items: start center; padding: 9vh 12px 24px; overflow-y: auto; }
.overlay-scrim { position: fixed; inset: 0; background: var(--scrim); animation: fade-in 160ms ease; }
.overlay.is-leaving .overlay-scrim { animation: fade-out 140ms ease forwards; }
.dialog {
  position: relative; width: min(560px, 100%); min-width: 0; border-radius: var(--r-xl); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--e-3); animation: dialog-in 200ms var(--ease-out); display: flex; flex-direction: column;
  max-height: calc(100dvh - 9vh - 24px);
}
.dialog.is-sm { width: min(440px, 100%); }
.dialog.is-lg { width: min(720px, 100%); }
.overlay.is-leaving .dialog { animation: dialog-out 140ms ease forwards; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(4px) scale(.99); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 16px; }
.dialog-head .t-title { overflow-wrap: anywhere; }
.dialog-head .sub { margin-top: 4px; font-size: 13px; color: var(--muted); }
.dialog-head .icon-btn { margin: -2px -8px 0 auto; }
.dialog-body { padding: 0 24px 24px; overflow-y: auto; }
.dialog-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.dialog-foot .left { margin-right: auto; }
.dialog-icon { margin-bottom: 16px; }

/* ---- Drawer (right floating panel, as in the mockup) -------------------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 75; }
.drawer-wrap .overlay-scrim { animation: fade-in 180ms ease; }
.drawer {
  position: absolute; top: 8px; right: 8px; bottom: 8px; width: min(var(--drawer-width), calc(100vw - 16px));
  display: flex; flex-direction: column; border-radius: var(--r-xl); border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--e-3); animation: drawer-in 240ms var(--ease-out); overflow: hidden;
}
.drawer.is-wide { width: min(500px, calc(100vw - 16px)); }
.drawer-wrap.is-leaving .drawer { animation: drawer-out 160ms ease forwards; }
.drawer-wrap.is-leaving .overlay-scrim { animation: fade-out 160ms ease forwards; }
@keyframes drawer-in { from { opacity: 0; transform: translateX(24px); } }
@keyframes drawer-out { to { opacity: 0; transform: translateX(16px); } }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 16px; }
.drawer-head .t-title { overflow-wrap: anywhere; }
.drawer-head .sub { margin-top: 4px; font-size: 13px; color: var(--muted); }
.drawer-head .icon-btn { margin: -2px -8px 0 auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 24px 24px; }
.drawer-foot { display: flex; align-items: center; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.drawer-foot .btn-primary { flex: 1; }
.drawer-loading { padding: 24px; }

.kv { border-radius: var(--r-lg); border: 1px solid var(--line); }
.kv > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 12px 16px; font-size: 13.5px; }
.kv > div + div { border-top: 1px solid var(--line); }
.kv dt { color: var(--muted); }
.kv dd { color: var(--ink); overflow-wrap: anywhere; }

/* ---- Tabs (segmented look, mockup style) -------------------------------- */
.tabs { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-tile); background: var(--chip); margin-bottom: 20px; }
.tabs > button { flex: 1; height: 32px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tabs > button:hover { color: var(--ink); }
.tabs > button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px #00000014, 0 0 0 .5px var(--line); }
.tabs .count { font-size: 11.5px; color: var(--faint); }
.tab-panel[hidden] { display: none; }

/* ---- Toasts ------------------------------------------------------------- */
.toasts { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 100; display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; min-height: 44px; max-width: min(92vw, 520px);
  padding: 8px 8px 8px 16px; border-radius: 13px; background: var(--toast); color: var(--toast-ink); font-size: 13.5px;
  font-weight: 500; box-shadow: var(--e-3), 0 0 0 1px #ffffff0f; animation: toast-in 220ms var(--ease-out);
}
.toast.is-leaving { animation: toast-out 160ms ease forwards; }
.toast > .i { color: var(--olive); }
.toast.is-error > .i { color: #e0715c; }
.toast .toast-msg { padding-right: 8px; }
.toast .toast-action { height: 30px; padding: 0 10px; border-radius: 8px; color: var(--olive); font-weight: 600; }
.toast .toast-action:hover { background: #ffffff14; }
.toast .icon-btn { color: #b8bab2; }
.toast .icon-btn:hover { background: #ffffff14; color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@media (max-width: 1023.98px) { .toasts { bottom: calc(var(--tabbar-height) + 12px + env(safe-area-inset-bottom)); } }

/* ---- Empty states -------------------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.empty.is-dashed { margin: 6px; border-radius: 12px; border: 2px dashed var(--line); }
.empty .tile { margin-bottom: 16px; }
.empty-title { font-size: var(--fs-heading); font-weight: 600; letter-spacing: -.01em; }
.empty-text { margin-top: 6px; max-width: 380px; font-size: 13.5px; color: var(--muted); }
.empty-actions { margin-top: 20px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---- Skeleton ------------------------------------------------------------ */
.skel { border-radius: 8px; background: var(--chip); position: relative; overflow: hidden; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--surface) 55%, transparent), transparent);
  animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.skel-tile { width: 38px; height: 38px; border-radius: 10px; }
.skel-line { height: 10px; }
.w-40 { width: 40%; } .w-25 { width: 25%; } .w-15 { width: 15%; } .w-60 { width: 60%; } .w-10 { width: 10%; }

/* Top progress (navigation) */
.nav-progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; z-index: 120; background: var(--olive);
  opacity: 0; transition: width 400ms var(--ease), opacity 200ms ease; }
.nav-progress.is-active { opacity: 1; }

/* ---- Timeline (activity) ------------------------------------------------- */
.timeline-day { margin: 20px 0 8px; font-size: var(--fs-label); font-weight: 500; color: var(--muted); }
.timeline-day:first-child { margin-top: 0; }
.timeline { position: relative; }
.tl-item { position: relative; display: grid; grid-template-columns: 14px 44px minmax(0, 1fr); gap: 8px; padding: 6px 0; font-size: 13.5px; }
.tl-item::before { content: ""; position: absolute; left: 3.5px; top: 22px; bottom: -6px; width: 1px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-dot { margin-top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.tl-dot.is-view { background: var(--olive); }
.tl-dot.is-download { background: var(--t-blue); }
.tl-dot.is-danger { background: var(--danger); }
.tl-time { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.tl-text { color: var(--ink); overflow-wrap: anywhere; }
.tl-text .who { font-weight: 600; }
.tl-text .meta { display: block; font-size: 12px; color: var(--faint); }

/* ---- Stepper ------------------------------------------------------------- */
.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: var(--r-tile); border: 1px solid var(--line); }
.stepper output { width: 32px; text-align: center; font-size: 15px; font-weight: 600; }

/* ---- Settings rows ------------------------------------------------------- */
.setting { display: flex; align-items: center; gap: 16px; padding: 14px 0; }
.setting + .setting { border-top: 1px solid var(--line); }
.setting-title { display: block; font-size: 14px; font-weight: 500; }
.setting-sub { display: block; font-size: 12.5px; color: var(--muted); }
.btn-ghost.danger-text { color: var(--danger); }
.btn-ghost.danger-text:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.dialog-head .t-title, .drawer-head .t-title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.boxed-rows { border-radius: 12px; border: 1px solid var(--line); }
.boxed-rows > * { display: flex; flex-wrap: nowrap; align-items: center; gap: 12px; padding: 14px 16px; }
.boxed-rows > * + * { border-top: 1px solid var(--line); }

/* Popover (filters) */
.popover { width: min(360px, calc(100vw - 16px)); padding: 16px; }
.popover .field + .field { margin-top: 12px; }
.popover-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }

.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-size: 13px; height: 40px; }
.secret { font-family: var(--font-mono); font-size: 15px; letter-spacing: .06em; padding: 12px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px dashed var(--line-strong); text-align: center; user-select: all; overflow-wrap: anywhere; }

.qr { width: 184px; height: 184px; padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: #fff; }
.qr svg { width: 100%; height: 100%; }
.qr svg path { fill: #2a2a2a; }

/* ---- Search palette ------------------------------------------------------ */
.dialog.search-dialog { width: min(640px, 100%); overflow: hidden; }
.palette-head { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-head .i { color: var(--muted); }
.palette-head input { flex: 1; min-width: 0; height: 100%; font-size: 15.5px; outline: none; }
.palette-head input::-webkit-search-cancel-button { display: none; }
.palette-head .kbd { margin-left: 0; }
.palette-results { max-height: 60vh; overflow-y: auto; padding: 8px; }
.palette-hint { padding: 24px 12px; text-align: center; font-size: 13.5px; color: var(--muted); }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; }
.palette-item .name { display: block; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .loc { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .go { color: var(--faint); opacity: 0; transition: opacity var(--t-fast) ease; }
.palette-item:hover, .palette-item.is-focused { background: var(--hover); }
.palette-item.is-focused .go { opacity: 1; }
.palette-item mark { background: color-mix(in oklab, var(--olive) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.palette-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted); background: var(--surface-2); }
.palette-foot a { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); }
.palette-foot a:hover { color: var(--olive-ink); }
.palette-foot .kbd { margin: 0; }
@media (max-width: 639.98px) { .palette-foot span { display: none; } }

/* ---- Password strength ------------------------------------------------------ */
.pw-strength { margin-top: 10px; }
.pw-bar { display: flex; align-items: center; gap: 10px; }
.pw-bar .meter { flex: 1; }
.pw-level { min-width: 64px; text-align: right; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.pw-strength[data-level="0"] .meter > span, .pw-strength[data-level="1"] .meter > span { background: var(--danger); }
.pw-strength[data-level="2"] .meter > span { background: #d9a23a; }
.pw-strength[data-level="0"] .pw-level, .pw-strength[data-level="1"] .pw-level { color: var(--danger); }
.pw-strength[data-level="2"] .pw-level { color: var(--warn); }
.pw-strength[data-level="3"] .pw-level, .pw-strength[data-level="4"] .pw-level { color: var(--olive-ink); }
.pw-rules { display: grid; gap: 4px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--muted); }
.pw-rules li { display: flex; align-items: center; gap: 6px; transition: color var(--t-slow) var(--ease); }
.pw-rules li .i { color: color-mix(in oklab, var(--ink) 18%, var(--surface)); transition: color var(--t-slow) var(--ease); }
.pw-rules li.is-ok { color: var(--ink); }
.pw-rules li.is-ok .i { color: var(--olive-ink); }
.stepper[data-quota-stepper] output { width: auto; min-width: 56px; padding: 0 4px; white-space: nowrap; }
