/* ============ Yaru design tokens ============ */
:root {
  --yaru-orange: #E95420;
  --yaru-aubergine: #77216F;
  --yaru-mid-aubergine: #5E2750;
  --yaru-dark-aubergine: #2C001E;
  --ubuntu-text-grey: #AEA79F;

  --radius-window: 10px;
  --radius-button: 6px;
  --radius-popover: 12px;
  --topbar-h: 32px;
  --dock-w: 64px;

  --font-ui: "Ubuntu", "Cantarell", "Segoe UI", sans-serif;
  --font-mono: "Ubuntu Mono", "SF Mono", monospace;

  --ease-standard: cubic-bezier(0.4, 0.0, 0.2, 1);
  --ease-decel: cubic-bezier(0.0, 0.0, 0.2, 1);
  --ease-accel: cubic-bezier(0.4, 0.0, 1, 1);
  --dur-fast: 150ms;
  --dur-med: 250ms;
  --dur-slow: 400ms;

  --shadow-window: 0 2px 6px rgba(0,0,0,.25), 0 12px 28px rgba(0,0,0,.35);
  --shadow-window-focused: 0 4px 10px rgba(0,0,0,.3), 0 18px 48px rgba(0,0,0,.5);
  --shadow-popover: 0 3px 8px rgba(0,0,0,.25), 0 10px 30px rgba(0,0,0,.35);
}

:root[data-accent="yaru"]      { --accent: #E95420; --accent-hover: #f0612f; --accent-active: #c7431a; --accent-fg: #ffffff; --accent-subtle: rgba(233,84,32,.25); }
:root[data-accent="blue"]      { --accent: #3584e4; --accent-hover: #4a90e8; --accent-active: #2a6cbd; --accent-fg: #ffffff; --accent-subtle: rgba(53,132,228,.25); }
:root[data-accent="bark"]      { --accent: #786450; --accent-hover: #8a7560; --accent-active: #61503f; --accent-fg: #ffffff; --accent-subtle: rgba(120,100,80,.28); }
:root[data-accent="sage"]      { --accent: #6e9c6e; --accent-hover: #7dab7d; --accent-active: #597f59; --accent-fg: #ffffff; --accent-subtle: rgba(110,156,110,.28); }
:root[data-accent="olive"]     { --accent: #9c9c48; --accent-hover: #abab58; --accent-active: #7f7f3a; --accent-fg: #ffffff; --accent-subtle: rgba(156,156,72,.28); }
:root[data-accent="viridian"]  { --accent: #26a269; --accent-hover: #33b178; --accent-active: #1e8556; --accent-fg: #ffffff; --accent-subtle: rgba(38,162,105,.25); }
:root[data-accent="prussian"]  { --accent: #20609c; --accent-hover: #2a6cab; --accent-active: #1a4e80; --accent-fg: #ffffff; --accent-subtle: rgba(32,96,156,.28); }
:root[data-accent="purple"]    { --accent: #9141ac; --accent-hover: #a04fbe; --accent-active: #76358d; --accent-fg: #ffffff; --accent-subtle: rgba(145,65,172,.25); }
:root[data-accent="magenta"]   { --accent: #c7417b; --accent-hover: #d15389; --accent-active: #a53565; --accent-fg: #ffffff; --accent-subtle: rgba(199,65,123,.25); }
:root[data-accent="red"]       { --accent: #e01b24; --accent-hover: #e6323b; --accent-active: #b7161e; --accent-fg: #ffffff; --accent-subtle: rgba(224,27,36,.25); }

/* dark style (default) */
:root {
  --bg: #242424;
  --bg-raised: #2d2d2d;
  --bg-hover: #383838;
  --bg-active: #424242;
  --base: #1e1e1e;
  --headerbar: #303030;
  --headerbar-backdrop: #2a2a2a;
  --fg: #ffffff;
  --fg-dim: rgba(255,255,255,.55);
  --fg-faint: rgba(255,255,255,.38);
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --card: #303030;
  --card-hover: #383838;
  --view-hover: rgba(255,255,255,.06);
  --view-active: rgba(255,255,255,.1);
  --selection: var(--accent);
  --selection-fg: var(--accent-fg);
  --topbar-bg: rgba(0,0,0,.9);
  --popover-bg: rgba(38,38,38,.96);
  --popover-item-hover: rgba(255,255,255,.08);
  --dock-bg: rgba(0,0,0,.55);
  --osd-bg: rgba(40,40,40,.92);
  --scrollbar-thumb: rgba(255,255,255,.22);
  --scrollbar-thumb-hover: rgba(255,255,255,.38);
  --entry-bg: #1e1e1e;
  --entry-border: rgba(255,255,255,.12);
  --switch-off: #4d4d4d;
  --success: #26a269;
  --warning: #f5c211;
  --error: #c01c28;
  --link: #78aeed;
  --terminal-bg: rgba(23,20,20,.96);
  --terminal-fg: #eeeeec;
  color-scheme: dark;
}

:root[data-style="light"] {
  --bg: #fafafa;
  --bg-raised: #ffffff;
  --bg-hover: #f0f0f0;
  --bg-active: #e6e6e6;
  --base: #ffffff;
  --headerbar: #f5f5f5;
  --headerbar-backdrop: #efefef;
  --fg: #242424;
  --fg-dim: rgba(36,36,36,.6);
  --fg-faint: rgba(36,36,36,.4);
  --border: rgba(0,0,0,.1);
  --border-strong: rgba(0,0,0,.18);
  --card: #ffffff;
  --card-hover: #f2f2f2;
  --view-hover: rgba(0,0,0,.05);
  --view-active: rgba(0,0,0,.09);
  --topbar-bg: rgba(0,0,0,.85);
  --popover-bg: rgba(250,250,250,.97);
  --popover-item-hover: rgba(0,0,0,.06);
  --osd-bg: rgba(250,250,250,.94);
  --scrollbar-thumb: rgba(0,0,0,.25);
  --scrollbar-thumb-hover: rgba(0,0,0,.42);
  --entry-bg: #ffffff;
  --entry-border: rgba(0,0,0,.15);
  --switch-off: #b0b0b0;
  --terminal-bg: rgba(30,27,27,.96);
  color-scheme: light;
}

/* ============ reset & base ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--fg);
  background: #000;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
@font-face { font-family: "Ubuntu"; src: url("../assets/fonts/ubuntu-300.woff2") format("woff2"); font-weight: 300; font-style: normal; }
@font-face { font-family: "Ubuntu"; src: url("../assets/fonts/ubuntu-400.woff2") format("woff2"); font-weight: 400; font-style: normal; }
@font-face { font-family: "Ubuntu"; src: url("../assets/fonts/ubuntu-500.woff2") format("woff2"); font-weight: 500; font-style: normal; }
@font-face { font-family: "Ubuntu"; src: url("../assets/fonts/ubuntu-700.woff2") format("woff2"); font-weight: 700; font-style: normal; }
@font-face { font-family: "Ubuntu"; src: url("../assets/fonts/ubuntu-400i.woff2") format("woff2"); font-weight: 400; font-style: italic; }
@font-face { font-family: "Ubuntu Mono"; src: url("../assets/fonts/ubuntu-mono-400.woff2") format("woff2"); font-weight: 400; }
@font-face { font-family: "Ubuntu Mono"; src: url("../assets/fonts/ubuntu-mono-700.woff2") format("woff2"); font-weight: 700; }

::selection { background: var(--accent); color: var(--accent-fg); }
input, textarea { user-select: text; font-family: inherit; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ============ buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 14px;
  border-radius: var(--radius-button);
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: 14px; font-weight: 400;
  transition: background var(--dur-fast) var(--ease-standard);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { background: var(--bg-active); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.suggested {
  background: var(--accent); border-color: transparent; color: var(--accent-fg); font-weight: 500;
}
.btn.suggested:hover { background: var(--accent-hover); }
.btn.suggested:active { background: var(--accent-active); }
.btn.destructive {
  background: var(--error); border-color: transparent; color: #fff; font-weight: 500;
}
.btn.destructive:hover { background: #d5242f; }
.btn.flat { background: transparent; border-color: transparent; }
.btn.flat:hover { background: var(--view-hover); }
.btn.circular {
  border-radius: 999px; min-height: 0; width: 32px; height: 32px; padding: 0;
}
.btn.link { background: none; border: none; color: var(--link); padding: 0; min-height: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px; border: none;
  background: transparent; color: var(--fg); flex: none;
}
.icon-btn:hover { background: var(--view-hover); }
.icon-btn:active { background: var(--view-active); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn svg { width: 16px; height: 16px; }

/* ============ entries ============ */
.entry {
  min-height: 32px; padding: 4px 10px;
  background: var(--entry-bg);
  border: 1px solid var(--entry-border);
  border-radius: var(--radius-button);
  color: var(--fg); font-size: 14px;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.entry:hover { border-color: var(--border-strong); }
.entry:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.entry::placeholder { color: var(--fg-faint); }

/* ============ switch ============ */
.switch {
  position: relative; width: 44px; height: 24px; flex: none;
  border-radius: 999px; border: none;
  background: var(--switch-off);
  transition: background var(--dur-fast) var(--ease-standard);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4);
  transition: transform var(--dur-fast) var(--ease-standard);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ============ slider ============ */
input[type="range"].slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 24px; background: transparent; cursor: pointer;
}
input[type="range"].slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill,50%), var(--switch-off) var(--fill,50%));
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
input[type="range"].slider::-moz-range-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--fill,50%), var(--switch-off) var(--fill,50%));
}
input[type="range"].slider::-moz-range-thumb {
  width: 18px; height: 18px; border: none;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.5);
}

/* ============ lists / rows ============ */
.list-box {
  background: var(--card);
  border-radius: var(--radius-popover);
  overflow: hidden;
}
.list-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 8px 16px;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row.activatable { cursor: pointer; transition: background var(--dur-fast); }
.list-row.activatable:hover { background: var(--card-hover); }
.list-row.activatable:active { background: var(--view-active); }
.list-row .row-title { font-size: 14px; }
.list-row .row-sub { font-size: 12px; color: var(--fg-dim); margin-top: 1px; }
.list-row .grow { flex: 1; min-width: 0; }

/* ============ dialogs ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4);
  animation: backdrop-in var(--dur-med) var(--ease-decel);
}
.modal {
  min-width: 340px; max-width: 480px;
  background: var(--popover-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  animation: modal-in var(--dur-med) var(--ease-decel);
}
.modal .modal-body { padding: 24px 24px 16px; text-align: center; }
.modal .modal-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal .modal-text { font-size: 14px; color: var(--fg-dim); line-height: 1.5; }
.modal .modal-actions {
  display: flex; border-top: 1px solid var(--border);
}
.modal .modal-actions button {
  flex: 1; min-height: 46px; border: none; background: transparent;
  color: var(--fg); font-size: 14px; font-weight: 500;
  padding: 8px;
}
.modal .modal-actions button:hover { background: var(--popover-item-hover); }
.modal .modal-actions button + button { border-left: 1px solid var(--border); }
.modal .modal-actions button.destructive { color: #ff6b6b; }
.modal .modal-actions button.suggested { color: var(--accent); font-weight: 700; }
.modal .modal-actions button:disabled { opacity: .4; }
@keyframes modal-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

/* ============ context menu ============ */
.ctx {
  position: fixed; z-index: 9500;
  min-width: 200px; padding: 6px;
  background: var(--popover-bg);
  border-radius: 10px;
  box-shadow: var(--shadow-popover);
  animation: ctx-in 120ms var(--ease-decel);
}
@keyframes ctx-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 6px;
  font-size: 13.5px; color: var(--fg); cursor: default;
}
.ctx-item:hover { background: var(--accent); color: var(--accent-fg); }
.ctx-item:hover svg { color: var(--accent-fg); }
.ctx-item.disabled { opacity: .4; pointer-events: none; }
.ctx-item svg { width: 15px; height: 15px; color: var(--fg-dim); flex: none; }
.ctx-sep { height: 1px; background: var(--border); margin: 5px 8px; }

/* ============ tooltip ============ */
#tooltip {
  position: fixed; z-index: 9800; pointer-events: none;
  padding: 4px 10px; border-radius: 6px;
  background: rgba(20,20,20,.92); color: #fff;
  font-size: 12.5px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* ============ toasts ============ */
#toasts {
  position: fixed; top: 40px; left: 50%; transform: translateX(-50%);
  z-index: 8000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  max-width: 480px; padding: 10px 16px;
  background: var(--popover-bg); color: var(--fg);
  border-radius: 999px; box-shadow: var(--shadow-popover);
  font-size: 13.5px;
  animation: toast-in var(--dur-med) var(--ease-decel);
}
.toast.leaving { animation: toast-out var(--dur-med) var(--ease-accel) forwards; }
.toast svg { width: 16px; height: 16px; flex: none; }
.toast .toast-actions { display: flex; gap: 6px; margin-left: 6px; }
.toast .toast-actions button {
  border: none; background: var(--view-hover); color: var(--fg);
  border-radius: 999px; padding: 3px 12px; font-size: 12.5px; font-weight: 500;
}
.toast .toast-actions button:hover { background: var(--view-active); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-16px); } }

/* ============ OSD ============ */
#osd {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%);
  z-index: 8500; pointer-events: none;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-radius: 14px;
  background: var(--osd-bg); color: var(--fg);
  box-shadow: var(--shadow-popover);
  animation: osd-in var(--dur-fast) var(--ease-decel);
}
#osd svg { width: 22px; height: 22px; }
#osd .osd-bar { width: 140px; height: 4px; border-radius: 2px; background: var(--switch-off); overflow: hidden; }
#osd .osd-bar > div { height: 100%; background: var(--fg); border-radius: 2px; }
@keyframes osd-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%,0); } }

/* ============ shared app bits ============ */
.app-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  background: var(--headerbar);
  border-bottom: 1px solid var(--border);
}
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px; color: var(--fg-dim); text-align: center; flex: 1;
}
.empty-state svg { width: 64px; height: 64px; opacity: .35; }
.empty-state .big { font-size: 16px; font-weight: 500; color: var(--fg); }
.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--view-active); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: var(--accent-fg);
  font-size: 10px; font-weight: 700;
}
.kbd {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 6px; border-radius: 4px;
  background: var(--view-hover); border: 1px solid var(--border-strong);
}
