/* clouds design system: tokens and primitives shared by the app and extensions.
   Apple-inspired: system typography, system colors, vibrancy, hairlines and gentle motion. */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-subtle: #f2f2f7;
  --bg-hover: rgba(0, 0, 0, 0.045);
  --bg-active: rgba(0, 0, 0, 0.08);
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-sidebar: rgba(236, 236, 241, 0.76);
  --glass-menu: rgba(250, 250, 252, 0.82);
  --glass-hud: rgba(28, 28, 30, 0.82);
  --overlay: rgba(0, 0, 0, 0.22);

  /* Lines */
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.16);
  --hairline: 0.5px solid rgba(0, 0, 0, 0.1);

  /* Text */
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-faint: #a1a1a6;

  /* System colors */
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-pressed: #006edb;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --accent-text: #ffffff;
  --focus-ring: rgba(0, 113, 227, 0.4);
  --selection: #0064e1;
  --danger: #e0301e;
  --danger-fill: #ff3b30;
  --danger-soft: rgba(255, 59, 48, 0.1);
  --success: #248a3d;
  --success-fill: #34c759;
  --success-soft: rgba(52, 199, 89, 0.14);
  --warning: #b25000;
  --warning-fill: #ff9f0a;
  --warning-soft: rgba(255, 159, 10, 0.14);

  /* File kinds */
  --k-folder: #3f8de6;
  --k-image: #af52de;
  --k-video: #ff2d55;
  --k-audio: #ff9500;
  --k-pdf: #ff3b30;
  --k-archive: #a2845e;
  --k-code: #30b0c7;
  --k-text: #8e8e93;
  --doc-page: #ffffff;
  --doc-edge: rgba(0, 0, 0, 0.18);
  --doc-fold: #f0f0f3;

  /* Code */
  --code-bg: #ffffff;
  --code-text: #1d1d1f;
  --code-selection: rgba(0, 113, 227, 0.18);
  --tk-comment: #8a8a8e;
  --tk-string: #c41a16;
  --tk-number: #1c00cf;
  --tk-keyword: #9b2393;
  --tk-type: #0b4f79;
  --tk-function: #326d74;
  --tk-constant: #9b2393;
  --tk-tag: #0b4f79;
  --tk-attribute: #815f03;
  --tk-property: #3900a0;
  --tk-heading: #1d1d1f;
  --tk-meta: #643820;
  --tk-variable: #3900a0;

  /* Shape and depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 0 0 0.5px rgba(0, 0, 0, 0.1), 0 24px 70px rgba(0, 0, 0, 0.22);
  --shadow-popover: 0 0 0 0.5px rgba(0, 0, 0, 0.14), 0 10px 32px rgba(0, 0, 0, 0.16);

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Motion */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --spring: cubic-bezier(0.32, 0.72, 0, 1);

  --sidebar: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161618;
    --bg-elevated: #1f1f21;
    --bg-subtle: #1c1c1e;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-active: rgba(255, 255, 255, 0.1);
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.34);
    --glass: rgba(30, 30, 32, 0.72);
    --glass-sidebar: rgba(40, 40, 43, 0.72);
    --glass-menu: rgba(44, 44, 47, 0.84);
    --glass-hud: rgba(60, 60, 64, 0.86);
    --overlay: rgba(0, 0, 0, 0.45);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --hairline: 0.5px solid rgba(255, 255, 255, 0.12);
    --text: #f5f5f7;
    --text-muted: #a1a1a6;
    --text-faint: #6e6e73;
    --accent: #0a84ff;
    --accent-hover: #3395ff;
    --accent-pressed: #0077ed;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --focus-ring: rgba(10, 132, 255, 0.5);
    --selection: #0058d0;
    --danger: #ff6961;
    --danger-fill: #ff453a;
    --danger-soft: rgba(255, 69, 58, 0.16);
    --success: #30d158;
    --success-fill: #30d158;
    --success-soft: rgba(48, 209, 88, 0.16);
    --warning: #ffb340;
    --warning-fill: #ff9f0a;
    --warning-soft: rgba(255, 159, 10, 0.16);
    --doc-page: #3a3a3c;
    --doc-edge: rgba(255, 255, 255, 0.16);
    --doc-fold: #48484a;
    --code-bg: #1f1f21;
    --code-text: #e5e5ea;
    --code-selection: rgba(10, 132, 255, 0.3);
    --tk-comment: #7f8c98;
    --tk-string: #fc6a5d;
    --tk-number: #d0bf69;
    --tk-keyword: #fc5fa3;
    --tk-type: #5dd8ff;
    --tk-function: #67b7a4;
    --tk-constant: #fc5fa3;
    --tk-tag: #5dd8ff;
    --tk-attribute: #d9c97c;
    --tk-property: #a167e6;
    --tk-heading: #ffffff;
    --tk-meta: #fd8f3f;
    --tk-variable: #a167e6;
    --shadow-sm: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 24px 70px rgba(0, 0, 0, 0.55);
    --shadow-popover: 0 0 0 0.5px rgba(255, 255, 255, 0.14), 0 10px 32px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161618;
  --bg-elevated: #1f1f21;
  --bg-subtle: #1c1c1e;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);
  --fill: rgba(118, 118, 128, 0.24);
  --fill-strong: rgba(118, 118, 128, 0.34);
  --glass: rgba(30, 30, 32, 0.72);
  --glass-sidebar: rgba(40, 40, 43, 0.72);
  --glass-menu: rgba(44, 44, 47, 0.84);
  --glass-hud: rgba(60, 60, 64, 0.86);
  --overlay: rgba(0, 0, 0, 0.45);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --hairline: 0.5px solid rgba(255, 255, 255, 0.12);
  --text: #f5f5f7;
  --text-muted: #a1a1a6;
  --text-faint: #6e6e73;
  --accent: #0a84ff;
  --accent-hover: #3395ff;
  --accent-pressed: #0077ed;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --focus-ring: rgba(10, 132, 255, 0.5);
  --selection: #0058d0;
  --danger: #ff6961;
  --danger-fill: #ff453a;
  --danger-soft: rgba(255, 69, 58, 0.16);
  --success: #30d158;
  --success-fill: #30d158;
  --success-soft: rgba(48, 209, 88, 0.16);
  --warning: #ffb340;
  --warning-fill: #ff9f0a;
  --warning-soft: rgba(255, 159, 10, 0.16);
  --doc-page: #3a3a3c;
  --doc-edge: rgba(255, 255, 255, 0.16);
  --doc-fold: #48484a;
  --code-bg: #1f1f21;
  --code-text: #e5e5ea;
  --code-selection: rgba(10, 132, 255, 0.3);
  --tk-comment: #7f8c98;
  --tk-string: #fc6a5d;
  --tk-number: #d0bf69;
  --tk-keyword: #fc5fa3;
  --tk-type: #5dd8ff;
  --tk-function: #67b7a4;
  --tk-constant: #fc5fa3;
  --tk-tag: #5dd8ff;
  --tk-attribute: #d9c97c;
  --tk-property: #a167e6;
  --tk-heading: #ffffff;
  --tk-meta: #fd8f3f;
  --tk-variable: #a167e6;
  --shadow-sm: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 0 0 0.5px rgba(255, 255, 255, 0.12), 0 24px 70px rgba(0, 0, 0, 0.55);
  --shadow-popover: 0 0 0 0.5px rgba(255, 255, 255, 0.14), 0 10px 32px rgba(0, 0, 0, 0.5);
}

/* Base ------------------------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.43 var(--font);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  -webkit-user-select: none;
  user-select: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.022em;
}

::selection {
  background: var(--code-selection);
}

:focus {
  outline: none;
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--fill-strong) transparent;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-thumb {
  background: var(--fill-strong);
  border: 3px solid transparent;
  border-radius: 10px;
  background-clip: content-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 17px;
  height: 17px;
  flex: none;
}

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  flex: none;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  opacity: 0.7;
  animation: spin 0.75s linear infinite;
}

.spinner.large {
  width: 26px;
  height: 26px;
  border-width: 2.5px;
  color: var(--text-faint);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.985);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

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

/* Buttons ----------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--fill);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: default;
  text-decoration: none;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease), opacity 0.15s;
}

.btn:hover {
  background: var(--fill-strong);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  background: var(--accent-pressed);
}

.btn-danger {
  background: var(--danger-fill);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-fill);
  filter: brightness(1.06);
}

.btn-ghost,
.btn-plain {
  background: transparent;
}

.btn-ghost {
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-plain {
  color: var(--accent);
  padding: 0 8px;
}

.btn-plain:hover {
  background: var(--accent-soft);
}

.btn-icon {
  width: 32px;
  padding: 0;
}

.btn-sm {
  height: 26px;
  padding: 0 10px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-sm.btn-icon {
  width: 26px;
  padding: 0;
}

.btn-large {
  height: 44px;
  font-size: 15px;
  border-radius: 12px;
}

.btn-block {
  width: 100%;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 9px;
  background: var(--fill);
}

.seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  min-width: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.15s var(--ease), color 0.15s, box-shadow 0.15s;
}

.seg:hover {
  color: var(--text);
}

.seg.active {
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.12);
}

.seg .icon {
  width: 16px;
  height: 16px;
}

.segmented.small .seg {
  height: 22px;
  min-width: 26px;
  padding: 0 7px;
  font-size: 12px;
}

.segmented.small .icon {
  width: 14px;
  height: 14px;
}

/* Forms --------------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label,
.label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
}

.input,
.select {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: var(--fill);
  color: var(--text);
  font-size: 14px;
  transition: box-shadow 0.15s var(--ease), background-color 0.15s;
}

.input::placeholder {
  color: var(--text-faint);
}

.input:focus,
.select:focus {
  background: var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--focus-ring);
}

.select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.password-input {
  position: relative;
  width: 100%;
}

.password-input input {
  padding-right: 40px;
}

.password-input .reveal {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-faint);
}

.password-input .reveal:hover {
  color: var(--text);
}

.password-input .reveal .icon {
  width: 16px;
  height: 16px;
}

/* Circular selection check (Photos/iCloud style). */
.check {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
}

.check input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
}

.check span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-elevated);
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s var(--spring);
}

.check input:checked + span {
  border-color: var(--accent);
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.2 8.3 2.4 2.4 5.2-5.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 14px no-repeat;
}

.check input:focus-visible + span {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.toggle-row .check span {
  border-radius: 5px;
}

/* iOS switch */
.switch {
  position: relative;
  display: inline-flex;
  flex: none;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  z-index: 1;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 25px;
  border-radius: 13px;
  background: var(--fill-strong);
  transition: background-color 0.25s var(--ease);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
  transition: transform 0.28s var(--spring);
}

.switch input:checked + .switch-track {
  background: var(--success-fill);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(17px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 10px 0;
  color: var(--danger);
  font-size: 13px;
  animation: rise 0.2s var(--ease);
}

.form-error .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
}

.strength {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  margin-top: 8px;
}

.meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}

.meter span {
  height: 4px;
  border-radius: 2px;
  background: var(--fill-strong);
  transition: background-color 0.3s var(--ease);
}

.meter.s0 span:nth-child(-n + 1),
.meter.s1 span:nth-child(-n + 1) {
  background: var(--danger-fill);
}

.meter.s2 span:nth-child(-n + 2) {
  background: var(--warning-fill);
}

.meter.s3 span:nth-child(-n + 3),
.meter.s4 span {
  background: var(--success-fill);
}

.strength-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.strength-problems {
  grid-column: 1 / -1;
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.strength-problems:empty {
  display: none;
}

/* Badges -------------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--fill);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  vertical-align: middle;
}

.badge .icon {
  width: 12px;
  height: 12px;
}

.badge.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 12.5px;
}
/* clouds app: layout and components. Tokens live in clouds-ui/style/base.css. */

.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg);
}

/* Shell ---------------------------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  background: var(--bg-elevated);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 10px 10px;
  background: var(--glass-sidebar);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  border-right: var(--hairline);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 16px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(180deg, #6cb2ff, #1e5ce8);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.35), 0 1px 3px rgba(30, 92, 232, 0.35);
}

.brand-mark .icon {
  width: 16px;
  height: 16px;
  fill: #fff;
  stroke: #fff;
  stroke-width: 1.2;
}

.nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-label {
  padding: 14px 10px 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-faint);
}

.nav-empty {
  margin: 0;
  padding: 2px 10px;
  color: var(--text-faint);
  font-size: 12.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 13.5px;
  transition: background-color 0.12s var(--ease);
}

.nav-item .icon {
  width: 17px;
  height: 17px;
  color: var(--accent);
}

.nav-item:hover {
  background: var(--bg-hover);
}

.nav-item.active {
  background: var(--bg-active);
  font-weight: 500;
}

.nav-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-badge {
  display: grid;
}

.nav-badge .icon {
  width: 13px;
  height: 13px;
  color: var(--text-faint);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: var(--hairline);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 9px;
  color: var(--text);
  transition: background-color 0.12s;
}

.user-chip:hover,
.user-chip.active {
  background: var(--bg-hover);
}

.user-chip > .icon {
  width: 15px;
  height: 15px;
  color: var(--text-faint);
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(180deg, #a1a1a6, #7c7c80);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.avatar.xl {
  width: 72px;
  height: 72px;
  font-size: 30px;
  font-weight: 500;
}

.user-meta {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11.5px;
  color: var(--text-muted);
}

.sidebar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 2px 2px;
}

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-elevated);
}

.scrim,
.nav-toggle {
  display: none;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    z-index: 70;
    inset: 0 auto 0 0;
    width: min(290px, 84vw);
    padding-top: max(14px, env(safe-area-inset-top));
    background: var(--glass-menu);
    transform: translateX(-104%);
    transition: transform 0.35s var(--spring);
    box-shadow: var(--shadow-lg);
  }

  .shell.nav-open .sidebar {
    transform: none;
  }

  .shell.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: var(--overlay);
    animation: fade 0.2s;
  }

  .nav-toggle {
    display: inline-flex;
  }
}

/* Toolbar ------------------------------------------------------------------------------- */

.toolbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-bottom: var(--hairline);
}

.toolbar-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  padding-left: 4px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.tool {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 28px;
  flex: none;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  transition: background-color 0.12s, color 0.12s;
}

.tool:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.tool:active {
  background: var(--bg-active);
}

.tool .icon {
  width: 18px;
  height: 18px;
}

.nav-buttons {
  display: flex;
  gap: 2px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 200px;
  overflow: hidden;
}

.crumb {
  padding: 3px 6px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  transition: background-color 0.12s, color 0.12s;
}

.crumb:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.crumb.current {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.crumb-sep {
  width: 12px;
  height: 12px;
  color: var(--text-faint);
  stroke-width: 2;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search > .icon {
  position: absolute;
  left: 9px;
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}

.search input {
  width: 200px;
  height: 30px;
  padding: 0 28px 0 29px;
  border: 0;
  border-radius: 8px;
  background: var(--fill);
  font-size: 13.5px;
  transition: width 0.3s var(--spring), box-shadow 0.15s, background-color 0.15s;
}

.search input::placeholder {
  color: var(--text-faint);
}

.search input::-webkit-search-cancel-button {
  display: none;
}

.search input:focus {
  width: 260px;
  background: var(--bg-elevated);
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--focus-ring);
}

.search .clear {
  position: absolute;
  right: 3px;
  width: 24px;
  height: 24px;
}

.search .clear .icon {
  width: 13px;
  height: 13px;
}

.dropdown {
  position: relative;
}

.dropdown .btn-primary {
  height: 28px;
  padding: 0 10px 0 11px;
  border-radius: 7px;
  font-size: 13px;
}

.dropdown .btn-primary .icon:last-child {
  width: 12px;
  height: 12px;
  opacity: 0.8;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
}

.toolbar .segmented .seg {
  height: 24px;
  min-width: 30px;
  padding: 0 6px;
}

@media (max-width: 860px) {
  .toolbar {
    flex-wrap: wrap;
    padding: 8px 10px;
  }

  .nav-buttons {
    display: none;
  }

  .search {
    order: 10;
    flex: 1 1 100%;
  }

  .search input,
  .search input:focus {
    width: 100%;
  }

  .hide-mobile {
    display: none;
  }
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 14px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-bottom: var(--hairline);
  flex-wrap: wrap;
  animation: fade 0.15s var(--ease);
}

.selection-bar .count {
  margin-right: 10px;
  padding-left: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.selection-bar .btn {
  height: 28px;
  padding: 0 10px;
  font-size: 13px;
  color: var(--accent);
}

.selection-bar .btn .icon {
  width: 15px;
  height: 15px;
}

/* Content --------------------------------------------------------------------------------- */

.content {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg-elevated);
  -webkit-overflow-scrolling: touch;
}

.loading-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  overflow: hidden;
}

.loading-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 30%;
  background: var(--accent);
  border-radius: 2px;
  animation: indeterminate 1s var(--ease) infinite;
}

@keyframes indeterminate {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(400%);
  }
}

.results-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.results-head strong {
  color: var(--text);
  font-weight: 600;
}

/* List view (Finder) */

.list {
  padding: 0 10px 110px;
}

.list-head,
.row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 180px 90px 32px;
  align-items: center;
  column-gap: 8px;
  padding: 0 8px;
}

.list-head {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 30px;
  margin: 0 -10px 2px;
  padding: 0 18px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: var(--hairline);
}

.list-head .check {
  opacity: 0;
  transition: opacity 0.15s;
}

.list:hover .list-head .check,
.list-head .check:has(input:checked) {
  opacity: 1;
}

.th {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.th:hover {
  color: var(--text);
}

.th .icon {
  width: 11px;
  height: 11px;
  stroke-width: 2.2;
}

.th.right,
.cell-size {
  justify-content: flex-end;
  text-align: right;
}

.row {
  height: 38px;
  border-radius: 8px;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
  transition: background-color 0.08s;
}

.row:nth-child(even of .row) {
  background: color-mix(in srgb, var(--fill) 35%, transparent);
}

.row:hover {
  background: var(--bg-hover);
}

.row.selected,
.row.selected:hover {
  background: var(--selection);
  color: #fff;
}

.row .check {
  opacity: 0;
  transition: opacity 0.15s;
}

.row:hover .check,
.row.selected .check,
.list:has(.row.selected) .row .check {
  opacity: 1;
}

.row.selected .check span {
  border-color: rgba(255, 255, 255, 0.9);
}

.row.selected .check input:checked + span {
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.2 8.3 2.4 2.4 5.2-5.4' fill='none' stroke='%230064e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.name-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.name-link {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 13.5px;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
}

.name-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--text-faint);
  text-underline-offset: 2px;
}

.name-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-size,
.cell-date {
  color: var(--text-muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row.selected .cell-size,
.row.selected .cell-date,
.row.selected .name-sub {
  color: rgba(255, 255, 255, 0.82);
}

.row-menu {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  opacity: 0;
  transition: opacity 0.12s, background-color 0.12s;
}

.row:hover .row-menu,
.row.selected .row-menu,
.row-menu:focus-visible {
  opacity: 0.8;
}

.row-menu:hover {
  background: var(--bg-active);
  opacity: 1;
}

.row-menu .icon {
  width: 16px;
  height: 16px;
}

.link-badge {
  display: grid;
  color: var(--text-faint);
}

.link-badge .icon {
  width: 12px;
  height: 12px;
}

/* File icons */

.ficon {
  display: inline-grid;
  width: 26px;
  height: 26px;
  flex: none;
}

.ficon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.folder-back {
  fill: url(#folder-back);
}

.folder-front {
  fill: url(#folder-front);
  filter: drop-shadow(0 -0.3px 0 rgba(0, 0, 0, 0.06));
}

.folder-shine {
  fill: rgba(255, 255, 255, 0.35);
}

.doc-page {
  fill: var(--doc-page);
  stroke: var(--doc-edge);
  stroke-width: 0.9;
}

.doc-fold {
  fill: var(--doc-fold);
  stroke: var(--doc-edge);
  stroke-width: 0.9;
  stroke-linejoin: round;
}

.doc-band {
  fill: var(--k-text);
}

.doc-band.k-image { fill: var(--k-image); }
.doc-band.k-video { fill: var(--k-video); }
.doc-band.k-audio { fill: var(--k-audio); }
.doc-band.k-pdf { fill: var(--k-pdf); }
.doc-band.k-archive { fill: var(--k-archive); }
.doc-band.k-code { fill: var(--k-code); }

.ficon text {
  fill: #fff;
  font-family: var(--font);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.doc-link {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Icon view */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 6px 4px;
  padding: 18px 16px 110px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px 8px;
  border-radius: 10px;
  cursor: default;
  -webkit-user-select: none;
  user-select: none;
}

.tile-art {
  display: grid;
  place-items: center;
  width: 92px;
  height: 84px;
  border-radius: 8px;
  transition: background-color 0.1s;
}

.tile:hover .tile-art {
  background: var(--bg-hover);
}

.tile.selected .tile-art {
  background: var(--bg-active);
}

.tile .ficon {
  width: 64px;
  height: 64px;
}

.thumb {
  max-width: 80px;
  max-height: 72px;
  border-radius: 4px;
  object-fit: cover;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.14);
  background: var(--fill);
}

.tile-name {
  max-width: 112px;
  padding: 1px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.3;
  text-align: center;
  cursor: default;
}

.tile-name span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.tile.selected .tile-name {
  background: var(--selection);
  color: #fff;
}

.tile-meta {
  font-size: 11px;
  color: var(--text-faint);
  min-height: 14px;
}

.tile .check {
  position: absolute;
  top: 8px;
  left: 12px;
  opacity: 0;
  z-index: 1;
}

.tile:hover .check,
.tile.selected .check,
.tiles:has(.tile.selected) .check {
  opacity: 1;
}

@media (max-width: 860px) {
  .list-head,
  .row {
    grid-template-columns: 28px minmax(0, 1fr) 30px;
  }

  .cell-size,
  .cell-date,
  .th-size,
  .th-date {
    display: none;
  }

  .row {
    height: 48px;
  }

  .row .check,
  .row-menu {
    opacity: 1;
  }

  .ficon {
    width: 30px;
    height: 30px;
  }

  .tiles {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    padding: 12px 8px 110px;
  }
}

/* States */

.state {
  display: grid;
  place-items: center;
  min-height: 50vh;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 55vh;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  animation: fade 0.3s var(--ease);
}

.empty h3 {
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
}

.empty p {
  margin: 0 0 14px;
  max-width: 340px;
  font-size: 13.5px;
}

.empty-icon {
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  color: var(--text-faint);
}

.empty-icon .icon {
  width: 52px;
  height: 52px;
  stroke-width: 1.1;
}

.drop-overlay {
  position: absolute;
  inset: 10px;
  z-index: 20;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
  animation: fade 0.12s;
}

.drop-overlay div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.drop-overlay .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
}

/* Menus (macOS) ------------------------------------------------------------------------- */

.menu {
  position: fixed;
  z-index: 90;
  min-width: 220px;
  padding: 5px;
  border-radius: 10px;
  background: var(--glass-menu);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--shadow-popover);
  animation: pop 0.12s var(--ease);
  transform-origin: top left;
}

.dropdown-menu.menu {
  position: absolute;
  transform-origin: top right;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  white-space: nowrap;
  cursor: default;
}

.menu-item .icon {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.menu-label {
  flex: 1;
}

.menu-shortcut {
  padding-left: 18px;
  color: var(--text-faint);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.menu-tick {
  display: grid;
  place-items: center;
  width: 15px;
}

.menu-tick .icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.4;
  color: var(--text);
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

.menu-item:hover .icon,
.menu-item:hover .menu-shortcut,
.menu-item:focus-visible .icon {
  color: #fff;
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger .icon {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: var(--danger-fill);
  color: #fff;
}

.menu-sep {
  height: 0.5px;
  margin: 5px 9px;
  background: var(--border-strong);
}

.menu-sep:first-child,
.menu-sep:last-child,
.menu-sep + .menu-sep {
  display: none;
}

@media (pointer: coarse) {
  .menu-item {
    height: 40px;
    font-size: 15px;
  }
}

/* Sheets ---------------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--overlay);
  animation: fade 0.18s var(--ease);
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  max-height: calc(100dvh - 32px);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  animation: pop 0.28s var(--spring);
}

.modal.wide {
  width: min(600px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 14px 4px 20px;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-header .btn-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--fill);
}

.modal-header .btn-icon .icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.2;
}

.modal-body {
  padding: 8px 20px 6px;
  overflow: auto;
}

.modal-body p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 13.5px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
}

.modal-footer .btn {
  min-width: 84px;
}

.item-list {
  margin: 0 0 12px;
  padding: 4px 0;
  list-style: none;
  border-radius: var(--radius);
  background: var(--bg-subtle);
  max-height: 180px;
  overflow: auto;
}

.item-list li {
  padding: 5px 12px;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.picker {
  border-radius: var(--radius);
  background: var(--bg-subtle);
  overflow: hidden;
  box-shadow: inset 0 0 0 0.5px var(--border);
}

.picker-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: var(--hairline);
  overflow-x: auto;
}

.picker-list {
  height: 236px;
  overflow: auto;
  padding: 4px;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 13.5px;
}

.picker-row:hover {
  background: var(--bg-hover);
}

.picker-row > .icon:first-child {
  color: var(--k-folder);
}

.picker-row > .icon:last-child {
  width: 13px;
  height: 13px;
  color: var(--text-faint);
}

.picker-row span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-note {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 60px;
  padding: 20px;
  color: var(--text-faint);
  font-size: 13px;
}

/* Quick Look ------------------------------------------------------------------------------ */

.preview {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: rgba(22, 22, 24, 0.9);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  backdrop-filter: blur(40px) saturate(150%);
  color: #f5f5f7;
  animation: fade 0.2s var(--ease);
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 52px;
  padding: 0 12px 0 18px;
  padding-top: env(safe-area-inset-top);
}

.preview-title {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}

.preview-title strong {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-title span {
  font-size: 11.5px;
  color: rgba(245, 245, 247, 0.6);
}

.preview .btn {
  height: 30px;
  background: rgba(255, 255, 255, 0.1);
  color: #f5f5f7;
}

.preview .btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.preview .btn-primary {
  background: #0a84ff;
}

.preview-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px 72px 36px;
}

.preview-stage img,
.preview-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
  animation: pop 0.35s var(--spring);
}

.preview-stage audio {
  width: min(480px, 100%);
}

.preview-stage iframe {
  width: min(1040px, 100%);
  height: 100%;
  border: 0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.preview-text {
  width: min(960px, 100%);
  height: 100%;
  margin: 0;
  padding: 22px 26px;
  overflow: auto;
  border-radius: 12px;
  background: #1f1f21;
  color: #e5e5ea;
  font: 12.5px/1.6 var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 30px 90px rgba(0, 0, 0, 0.5);
}

.preview-none {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: rgba(245, 245, 247, 0.7);
  font-size: 14px;
}

.preview-none .ficon {
  width: 110px;
  height: 110px;
}

.preview-none p {
  margin: 0;
}

.preview-nav {
  position: absolute;
  top: 50%;
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  transform: translateY(-50%);
}

.preview-nav.prev {
  left: 16px;
}

.preview-nav.next {
  right: 16px;
}

@media (max-width: 860px) {
  .preview-stage {
    padding: 0 8px 16px;
  }

  .preview-nav {
    display: none !important;
  }
}

/* Extensions ------------------------------------------------------------------------------ */

.ext-layer {
  position: fixed;
  inset: 0;
  z-index: 82;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  animation: pop 0.25s var(--spring);
}

.ext-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 8px 0 14px;
  padding-top: env(safe-area-inset-top);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  border-bottom: var(--hairline);
}

.ext-icon,
.extension-icon,
.mini-icon {
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 6px;
  background: linear-gradient(180deg, #b389ff, #7b4ce0);
  color: #fff;
}

.ext-icon {
  width: 22px;
  height: 22px;
}

.ext-icon .icon {
  width: 14px;
  height: 14px;
}

.ext-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
}

.ext-title strong {
  font-weight: 600;
}

.ext-title span {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.ext-sandbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 11.5px;
  font-weight: 600;
}

.ext-sandbox .icon {
  width: 13px;
  height: 13px;
}

.ext-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--bg-elevated);
}

/* Uploads --------------------------------------------------------------------------------- */

.uploads {
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  width: min(360px, calc(100vw - 24px));
  border-radius: var(--radius-lg);
  background: var(--glass-menu);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  backdrop-filter: saturate(180%) blur(30px);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  animation: pop 0.3s var(--spring);
  transform-origin: bottom right;
}

.uploads-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 8px 8px 14px;
}

.uploads-title {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.uploads-title .icon.ok {
  width: 16px;
  height: 16px;
}

.uploads-head .btn-ghost .icon {
  width: 14px;
  height: 14px;
}

.uploads.collapsed .uploads-head .btn-ghost:first-of-type .icon {
  transform: rotate(180deg);
}

.uploads-progress {
  height: 2px;
  margin: 0 14px;
  border-radius: 1px;
  background: var(--fill);
  overflow: hidden;
}

.uploads-progress div,
.bar div {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s var(--ease);
}

.uploads-conflicts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 10px 2px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warning-soft);
  animation: rise 0.2s var(--ease);
}

.uploads-conflicts-text {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
}

.uploads-conflicts-text .icon {
  width: 15px;
  height: 15px;
}

.uploads-conflicts-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.uploads-list {
  max-height: 290px;
  margin: 0;
  padding: 4px 0 6px;
  list-style: none;
  overflow: auto;
}

.uploads.collapsed .uploads-list,
.uploads.collapsed .uploads-conflicts {
  display: none;
}

.upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 14px;
}

.upload-info {
  flex: 1;
  min-width: 0;
}

.upload-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-status {
  font-size: 11.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-row.failed .upload-status {
  color: var(--danger);
}

.bar {
  height: 3px;
  margin-top: 5px;
  border-radius: 2px;
  background: var(--fill);
  overflow: hidden;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.upload-actions .btn-sm {
  color: var(--accent);
}

.icon.ok {
  color: var(--success-fill);
}

/* Toasts (HUD) ---------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: min(480px, calc(100vw - 32px));
  padding: 9px 8px 9px 14px;
  border-radius: 14px;
  background: var(--glass-hud);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  color: #f5f5f7;
  font-size: 13.5px;
  box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  animation: pop 0.35s var(--spring);
}

.toast > .icon {
  width: 16px;
  height: 16px;
  color: #a1a1a6;
}

.toast.success > .icon {
  color: #30d158;
}

.toast.error > .icon {
  color: #ff6961;
}

.toast-close {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(245, 245, 247, 0.55);
}

.toast-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.toast-close .icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}

/* Pages ----------------------------------------------------------------------------------- */

.page {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.page-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 24px 90px;
}

.page-inner.narrow {
  max-width: 640px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 26px;
  font-weight: 700;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
}

/* Grouped lists (System Settings) */

.profile {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0 26px;
}

.profile h1 {
  font-size: 24px;
  font-weight: 700;
}

.profile p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.group-section {
  margin-bottom: 26px;
}

.group-title,
.group-title-row {
  margin: 0 0 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.005em;
}

.group-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-right: 4px;
}

.group-title-row .group-title {
  margin: 0;
}

.group {
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.group-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 13.5px;
}

.group-row + .group-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  border-top: var(--hairline);
}

.group-row.stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.group-row.stacked label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

.group-row.actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.group-row.actions .form-error {
  flex-basis: 100%;
  margin: 0;
}

.group-row.center {
  justify-content: center;
}

.row-label {
  color: var(--text);
}

.row-label.with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-icon {
  width: 22px;
  height: 22px;
}

.mini-icon .icon {
  width: 13px;
  height: 13px;
}

.row-value {
  color: var(--text-muted);
  text-align: right;
}

.group-caption {
  margin: 7px 14px 0;
  font-size: 12px;
  color: var(--text-muted);
}

.input.plain {
  height: 34px;
}

.group-row.device {
  justify-content: flex-start;
  gap: 12px;
}

.device-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--fill);
  color: var(--text-muted);
}

.grow {
  flex: 1;
  min-width: 0;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.row-detail {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-tiles {
  justify-content: flex-start;
  gap: 18px;
  padding: 16px;
}

.theme-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 12.5px;
}

.theme-preview {
  position: relative;
  display: flex;
  width: 96px;
  height: 62px;
  padding: 7px;
  gap: 5px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.15s;
}

.theme-tile.active .theme-preview {
  box-shadow: 0 0 0 3px var(--accent);
}

.theme-tile.active .theme-label {
  font-weight: 600;
}

.theme-preview.light {
  background: #e9e9ee;
}

.theme-preview.dark {
  background: #2a2a2d;
}

.theme-preview.auto {
  background: linear-gradient(115deg, #e9e9ee 50%, #2a2a2d 50%);
}

.tp-sidebar {
  width: 22px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.5);
}

.dark .tp-sidebar {
  background: rgba(255, 255, 255, 0.08);
}

.tp-window {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border-radius: 3px;
  background: #fff;
}

.dark .tp-window {
  background: #1f1f21;
}

.auto .tp-window {
  background: linear-gradient(115deg, #fff 58%, #1f1f21 58%);
}

.tp-bar {
  height: 5px;
  width: 60%;
  border-radius: 2px;
  background: #0071e3;
}

.tp-line {
  height: 3px;
  border-radius: 2px;
  background: rgba(128, 128, 128, 0.35);
}

.tp-line.short {
  width: 60%;
}

/* Panels (admin) */

.panel {
  margin-bottom: 16px;
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 0;
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 600;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.panel-body {
  padding: 14px 18px 16px;
}

.panel-body.flush {
  padding: 10px 0 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--text);
  font-size: 13px;
}

.banner > .icon {
  color: var(--warning);
  margin-top: 1px;
}

.banner.info {
  background: var(--accent-soft);
}

.banner.info > .icon {
  color: var(--accent);
}

.banner strong {
  font-weight: 600;
}

.generated {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 8px 8px 12px;
  border-radius: 9px;
  background: var(--fill);
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
}

.generated code {
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  padding: 6px 18px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: var(--hairline);
  white-space: nowrap;
}

.table td {
  padding: 10px 18px;
  border-bottom: var(--hairline);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background-color 0.1s;
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table .actions {
  text-align: right;
  white-space: nowrap;
}

.table .actions .btn-ghost {
  opacity: 0.6;
}

.table tr:hover .actions .btn-ghost {
  opacity: 1;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
}

.who .avatar {
  width: 32px;
  height: 32px;
}

.access-grid {
  border-radius: 10px;
  background: var(--bg-subtle);
  box-shadow: inset 0 0 0 0.5px var(--border);
  overflow: hidden;
}

.access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 12px;
}

.access-row + .access-row {
  border-top: var(--hairline);
}

.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13.5px;
}

.vol .icon {
  color: var(--accent);
}

.extension-card .panel-head {
  align-items: flex-start;
}

.extension-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.extension-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.4);
}

.extension-icon .icon {
  width: 24px;
  height: 24px;
}

.extension-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding-left: 58px;
}

@media (max-width: 700px) {
  .extension-meta {
    grid-template-columns: 1fr;
    padding-left: 0;
  }
}

.plain-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.plain-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.plain-list .icon {
  width: 13px;
  height: 13px;
  color: var(--text-faint);
}

.extension-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 0 0 58px;
  border-top: var(--hairline);
}

/* Sign in --------------------------------------------------------------------------------- */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(1000px 600px at 20% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    radial-gradient(800px 500px at 90% 100%, color-mix(in srgb, #af52de 7%, transparent), transparent 70%),
    var(--bg);
}

.auth-card {
  width: min(360px, 100%);
  animation: rise 0.5s var(--spring);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-bottom: 26px;
  text-align: center;
}

.app-icon {
  width: 84px;
  height: 84px;
  margin-bottom: 10px;
  filter: drop-shadow(0 8px 18px rgba(30, 92, 232, 0.28));
}

.auth-brand h1 {
  font-size: 26px;
  font-weight: 700;
}

.auth-brand p {
  margin: 0;
  color: var(--text-muted);
  font-size: 15px;
}

.field-group {
  border-radius: 12px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.field-group:focus-within {
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--focus-ring);
}

.field-group.invalid {
  animation: shake 0.4s var(--ease);
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

.group-input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
}

.group-input::placeholder {
  color: var(--text-faint);
}

.field-group > * + * {
  border-top: var(--hairline);
}

.auth-card .form-error {
  justify-content: center;
}

.auth-card .btn-primary {
  margin-top: 16px;
}

.auth-footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 20px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.auth-footnote .icon {
  width: 12px;
  height: 12px;
}
