:root {
  --bg: #141518;
  --surface: #1b1c20;
  --surface-2: #232429;
  --border: #2c2e34;
  --text: #e8e8ea;
  --dim: #9b9ca3;
  --faint: #66676e;

  --ok: #3f9a5f;
  --bad: #d9534c;
  --warn: #c98f16;

  --border-strong: color-mix(in srgb, var(--text) 22%, var(--border));
  --hover: color-mix(in srgb, var(--text) 6%, transparent);
  --focus: color-mix(in srgb, var(--text) 70%, transparent);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.24), 0 8px 24px rgba(0, 0, 0, 0.32);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text', 'Segoe UI', system-ui, Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-md: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.25rem;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;

  --control-h: 36px;
  --control-h-sm: 32px;

  --upload-panel-offset: 0px;

  --android-inset-top: 0px;
  --android-inset-right: 0px;
  --android-inset-bottom: 0px;
  --android-inset-left: 0px;

  --safe-top: max(var(--android-inset-top), env(safe-area-inset-top, 0px));
  --safe-bottom: max(var(--android-inset-bottom), env(safe-area-inset-bottom, 0px));
  --safe-left: max(var(--android-inset-left), env(safe-area-inset-left, 0px));
  --safe-right: max(var(--android-inset-right), env(safe-area-inset-right, 0px));

  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --border: #e4e4e7;
    --text: #18181b;
    --dim: #5f6068;
    --faint: #9b9ca3;
    color-scheme: light;
  }
}

[data-scheme="light"] {
  --ok: #2f8a50;
  --bad: #c9362f;
  --warn: #a8760c;
  --scrim: rgba(24, 24, 27, 0.32);
  --shadow-pop: 0 1px 2px rgba(24, 24, 27, 0.06), 0 8px 24px rgba(24, 24, 27, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 100%;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body { font-size: var(--text-md); }

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

.hidden { display: none !important; }

button {
  font-family: inherit;
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
  min-height: var(--control-h);
  background: var(--surface);
  color: var(--text);
  text-align: center;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:hover { background: var(--surface-2); border-color: var(--border-strong); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

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

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 600;
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--text) 86%, var(--bg));
  border-color: color-mix(in srgb, var(--text) 86%, var(--bg));
}
.btn-primary:disabled:hover { background: var(--text); border-color: var(--text); }

.btn-with-icon, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-ghost svg { color: var(--dim); flex-shrink: 0; }
.btn-ghost:hover svg { color: var(--text); }

.btn-icon {
  border: 1px solid transparent;
  width: var(--control-h-sm);
  height: var(--control-h-sm);
  min-height: 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--dim);
  background: transparent;
}
.btn-icon:hover { color: var(--text); background: var(--hover); border-color: transparent; }
.btn-icon:disabled:hover { color: var(--dim); background: transparent; }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon.active, .btn-icon[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }

.btn-icon.btn-icon-primary { color: var(--bg); background: var(--text); }
.btn-icon.btn-icon-primary:hover { background: color-mix(in srgb, var(--text) 86%, var(--bg)); }
.btn-icon.btn-icon-primary:disabled:hover { background: var(--text); }
.btn-icon.btn-icon-primary .spinner {
  border-color: color-mix(in srgb, var(--bg) 35%, transparent);
  border-top-color: var(--bg);
}

.btn-danger {
  display: block;
  width: 100%;
  margin-top: 8px;
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
  background: transparent;
  color: var(--bad);
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--bad) 8%, transparent);
  border-color: color-mix(in srgb, var(--bad) 60%, var(--border));
}

input[type=password], input[type=text], input[type=url], input[type=number], textarea {
  font-family: inherit;
  font-size: var(--text-md);
  line-height: 1.4;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  width: 100%;
  transition: border-color 0.12s ease;
}
input[type=password], input[type=text], input[type=url], input[type=number] { min-height: var(--control-h); }
input:hover, textarea:hover { border-color: var(--border-strong); }
input[type=password]:focus, input[type=text]:focus, input[type=url]:focus, input[type=number]:focus, textarea:focus {
  border-color: var(--dim);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 10%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; }
textarea[readonly] { color: var(--dim); background: var(--surface-2); }

input[type=checkbox], input[type=radio] { accent-color: var(--text); }

@media (pointer: coarse) {
  input[type=password], input[type=text], input[type=url], input[type=number], textarea { font-size: 16px; }
}

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 28px; height: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.field label .label-hint { color: var(--faint); font-weight: 400; }

.field-hint {
  font-size: var(--text-sm);
  color: var(--dim);
  margin: 6px 0 0;
  line-height: 1.45;
}
.field-hint.error { color: var(--bad); }
.field-hint.warn { color: var(--warn); }

.strength-meter {
  --tier-color: var(--border);
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.strength-segment {
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  flex: 1;
  transition: background-color 0.15s ease;
}
.strength-segment.on { background: var(--tier-color); }
.strength-meter[data-tier="weak"]   { --tier-color: var(--bad); }
.strength-meter[data-tier="fair"]   { --tier-color: var(--warn); }
.strength-meter[data-tier="good"]   { --tier-color: color-mix(in srgb, var(--ok) 70%, var(--warn)); }
.strength-meter[data-tier="strong"] { --tier-color: var(--ok); }

#auth-screen, #share-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) calc(20px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(20px + var(--safe-left));
}

.auth-card { width: 100%; max-width: 360px; }
.share-card { max-width: 380px; }

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 40px;
}
.wordmark svg { flex-shrink: 0; color: var(--text); }
.wordmark img { flex-shrink: 0; display: block; object-fit: contain; width: 22px; height: 22px; }
.wordmark span {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}
[data-scheme="light"] .wordmark img { filter: invert(1); }

.auth-card h1 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 24px;
}
.auth-card p.subtitle {
  color: var(--dim);
  font-size: var(--text-md);
  margin: -16px 0 24px;
  line-height: 1.5;
}

.auth-actions { margin-top: 24px; }
.auth-actions .btn-primary { width: 100%; min-height: 40px; }

.auth-status {
  margin-top: 14px;
  font-size: var(--text-sm);
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
}
.auth-status.error { color: var(--bad); }
.auth-status .spinner { width: 12px; height: 12px; }

.share-status { font-size: var(--text-md); color: var(--dim); }
.share-status.error { color: var(--bad); }
#share-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.share-filename {
  font-weight: 600;
  font-size: var(--text-lg);
  margin: 0;
  word-break: break-word;
}
.share-filesize {
  color: var(--dim);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  margin: -8px 0 8px;
}
#share-body .btn-primary { width: 100%; min-height: 40px; }
#share-body .btn-danger { margin-top: 0; }
#share-body .field-hint { margin-top: 0; }

#app-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: calc(56px + var(--safe-top));
  padding: var(--safe-top) calc(20px + var(--safe-right)) 0 calc(20px + var(--safe-left));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar .wordmark { margin-bottom: 0; }
.topbar .wordmark span { font-size: var(--text-md); }
.topbar .wordmark img { width: 20px; height: 20px; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: flex-end;
}

.usage {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
.usage-pill {
  font-size: var(--text-xs);
  color: var(--dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.usage-meter {
  display: block;
  width: 120px;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.usage-meter-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--dim);
  transition: width 0.4s ease;
}
.usage-meter.is-high .usage-meter-fill { background: var(--bad); }

.settings-wrap { position: relative; }

.settings-menu, .context-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: var(--shadow-pop);
}
.settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 50;
  min-width: 200px;
}
.settings-menu button, .context-menu-item {
  border: none;
  background: transparent;
  min-height: 32px;
  width: 100%;
  padding: 0 10px;
  font-size: var(--text-md);
  font-weight: 400;
  text-align: left;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-menu button:hover, .context-menu-item:hover, .context-menu-item:focus-visible {
  background: var(--hover);
  outline: none;
}
.settings-menu-sep, .context-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
#source-btn svg { flex-shrink: 0; }

main.vault {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 24px calc(120px + var(--safe-bottom));
}

.vault-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.vault-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  min-width: 0;
  flex: 1 1 260px;
  margin-left: -6px;
}
.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  min-height: 32px;
  padding: 0 6px;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--dim);
  border-radius: var(--radius);
  max-width: 280px;
}
.breadcrumb-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumb-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.breadcrumb-item:hover { color: var(--text); background: var(--hover); }
.breadcrumb-item.current { color: var(--text); cursor: default; }
.breadcrumb-item.current:hover { background: transparent; }
.breadcrumb-home:not(.current) span { display: none; }
.breadcrumb-home.current svg { display: none; }
.breadcrumb-item.has-color::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fc);
  flex-shrink: 0;
}
.breadcrumb-sep { display: inline-flex; color: var(--faint); }
.breadcrumb-sep svg { width: 14px; height: 14px; }

.grid-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-label {
  font-size: var(--text-sm);
  color: var(--dim);
  margin: 0 8px 0 0;
  font-variant-numeric: tabular-nums;
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.view-toggle {
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--surface-2);
  flex-shrink: 0;
}
.view-toggle-btn {
  border: none;
  border-radius: var(--radius-sm);
  min-height: 28px;
  width: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  background: transparent;
}
.view-toggle-btn:hover { color: var(--text); background: transparent; }
.view-toggle-btn.active {
  color: var(--text);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}

#select-toggle-btn.active { color: var(--text); background: var(--surface-2); }

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 280px;
  margin-left: auto;
}
.search-bar .search-icon {
  position: absolute;
  left: 10px;
  color: var(--faint);
  pointer-events: none;
}
.search-bar input[type=text] {
  min-height: var(--control-h-sm);
  padding: 6px 32px 6px 32px;
  font-size: var(--text-md);
}
.search-bar .search-clear {
  position: absolute;
  right: 2px;
  width: 28px;
  height: 28px;
  color: var(--faint);
}
.search-bar .search-clear:hover { color: var(--text); }

.selection-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px 4px 4px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  flex-wrap: wrap;
}
.selection-count {
  font-size: var(--text-md);
  font-weight: 500;
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}
#selection-select-all, .selection-cancel {
  min-height: var(--control-h-sm);
  padding: 0 10px;
  font-size: var(--text-sm);
  border-color: transparent;
  background: transparent;
}
#selection-select-all:hover, .selection-cancel:hover { background: var(--hover); }

.grid-sentinel {
  text-align: center;
  color: var(--faint);
  font-size: var(--text-xs);
  padding: 20px 0 4px;
}

.folder-c-red    { --fc: #d0524b; }
.folder-c-orange { --fc: #d27a3a; }
.folder-c-yellow { --fc: #c49a22; }
.folder-c-green  { --fc: #43955f; }
.folder-c-teal   { --fc: #2e968c; }
.folder-c-blue   { --fc: #4a7bd0; }
.folder-c-indigo { --fc: #6870c8; }
.folder-c-purple { --fc: #9064c4; }
.folder-c-pink   { --fc: #c45c8a; }
.folder-c-grey   { --fc: #8b8e96; }

.tone-pdf, .tone-sheet, .tone-text, .tone-code, .tone-archive,
.tone-audio, .tone-video, .tone-image, .tone-other { --tone: var(--dim); }

.ico-back { fill: color-mix(in srgb, currentColor 55%, transparent); }
.ico-front { fill: currentColor; }
.ico-page { fill: color-mix(in srgb, currentColor 10%, transparent); stroke: currentColor; stroke-width: 1.1; stroke-linejoin: round; }
.ico-fold { fill: none; stroke: currentColor; stroke-width: 1.1; stroke-linejoin: round; }

.box-grid {
  --caption-h: 50px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}

.box-tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s ease;
  -webkit-touch-callout: none;
}
.box-tile:hover { border-color: var(--border-strong); }
.box-tile.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 1px var(--text) inset;
}

.box-body {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--caption-h);
}

.box-body img, .box-body video.thumb {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: var(--caption-h);
  width: 100%;
  height: calc(100% - var(--caption-h));
  object-fit: cover;
}

.box-icon {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  background: var(--surface-2);
}
.box-icon svg { width: 40px; height: 40px; }
.box-tile.is-folder .box-icon { color: color-mix(in srgb, var(--dim) 75%, var(--surface-2)); }
.box-tile.has-color .box-icon { color: var(--fc); }
.box-tile[data-thumb="on"] .box-icon { visibility: hidden; }

.box-doc {
  position: relative;
  display: inline-flex;
  color: var(--tone, var(--dim));
}
.box-doc svg { width: 46px; height: 46px; }
.box-ext {
  position: absolute;
  left: 50%;
  bottom: 7px;
  transform: translateX(-50%);
  padding: 2px 4px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--dim);
  box-shadow: 0 0 0 1px var(--border);
  font-size: 0.5625rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box-caption {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.box-name {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.box-meta {
  font-size: var(--text-xs);
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.box-play {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: var(--caption-h);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
}
.box-play svg { width: 34px; height: 34px; }
.box-tile:not([data-thumb="on"]) .box-play { display: none; }

.box-menu {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.box-tile:hover .box-menu, .box-tile:focus-within .box-menu { opacity: 1; }
.box-menu .btn-icon {
  width: 28px;
  height: 28px;
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}
.box-menu .btn-icon:hover { background: var(--surface-2); }
.box-menu .btn-icon svg { width: 14px; height: 14px; }

.box-select-label {
  position: absolute;
  top: 6px; left: 6px;
  z-index: 3;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.12s ease;
  cursor: pointer;
}
.box-tile:hover .box-select-label,
.box-tile.selection-mode .box-select-label,
.box-tile.selected .box-select-label { opacity: 1; }
.box-select-checkbox { width: 15px; height: 15px; margin: 0; cursor: pointer; }

.box-tile.decrypting .box-icon svg { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.file-list { border-top: 1px solid var(--border); }
.file-list-head, .file-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 96px 104px;
  gap: 12px;
  align-items: center;
  padding: 0 8px;
}
.file-list-head {
  min-height: 36px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--dim);
  border-bottom: 1px solid var(--border);
}
.file-list-row {
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: var(--text-md);
  transition: background-color 0.1s ease;
  -webkit-touch-callout: none;
}
.file-list-row:hover, .file-list-row:focus-visible { background: var(--hover); }
.file-list-row:focus-visible { outline-offset: -2px; }
.file-list-row.selected { background: var(--surface-2); }

.file-row-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-row-select {
  display: none;
  width: 18px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.file-list-row:hover .file-row-select,
.file-list-row:focus-within .file-row-select,
.file-list-row.selection-mode .file-row-select,
.file-list-row.selected .file-row-select { display: inline-flex; }
.file-list-row:hover .file-row-icon,
.file-list-row:focus-within .file-row-icon,
.file-list-row.selection-mode .file-row-icon,
.file-list-row.selected .file-row-icon { display: none; }
.file-row-checkbox { width: 15px; height: 15px; margin: 0; cursor: pointer; }
.file-row-icon { color: var(--dim); flex-shrink: 0; display: inline-flex; }
.file-row-icon svg { width: 18px; height: 18px; }
.file-list-row.is-folder .file-row-icon { color: color-mix(in srgb, var(--dim) 75%, var(--surface)); }
.file-list-row.has-color .file-row-icon { color: var(--fc); }
.file-row-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row-count {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.file-row-type, .file-row-size {
  color: var(--dim);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-row-actions-col, .file-row-actions { text-align: right; }
.file-row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.file-list-row:hover .file-row-actions,
.file-list-row:focus-within .file-row-actions { opacity: 1; }
.file-row-actions .btn-icon { width: 28px; height: 28px; }
.file-row-actions .btn-icon svg { width: 15px; height: 15px; }

.empty-state {
  text-align: center;
  padding: 88px 20px 96px;
  color: var(--dim);
}
.empty-state-icon {
  display: block;
  margin: 0 auto;
  width: 24px;
  height: 24px;
  color: var(--faint);
}
.empty-state h3 {
  color: var(--text);
  font-weight: 600;
  font-size: var(--text-lg);
  margin: 14px 0 4px;
}
.empty-state p { margin: 0 auto; max-width: 42ch; font-size: var(--text-md); }
.empty-state #empty-upload-btn { margin-top: 20px; }
.empty-state .empty-state-hint { margin-top: 10px; font-size: var(--text-sm); color: var(--faint); }
.empty-state.is-search #empty-upload-btn,
.empty-state.is-search .empty-state-hint { display: none; }

.context-menu {
  position: fixed;
  z-index: 150;
  min-width: 208px;
  max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
  max-height: calc(100vh - 16px - var(--safe-top) - var(--safe-bottom));
  overflow-y: auto;
}
.context-menu-item svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--dim); }
.context-menu-item.danger, .context-menu-item.danger svg { color: var(--bad); }

.context-menu-colors { padding: 4px 6px 8px; }
.context-menu-label {
  padding: 2px 4px 8px;
  font-size: var(--text-xs);
  color: var(--dim);
}
.context-menu-swatches {
  display: grid;
  grid-template-columns: repeat(6, 20px);
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}
.color-swatch {
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--fc);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.color-swatch:hover { background: var(--fc); }
.color-swatch svg { width: 14px; height: 14px; opacity: 0; }
.color-swatch.is-checked svg { opacity: 1; }
.color-swatch.is-checked { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--fc); }
.color-swatch:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.color-swatch.is-none {
  background: transparent;
  color: var(--faint);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.color-swatch.is-none svg { opacity: 1; width: 16px; height: 16px; }
.color-swatch.is-none.is-checked { color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }

.upload-queue { display: flex; flex-direction: column; gap: 0; }
.upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
}
.upload-row-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.upload-row-icon svg { width: 16px; height: 16px; }
.upload-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upload-row-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.upload-row .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.upload-row .status {
  flex-shrink: 0;
  color: var(--dim);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.upload-row .bar {
  height: 2px;
  border-radius: 1px;
  background: var(--border);
  overflow: hidden;
}
.upload-row .bar-fill {
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.2s ease;
}
.upload-row .upload-cancel { width: 26px; height: 26px; flex-shrink: 0; }
.upload-row .upload-cancel svg { width: 12px; height: 12px; }
.upload-row.is-queued .name { color: var(--dim); }
.upload-row.is-done .bar,
.upload-row.is-error .bar,
.upload-row.is-cancelled .bar { display: none; }
.upload-row.is-done .upload-row-icon { color: var(--ok); }
.upload-row.is-error .upload-row-icon,
.upload-row.is-error .status { color: var(--bad); }
.upload-row.is-cancelled .name,
.upload-row.is-cancelled .status,
.upload-row.is-cancelled .upload-row-icon { color: var(--faint); }
.upload-row.is-cancelled .name { text-decoration: line-through; }
.upload-row.is-retrying .status { color: var(--warn); }
.upload-row.is-retrying .bar-fill { background: var(--warn); }

.upload-panel {
  position: fixed;
  right: calc(20px + var(--safe-right));
  bottom: calc(20px + var(--safe-bottom));
  z-index: 90;
  width: 360px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: upload-panel-in 0.18s ease-out;
}
@keyframes upload-panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.upload-panel-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 8px 11px 14px;
  border-bottom: 1px solid var(--border);
}
.upload-panel.collapsed .upload-panel-head { border-bottom-color: transparent; }
.upload-panel-summary {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.upload-panel-title { font-size: var(--text-md); font-weight: 600; }
.upload-panel-sub {
  font-size: var(--text-xs);
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-panel-head .btn-icon { width: 28px; height: 28px; flex-shrink: 0; }
.upload-panel-toggle svg { transition: transform 0.18s ease; }
.upload-panel.collapsed .upload-panel-toggle svg { transform: rotate(180deg); }
.upload-panel-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
}
.upload-panel-progress-fill {
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.3s ease, background-color 0.3s ease;
}
.upload-panel:not(.is-busy) .upload-panel-progress-fill { background: var(--ok); }
.upload-panel.has-errors:not(.is-busy) .upload-panel-progress-fill { background: var(--bad); }
.upload-panel .upload-queue {
  max-height: min(320px, 48vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px;
  margin: 0;
}
.upload-panel.collapsed .upload-queue { display: none; }

#toasts {
  position: fixed;
  right: calc(20px + var(--safe-right));
  bottom: calc(20px + var(--safe-bottom) + var(--upload-panel-offset));
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  transition: bottom 0.2s ease;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: var(--text-sm);
  line-height: 1.4;
  max-width: 340px;
  box-shadow: var(--shadow-pop);
}
.toast.error { background: var(--bad); color: #fff; }

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  pointer-events: none;
  animation: drop-in 0.12s ease;
}
.drop-overlay::before {
  content: '';
  position: absolute;
  inset: calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
  border: 1.5px dashed var(--dim);
  border-radius: var(--radius-lg);
}
@keyframes drop-in { from { opacity: 0; } to { opacity: 1; } }
.drop-overlay-card { position: relative; text-align: center; }
.drop-overlay-card svg { color: var(--text); width: 28px; height: 28px; }
.drop-overlay-title { margin: 12px 0 4px; font-size: var(--text-lg); font-weight: 600; }
.drop-overlay-sub { margin: 0; font-size: var(--text-md); color: var(--dim); }

#lightbox {
  --lb-pad-top: calc(64px + var(--safe-top));
  --lb-pad-bottom: calc(24px + var(--safe-bottom));
  --lb-pad-x: 32px;
  --lb-meta-reserve: 48px;
  --lb-avail: calc(100vh - var(--lb-pad-top) - var(--lb-pad-bottom));
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 97%, transparent);
  z-index: 100;
  display: flex;
  padding: var(--lb-pad-top) calc(var(--lb-pad-x) + var(--safe-right)) var(--lb-pad-bottom) calc(var(--lb-pad-x) + var(--safe-left));
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
@supports (height: 100dvh) {
  #lightbox { --lb-avail: calc(100dvh - var(--lb-pad-top) - var(--lb-pad-bottom)); }
}
#lightbox > :not(.lightbox-close) { margin: auto; }
#lightbox:focus-visible { outline: none; }
#lightbox.has-nav { --lb-pad-x: 64px; }

#lightbox:has(> .settings-panel),
#lightbox:has(> .share-modal-scroll),
#lightbox:has(> .share-modal) {
  background: var(--scrim);
  --lb-pad-top: calc(48px + var(--safe-top));
}

html:has(#lightbox:not(.hidden)),
html:has(#lightbox:not(.hidden)) body { overflow: hidden; }

.lightbox-close {
  position: fixed;
  top: calc(14px + var(--safe-top)); right: calc(14px + var(--safe-right));
  z-index: 5;
  width: 36px;
  height: 36px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}
.lightbox-close:hover { background: var(--surface-2); border-color: var(--border-strong); }

.lightbox-content {
  position: relative;
  max-width: min(1000px, 100%);
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.lightbox-content > * { flex-shrink: 0; }
.lightbox-content > #lightbox-media { flex-shrink: 1; min-height: 0; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 40px;
  height: 40px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
}
.lightbox-nav:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.lightbox-nav-prev { left: -52px; }
.lightbox-nav-next { right: -52px; }

.lightbox-content img, .lightbox-content video {
  max-width: 100%;
  max-height: 72vh;
  max-height: min(72vh, calc(var(--lb-avail) - var(--lb-meta-reserve)));
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #000;
}

.lightbox-pdf-container {
  width: min(900px, 84vw);
  max-height: 74vh;
  max-height: min(74vh, calc(var(--lb-avail) - var(--lb-meta-reserve) - 52px));
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  display: flex;
  justify-content: center;
}
.lightbox-pdf-canvas { display: block; max-width: 100%; height: auto; }
.lightbox-pdf-pager {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
}
.lightbox-pdf-pager .btn-icon { width: 30px; height: 30px; color: var(--text); }
.lightbox-pdf-pager .btn-icon:disabled { opacity: 0.35; cursor: default; }
.lightbox-pdf-page-indicator {
  font-size: var(--text-sm);
  color: var(--text);
  min-width: 4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.lightbox-content-audio audio { width: min(480px, 84vw); }

.lightbox-text {
  width: min(820px, 88vw);
  max-height: 72vh;
  max-height: min(72vh, calc(var(--lb-avail) - var(--lb-meta-reserve)));
  overflow: auto;
  margin: 0;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}
.editor-preview.lightbox-markdown {
  width: min(820px, 88vw);
  min-height: min(60vh, 520px);
  min-height: min(60vh, 520px, calc(var(--lb-avail) - var(--lb-meta-reserve)));
  max-height: 80vh;
  max-height: min(80vh, calc(var(--lb-avail) - var(--lb-meta-reserve)));
  padding: 28px 32px;
  font-size: 0.9375rem;
  line-height: 1.7;
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.lightbox-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  color: var(--text);
  font-size: var(--text-md);
}
.lightbox-meta .fname {
  color: var(--dim);
  min-width: 0;
  margin-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.lightbox-meta .btn-icon { flex-shrink: 0; }

.lightbox-generic {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 36px 40px;
  max-width: 100%;
  text-align: center;
  color: var(--dim);
}
.lightbox-generic > svg { width: 32px; height: 32px; color: var(--faint); }
.lightbox-generic-name {
  margin: 12px 0 0;
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.lightbox-generic-size { font-size: var(--text-sm); margin: 4px 0 0; font-variant-numeric: tabular-nums; }
.lightbox-generic-note { font-size: var(--text-sm); margin: 12px 0 0; color: var(--dim); }
.lightbox-generic-btn { margin-top: 20px; }
.lightbox-generic-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}
.lightbox-generic-actions .lightbox-generic-btn { margin-top: 0; }

#lightbox-media:fullscreen {
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  object-fit: contain;
  background: #000;
  border-radius: 0;
}
#lightbox-media:-webkit-full-screen {
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  object-fit: contain;
  background: #000;
  border-radius: 0;
}

#lightbox.is-pseudo-fullscreen {
  padding: 0;
  background: #000;
  overflow: hidden;
}
#lightbox.is-pseudo-fullscreen > .lightbox-content {
  position: static;
  margin: 0;
  max-width: none;
  max-height: none;
}
#lightbox.is-pseudo-fullscreen #lightbox-media {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  border-radius: 0;
  background: #000;
}
#lightbox.is-pseudo-fullscreen video#lightbox-media {
  top: var(--safe-top);
  right: var(--safe-right);
  bottom: var(--safe-bottom);
  left: var(--safe-left);
  width: calc(100% - var(--safe-left) - var(--safe-right));
  height: calc(100% - var(--safe-top) - var(--safe-bottom));
}
#lightbox.is-pseudo-fullscreen .lightbox-meta {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 3;
  max-width: none;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 4px;
  text-align: left;
  padding: calc(10px + var(--safe-top)) calc(64px + var(--safe-right)) 28px calc(16px + var(--safe-left));
  background: linear-gradient(rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
  color: #fff;
  pointer-events: none;
}
#lightbox.is-pseudo-fullscreen .lightbox-meta > * { pointer-events: auto; }
#lightbox.is-pseudo-fullscreen .lightbox-meta .fname { flex: 1 1 auto; margin-right: 8px; color: rgba(255, 255, 255, 0.8); }
#lightbox.is-pseudo-fullscreen .lightbox-meta .btn-icon { color: #fff; }
#lightbox.is-pseudo-fullscreen .lightbox-meta .btn-icon:hover { background: rgba(255, 255, 255, 0.12); }
#lightbox.is-pseudo-fullscreen .lightbox-close {
  top: calc(10px + var(--safe-top));
  right: calc(16px + var(--safe-right));
}
#lightbox.is-pseudo-fullscreen .lightbox-nav { position: fixed; z-index: 3; }
#lightbox.is-pseudo-fullscreen .lightbox-nav-prev { left: calc(12px + var(--safe-left)); }
#lightbox.is-pseudo-fullscreen .lightbox-nav-next { right: calc(12px + var(--safe-right)); }

.safe-area-probe {
  position: fixed;
  top: 0; left: 0;
  width: 0; height: 0;
  visibility: hidden;
  pointer-events: none;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  max-height: min(90vh, 100%);
  overflow-y: auto;
  text-align: left;
}
.settings-panel.settings-panel-wide { max-width: 480px; }
.settings-panel h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.settings-panel h3 {
  font-size: var(--text-md);
  font-weight: 600;
  margin: 0 0 6px;
}
.settings-panel p.subtitle {
  color: var(--dim);
  font-size: var(--text-md);
  line-height: 1.5;
  margin: 0 0 20px;
}
.settings-panel .panel-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}
.settings-panel .panel-actions button { min-width: 88px; }
.settings-panel .status-line {
  font-size: var(--text-sm);
  color: var(--dim);
  margin-bottom: 16px;
}
.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0 20px;
}
.settings-panel .cp-progress {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--dim);
}
.settings-panel .cp-progress .spinner { width: 14px; height: 14px; }
.settings-panel .salt-display {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
  margin-bottom: 16px;
}

.move-picker-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 4px;
  padding: 4px;
}
.move-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--text-md);
  color: var(--text);
}
.move-picker-item:hover { background: var(--hover); }
.move-picker-item svg { color: color-mix(in srgb, var(--dim) 75%, var(--surface)); flex-shrink: 0; }
.move-picker-item.has-color svg { color: var(--fc); }

.duress-decoy-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.duress-decoy-section h3 { font-size: var(--text-md); font-weight: 600; margin: 0 0 6px; }
.duress-decoy-section p.subtitle { margin-bottom: 16px; }
.decoy-inline-fields { display: flex; align-items: flex-end; gap: 8px; }
.decoy-inline-fields .field { flex: 1; margin-bottom: 0; }
.decoy-inline-fields button { flex-shrink: 0; white-space: nowrap; }
.duress-decoy-section .upload-queue { margin-top: 12px; margin-bottom: 0; }

.conflict-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 180px;
  overflow-y: auto;
  font-size: var(--text-sm);
  color: var(--dim);
}
.conflict-list li { padding: 4px 0; overflow-wrap: anywhere; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 10px 8px;
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  font-weight: 400;
}
.theme-option:hover { background: transparent; }
.theme-option:focus-visible { outline-offset: 3px; }
.theme-option-preview {
  display: flex;
  height: 36px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-strong);
  transition: box-shadow 0.12s ease;
}
.theme-option:hover .theme-option-preview { box-shadow: 0 0 0 1px var(--dim); }
.theme-option[aria-checked="true"] .theme-option-preview {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}
.theme-option-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 0 8px;
}
.theme-option-line { display: block; width: 100%; height: 2px; border-radius: 1px; opacity: 0.85; }
.theme-option-accent { display: block; width: 55%; height: 2px; border-radius: 1px; }
.theme-option-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  font-size: var(--text-xs);
  line-height: 1.25;
  color: var(--dim);
  text-align: center;
  overflow: hidden;
}
.theme-grid-standard { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.theme-grid-standard .theme-option-name { -webkit-line-clamp: 3; line-clamp: 3; }
.theme-option:hover .theme-option-name { color: var(--text); }
.theme-option[aria-checked="true"] .theme-option-name { color: var(--text); font-weight: 600; }
.settings-panel .theme-group-heading {
  margin: 20px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--dim);
}

.settings-panel.settings-panel-editor {
  max-width: min(960px, 94vw);
  padding-bottom: 0;
}
.settings-panel-editor h2 { font-size: var(--text-sm); font-weight: 500; color: var(--dim); margin-bottom: 2px; }
.settings-panel-editor .panel-actions { justify-content: flex-end; }
.settings-panel-editor .panel-actions button { flex: none; }
.settings-panel-editor label[for="editor-name-input"] { font-size: var(--text-xs); color: var(--faint); }

#editor-name-input {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  margin-left: -4px;
  min-height: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
  box-shadow: none;
}
#editor-name-input:hover { background: var(--hover); }
#editor-name-input:focus { background: var(--hover); box-shadow: none; }

.editor-tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.editor-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--surface-2);
  width: fit-content;
}
.editor-tab {
  border: none;
  border-radius: var(--radius-sm);
  min-height: 28px;
  padding: 0 14px;
  font-size: var(--text-sm);
  color: var(--dim);
  background: transparent;
}
.editor-tab:hover { color: var(--text); background: transparent; }
.editor-tab.active { color: var(--text); background: var(--bg); box-shadow: 0 0 0 1px var(--border); }

#editor-save-btn {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}
#editor-save-btn:hover { background: color-mix(in srgb, var(--text) 86%, var(--bg)); }
#editor-save-btn:disabled:hover { background: var(--text); }
#editor-save-btn .spinner { border-color: color-mix(in srgb, var(--bg) 35%, transparent); border-top-color: var(--bg); }

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  margin: 0;
}
.editor-toolbar .btn-icon { width: 30px; height: 30px; }
.editor-toolbar .btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.editor-toolbar-sep {
  width: 1px;
  height: 16px;
  margin: 0 6px;
  background: var(--border);
}

.field.editor-content-field { margin: 0 -24px; }
.editor-textarea, .editor-preview {
  display: block;
  min-height: 52vh;
  max-height: 62vh;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--bg);
  padding: 20px 24px;
}
.editor-textarea {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.65;
  resize: none;
}
.editor-textarea:hover { border-top-color: var(--border); }
.editor-textarea:focus { box-shadow: none; border-top-color: var(--border); }

.editor-preview {
  overflow-y: auto;
  font-size: var(--text-md);
  line-height: 1.65;
  color: var(--text);
}
.editor-preview > *:first-child { margin-top: 0; }
.editor-preview > *:last-child { margin-bottom: 0; }
.editor-preview h1, .editor-preview h2, .editor-preview h3,
.editor-preview h4, .editor-preview h5, .editor-preview h6 {
  margin: 1.6em 0 0.6em;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.editor-preview h1 { font-size: 1.5rem; }
.editor-preview h2 { font-size: 1.25rem; }
.editor-preview h3 { font-size: 1.0625rem; }
.editor-preview h4, .editor-preview h5, .editor-preview h6 { font-size: 1rem; }
.editor-preview p { margin: 0 0 1em; }
.editor-preview a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--faint); }
.editor-preview a:hover { text-decoration-color: var(--text); }
.editor-preview strong { font-weight: 600; }
.editor-preview em { font-style: italic; }
.editor-preview del { color: var(--dim); }
.editor-preview code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}
.editor-preview pre {
  margin: 0 0 1em;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow-x: auto;
}
.editor-preview pre code { background: none; padding: 0; font-size: var(--text-sm); }
.editor-preview blockquote {
  margin: 0 0 1em;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--border-strong);
  color: var(--dim);
}
.editor-preview blockquote p { margin: 0 0 6px; }
.editor-preview blockquote p:last-child { margin-bottom: 0; }
.editor-preview ul, .editor-preview ol { margin: 0 0 1em; padding-left: 22px; }
.editor-preview li { margin: 4px 0; }
.editor-preview li > input[type=checkbox] { margin-right: 6px; }
.editor-preview hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.editor-preview table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; max-width: 100%; }
.editor-preview th, .editor-preview td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.editor-preview th { background: var(--surface-2); font-weight: 600; }
.editor-preview-empty { color: var(--faint); }

.share-modal-scroll {
  width: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.share-modal {
  width: min(440px, 88vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 24px;
  text-align: left;
  align-items: stretch;
  gap: 0;
}
.share-modal h3 {
  margin: 0 0 6px;
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.share-modal .field-hint { font-size: var(--text-md); margin: 0 0 20px; }
.share-modal .spinner-lg { margin: 8px auto; }
.share-modal p:has(+ .spinner-lg), .share-modal .spinner-lg + p {
  text-align: center;
  color: var(--dim);
  font-size: var(--text-md);
}

.share-section { margin-bottom: 20px; }
.share-section-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  margin: 0 0 8px;
}
.share-section .share-download-count { margin-bottom: 0; }

.share-download-count {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.share-count-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h-sm);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--dim);
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}
.share-count-option:hover { color: var(--text); border-color: var(--border-strong); }
.share-count-option:has(input:checked) {
  border-color: var(--text);
  color: var(--text);
  background: var(--surface-2);
}
.share-count-option:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.share-count-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

#share-count-custom {
  width: 100%;
  margin: 8px 0 0;
}

.share-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  margin: 0 0 16px;
}
.share-summary-item { display: flex; flex-direction: column; gap: 2px; }
.share-summary-item .label { font-size: var(--text-xs); color: var(--dim); }
.share-summary-item .value { font-size: var(--text-md); font-weight: 500; color: var(--text); }

.share-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.12s ease;
}
.share-checkbox-row:hover { border-color: var(--border-strong); }
.share-checkbox-row:has(input:checked) { border-color: var(--dim); }
.share-checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  cursor: pointer;
}
.share-checkbox-text { display: flex; flex-direction: column; gap: 2px; }
.share-checkbox-text strong { font-size: var(--text-md); font-weight: 500; color: var(--text); }
.share-checkbox-text small { font-size: var(--text-sm); color: var(--dim); line-height: 1.45; }

.share-delete-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 8%, transparent);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 16px !important;
  line-height: 1.45;
}
.share-delete-warning-icon { display: flex; flex-shrink: 0; margin-top: 1px; }
.share-delete-warning-icon svg { display: block; width: 16px; height: 16px; }

.share-link-row { display: flex; gap: 8px; margin-top: 4px; }
.share-link-row .btn-primary { flex-shrink: 0; }
.share-link-row:has(#share-create-btn) .btn-primary { flex: 1; }
.share-link-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--surface-2);
}

@media (max-width: 560px) {
  .topbar {
    min-height: calc(52px + var(--safe-top));
    padding: var(--safe-top) calc(14px + var(--safe-right)) 0 calc(14px + var(--safe-left));
    gap: 8px;
  }
  .topbar-right { gap: 8px; }
  .usage-meter { width: 80px; }
  .settings-menu { right: -4px; }

  main.vault { padding: 16px 14px calc(120px + var(--safe-bottom)); }
  .vault-head { margin-bottom: 16px; }
  .breadcrumb { flex-basis: 100%; }
  .breadcrumb-item { font-size: 1.125rem; max-width: 170px; }
  .vault-actions { width: 100%; }
  .vault-actions .btn-ghost { flex: 0 0 auto; padding: 0 11px; }
  .vault-actions .btn-ghost .btn-label { display: none; }
  .vault-actions .btn-primary { flex: 1; }

  .selection-count { width: 100%; padding: 4px 0; margin-right: 0; }
  .grid-toolbar { gap: 6px; }
  .search-bar { max-width: 100%; order: 3; }

  .box-grid { --caption-h: 44px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  .box-caption { padding: 0 9px; }
  .box-icon svg { width: 32px; height: 32px; }
  .box-doc svg { width: 38px; height: 38px; }
  .box-ext { bottom: 6px; font-size: 0.5rem; padding: 1px 3px; }
  .box-name { font-size: var(--text-xs); }
  .box-meta { font-size: 0.6875rem; }
  .box-play svg { width: 28px; height: 28px; }

  .file-list-head, .file-list-row { grid-template-columns: minmax(0, 1fr) 64px 68px; gap: 8px; padding: 0 4px; }
  .file-row-type-col, .file-row-type { display: none; }
  .file-row-count { display: none; }

  .upload-panel {
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    bottom: calc(8px + var(--safe-bottom));
    width: auto;
    max-width: none;
  }
  #toasts { left: calc(12px + var(--safe-left)); right: calc(12px + var(--safe-right)); align-items: stretch; }
  .toast { max-width: none; }

  #lightbox {
    --lb-pad-bottom: calc(14px + var(--safe-bottom));
    --lb-pad-x: 14px;
    --lb-meta-reserve: 96px;
  }
  #lightbox.has-nav { --lb-pad-x: 46px; }
  .lightbox-close { top: calc(10px + var(--safe-top)); right: calc(10px + var(--safe-right)); }
  .lightbox-nav { width: 36px; height: 36px; }
  .lightbox-nav-prev { left: -42px; }
  .lightbox-nav-next { right: -42px; }
  .lightbox-meta { flex-wrap: wrap; justify-content: center; text-align: center; }
  .lightbox-generic { padding: 28px 20px; }

  .settings-panel { padding: 20px; max-width: 100%; }
  .settings-panel.settings-panel-editor { max-height: 100%; padding-bottom: 0; }
  .settings-panel-editor .panel-actions { margin-top: 12px; }
  .field.editor-content-field { margin: 0 -20px; }
  .editor-textarea, .editor-preview { padding: 16px 20px; }
  .editor-tabs-row { margin-bottom: 6px; }
  .editor-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .editor-toolbar::-webkit-scrollbar { display: none; }
  .editor-toolbar .btn-icon { flex-shrink: 0; }
  .editor-toolbar-sep { flex-shrink: 0; }
  .editor-textarea, .editor-preview:not(.lightbox-markdown) { min-height: 30vh; max-height: 40vh; }

  .share-modal { padding: 20px; }

  .auth-card { max-width: 100%; }
  .wordmark { margin-bottom: 32px; }
}

@media (max-width: 420px) {
  .decoy-inline-fields { flex-direction: column; align-items: stretch; }
  .decoy-inline-fields button { width: 100%; }
}

@media (max-width: 380px) {
  .usage-pill { display: none; }
  .box-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
  .box-icon svg { width: 28px; height: 28px; }
  .box-doc svg { width: 32px; height: 32px; }
}

@media (hover: none) {
  .file-row-actions { opacity: 1; }
  .box-select-label { width: 30px; height: 30px; }
  .box-select-checkbox, .file-row-checkbox { width: 18px; height: 18px; }
  .file-list-row:hover .file-row-select { display: none; }
  .file-list-row:hover .file-row-icon { display: inline-flex; }
  .file-list-row.selection-mode .file-row-select,
  .file-list-row.selected .file-row-select { display: inline-flex; }
  .file-list-row.selection-mode .file-row-icon,
  .file-list-row.selected .file-row-icon { display: none; }
  .color-swatch { width: 26px; height: 26px; }
  .context-menu-swatches { grid-template-columns: repeat(6, 26px); gap: 10px; }
}
