/* Nexus design system: tokens, themes and shared components. */

/* Material 3 (Google style): Google Sans Flex, Google green accent, flat surfaces, pill controls. */
@font-face {
  font-family: "Google Sans Flex"; font-style: normal; font-display: swap; font-weight: 1 1000;
  src: url(../fonts/google-sans-flex-latin-wght-normal.woff2) format("woff2-variations"), url(../fonts/google-sans-flex-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Google Sans Flex"; font-style: normal; font-display: swap; font-weight: 1 1000;
  src: url(../fonts/google-sans-flex-latin-ext-wght-normal.woff2) format("woff2-variations"), url(../fonts/google-sans-flex-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* Surfaces (M3 neutral, white) */
  --bg: #f8f9fa; --sidebar: #f8f9fa; --surface: #ffffff; --surface-2: #f1f3f4; --surface-3: #e8eaed;
  --border: #e1e3e1; --border-strong: #c4c7c5; --overlay: rgba(31, 31, 31, .4);
  --text: #1f1f1f; --text-2: #444746; --muted: #747775;
  /* Primary: Google green */
  --accent: #188038; --accent-hover: #137333; --accent-fg: #ffffff; --accent-soft: #e6f4ea; --accent-text: #0d652d;
  --ok: #188038; --ok-soft: #e6f4ea; --warn: #b06000; --warn-soft: #fef7e0; --bad: #d93025; --bad-soft: #fce8e6;
  --p-urgent: #d93025; --p-high: #e37400; --p-medium: #1a73e8; --p-low: #80868b;
  /* M3 elevation: flat by default, soft key shadows only for floating layers */
  --shadow-1: none;
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 6px 2px rgba(0, 0, 0, .15);
  --shadow-3: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 8px 3px rgba(0, 0, 0, .15);
  /* M3 shape scale */
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 28px; --r-full: 999px;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
  --font: "Google Sans Flex", "Google Sans", Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: var(--font);
  --mono: "Cascadia Code", "Cascadia Mono", Consolas, ui-monospace, monospace;
  --ease: cubic-bezier(.2, 0, 0, 1);
  color-scheme: light;

  /* Project colours (Google palette) */
  --c-red: #d93025; --c-orange: #e8710a; --c-amber: #f9ab00; --c-green: #1e8e3e; --c-teal: #12a4af; --c-cyan: #129eaf;
  --c-blue: #1a73e8; --c-indigo: #4b5fd6; --c-violet: #9334e6; --c-pink: #e52592; --c-brown: #a0703c; --c-gray: #80868b;

  /* Note colours (Keep-style), background / border */
  --n-default: var(--surface); --n-default-b: var(--border);
  --n-red: #faafa8; --n-red-b: #f6928a; --n-orange: #f39f76; --n-orange-b: #ef8a58; --n-yellow: #fff8b8; --n-yellow-b: #f5e98c;
  --n-green: #e2f6d3; --n-green-b: #c6e9ad; --n-teal: #b4ddd3; --n-teal-b: #97cfc1; --n-blue: #d4e4ed; --n-blue-b: #b6d1e0;
  --n-purple: #d3bfdb; --n-purple-b: #c2a6cd; --n-pink: #f6e2dd; --n-pink-b: #ecc9c0; --n-brown: #e9e3d4; --n-brown-b: #d9cfb8;
  --n-gray: #efeff1; --n-gray-b: #d6d7db;
}

:root[data-theme="dark"] {
  --bg: #131314; --sidebar: #131314; --surface: #1e1f20; --surface-2: #282a2c; --surface-3: #333537;
  --border: #3c4043; --border-strong: #5f6368; --overlay: rgba(0, 0, 0, .6);
  --text: #e3e3e3; --text-2: #c4c7c5; --muted: #8e918f;
  --accent: #6dd58c; --accent-hover: #85e0a0; --accent-fg: #00391a; --accent-soft: #0f3d1f; --accent-text: #9ef0b4;
  --ok: #6dd58c; --ok-soft: #0f3d1f; --warn: #fdd663; --warn-soft: #3a2f0b; --bad: #f28b82; --bad-soft: #42201e;
  --p-urgent: #f28b82; --p-high: #fcad70; --p-medium: #8ab4f8; --p-low: #9aa0a6;
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .5), 0 2px 6px 2px rgba(0, 0, 0, .3);
  --shadow-3: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 8px 3px rgba(0, 0, 0, .3);
  color-scheme: dark;
  --c-red: #f28b82; --c-orange: #fcad70; --c-amber: #fdd663; --c-green: #81c995; --c-teal: #78d9ec; --c-cyan: #78d9ec;
  --c-blue: #8ab4f8; --c-indigo: #a8b4f5; --c-violet: #c58af9; --c-pink: #ff8bcb; --c-brown: #d7b38c; --c-gray: #9aa0a6;
  --n-red: #77172e; --n-red-b: #8e2a40; --n-orange: #692b17; --n-orange-b: #803d26; --n-yellow: #7c4a03; --n-yellow-b: #925c12;
  --n-green: #264d3b; --n-green-b: #36604c; --n-teal: #0c625d; --n-teal-b: #1d756f; --n-blue: #256377; --n-blue-b: #36768a;
  --n-purple: #472e5b; --n-purple-b: #5a406e; --n-pink: #6c394f; --n-pink-b: #804b62; --n-brown: #4b443a; --n-brown-b: #5e564b;
  --n-gray: #232427; --n-gray-b: #3a3b3f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); font-optical-sizing: auto; letter-spacing: .01em; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 500; letter-spacing: 0; }
h1 { font-size: 22px; font-weight: 400; } h2 { font-size: 18px; } h3 { font-size: 14px; }
p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.faint { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kbd, kbd { font: 11px/1 var(--mono); padding: 3px 5px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; color: var(--text-2); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* Icons */
/* Material Symbols are filled glyphs, sized a touch larger than the old line icons to match their optical weight. */
.icon { width: 18px; height: 18px; flex: none; fill: currentColor; stroke: none; vertical-align: middle; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 22px; height: 22px; }
.icon.xl { width: 28px; height: 28px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Buttons */
button, .btn {
  font: inherit; font-weight: 500; letter-spacing: .01em; color: var(--text); background: transparent; border: 1px solid var(--border-strong);
  border-radius: var(--r-full); padding: 0 16px; height: 36px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap; transition: background .12s, border-color .12s, color .12s, box-shadow .12s; text-decoration: none;
}
button:hover, .btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); text-decoration: none; }
button:active { background: color-mix(in srgb, var(--text) 12%, transparent); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
/* Tonal button (M3 filled tonal) */
button.tonal { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
button.tonal:hover { background: color-mix(in srgb, var(--accent) 22%, var(--accent-soft)); }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px 1px rgba(0, 0, 0, .15); }
button.primary:active { background: var(--accent-hover); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover { background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--text); }
button.danger { color: var(--bad); }
button.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
button.icon-btn { width: 36px; padding: 0; border-radius: var(--r-full); }
button.icon-btn.sm { width: 28px; height: 28px; border-radius: var(--r-full); }
button.sm { height: 30px; padding: 0 12px; font-size: 13px; border-radius: var(--r-full); }
button.lg { height: 44px; padding: 0 24px; font-size: 15px; }
button[disabled] { opacity: .38; cursor: default; pointer-events: none; }
.menu-item, .nav-item, .mini-item, .palette-item, .hist-item, .td-prop-value, .tl-label, .add-task-btn, .composer-open { text-align: left; }
button.pill { border-radius: 999px; }
button[aria-pressed="true"].toggle { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
/* M3 segmented button */
.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-full); overflow: hidden; background: transparent; }
.btn-group button { border: 0; border-radius: 0; height: 34px; padding: 0 14px; background: transparent; color: var(--text); }
.btn-group button + button { border-left: 1px solid var(--border-strong); }
.btn-group button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); }

/* Form controls */
input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  padding: 0 12px; height: 40px; width: 100%; transition: border-color .12s, box-shadow .12s;
}
textarea { padding: 10px 12px; height: auto; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
input[type="color"] { padding: 2px; width: 40px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.input-plain { border-color: transparent; background: transparent; padding: 0; height: auto; }
.input-plain:focus { box-shadow: none; border-color: transparent; }
.form-error { color: var(--bad); font-size: 13px; min-height: 1em; }

/* Chips and badges */
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2); border: 1px solid transparent; white-space: nowrap; max-width: 100%;
}
.chip .icon { width: 12px; height: 12px; }
.chip.accent { background: var(--accent-soft); color: var(--accent-text); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.outline { background: transparent; border-color: var(--border-strong); }
button.chip { height: 32px; padding: 0 12px; cursor: pointer; border-color: var(--border-strong); background: transparent; color: var(--text-2); }
button.chip:hover { background: var(--surface-3); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; background: var(--muted); }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Cards and surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: none; }
.panel-title { font-size: 12px; font-weight: 500; letter-spacing: .02em; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 8px 0; border: 0; }
.empty-state { text-align: center; padding: 56px 24px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-state .art { width: 64px; height: 64px; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; }
.empty-state h3 { font-size: 16px; color: var(--text); }

/* Menus and popovers */
.popover {
  position: fixed; inset: auto; margin: 0; color: var(--text); z-index: 60; min-width: 200px; max-width: min(360px, calc(100vw - 16px)); max-height: min(70vh, 520px); overflow: auto;
  background: var(--surface); border: 0; border-radius: var(--r-sm); box-shadow: var(--shadow-2); padding: 8px 0;
  animation: pop-in .14s var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 16px; border: 0; border-radius: 0;
  background: transparent; color: var(--text); font-weight: 400; justify-content: flex-start; text-align: left;
}
.menu-item:hover, .menu-item.active { background: color-mix(in srgb, var(--text) 8%, transparent); }
.menu-item .icon { color: var(--text-2); }
.menu-item.danger { color: var(--bad); }
.menu-item.danger .icon { color: var(--bad); }
.menu-item .hint { margin-left: auto; color: var(--muted); font-size: 12px; }
.menu-item[aria-checked="true"]::after { content: ""; margin-left: auto; width: 6px; height: 10px; border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-2px, -1px); }
.menu-sep { height: 1px; background: var(--border); margin: 8px 0; }
.menu-label { font-size: 12px; font-weight: 500; letter-spacing: .02em; color: var(--muted); padding: 8px 16px 4px; }
.swatches { display: grid; grid-template-columns: repeat(6, 28px); gap: 6px; padding: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* Dialogs */
dialog {
  border: 0; padding: 0; border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-3);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
}
dialog[open] { animation: dialog-in .18s var(--ease); }
dialog::backdrop { background: var(--overlay); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 24px 24px 8px; }
.dialog-head h2 { font-size: 22px; font-weight: 400; }
.dialog-body { padding: 8px 24px 16px; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 24px 24px; }

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: var(--r-sm);
  background: #313033; color: #f4eff4; box-shadow: var(--shadow-3); font-size: 13.5px; max-width: min(560px, calc(100vw - 32px));
  animation: toast-in .2s var(--ease);
}
:root[data-theme="dark"] .toast { background: #e6e1e5; color: #313033; }
.toast.error { background: var(--bad); color: #fff; }
.toast button { height: 26px; background: transparent; color: inherit; border-color: rgba(255, 255, 255, .25); font-size: 13px; }
:root[data-theme="dark"] .toast button { border-color: rgba(0, 0, 0, .2); }
.toast button:hover { background: rgba(255, 255, 255, .12); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* Tooltips (title attributes stay native; this is for richer hints) */
[data-tip] { position: relative; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; border-radius: 0; background: transparent; color: var(--text-2); height: 44px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }

/* Progress */
.progress { height: 4px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s var(--ease); }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
button.chip.accent, button.chip.accent:hover { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
button.chip.accent:hover { background: color-mix(in srgb, var(--accent) 18%, var(--accent-soft)); }
