/* NewTech PC Support - design tokens + shared primitives.
   Light/dark follows the OS; [data-theme] on <html> can force one. */
:root {
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --brand: #007968;
  --brand-2: #009682;
  --brand-ink: #ffffff;
  --brand-soft: rgba(0, 121, 104, 0.10);
  --brand-ring: rgba(0, 150, 130, 0.35);

  --bg: #ffffff;
  --bg-soft: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --surface-3: #e9eaee;
  --border: #e4e5e9;
  --border-strong: #d2d4da;
  --text: #15161a;
  --text-2: #4d505b;
  --text-3: #8b8e99;
  --user-bubble: #f0f1f4;
  --overlay: rgba(15, 16, 20, 0.45);

  --success: #0e9f6e;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(239, 68, 68, 0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;
  --shadow-sm: 0 1px 2px rgba(16, 18, 24, 0.06);
  --shadow: 0 6px 24px rgba(16, 18, 24, 0.08);
  --shadow-lg: 0 18px 48px rgba(16, 18, 24, 0.18);

  --sidebar-w: 268px;
  --topbar-h: 56px;
  --chat-max: 768px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-soft: rgba(0, 150, 130, 0.16);
    --bg: #0d0d11;
    --bg-soft: #131318;
    --surface: #17171c;
    --surface-2: #202028;
    --surface-3: #2a2a34;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #f4f4f6;
    --text-2: #a3a5b0;
    --text-3: #6c6e7a;
    --user-bubble: #272732;
    --overlay: rgba(0, 0, 0, 0.6);
    --success: #10b981;
    --success-soft: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-soft: rgba(0, 150, 130, 0.16);
  --bg: #0d0d11; --bg-soft: #131318; --surface: #17171c; --surface-2: #202028; --surface-3: #2a2a34;
  --border: rgba(255, 255, 255, 0.08); --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f6; --text-2: #a3a5b0; --text-3: #6c6e7a; --user-bubble: #272732; --overlay: rgba(0, 0, 0, 0.6);
  --success: #10b981; --success-soft: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b; --warning-soft: rgba(245, 158, 11, 0.15);
  --danger: #ef4444; --danger-soft: rgba(239, 68, 68, 0.15);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45); --shadow-lg: 0 20px 56px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-2); }
code, pre, kbd { font-family: var(--font-mono); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-ring); outline-offset: 2px; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s, transform .1s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-danger { color: var(--danger); border-color: var(--danger-soft); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: transparent; color: var(--text-2);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- chips / inputs ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
button.chip:hover { background: var(--surface-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.dot.online { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.offline { background: var(--danger); }

.input {
  width: 100%; height: 44px; padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 16px; /* >=16px: no iOS zoom */
}
.input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-ring); }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.muted { color: var(--text-3); font-size: 13px; }

/* ---------- modal (<dialog class="modal">) ---------- */
dialog.modal {
  width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in .18s var(--ease); }
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 8px; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; }
.modal-body { padding: 8px 18px 16px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) {
  dialog.modal { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92dvh; }
  dialog.modal[open] { animation: sheet-in .22s var(--ease); }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- toast ---------- */
#toast-root {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none;
  width: min(440px, calc(100vw - 24px));
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500; box-shadow: var(--shadow);
  pointer-events: auto; animation: modal-in .2s var(--ease); transition: opacity .3s;
}
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.warning svg { color: var(--warning); }

/* ---------- spinner ---------- */
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--surface-3); border-top-color: var(--brand-2);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
