/* ZNSS Hub shared styles. Modules link this and only add what's specific to them.
   Dark by default (it's a camera app and a showpiece); light theme follows the device. */
:root {
  --brand: #00aeef;          /* ZNSS sky blue */
  --brand-2: #2b3990;        /* ZNSS navy */
  --brand-ink: #00aeef;      /* brand coloured TEXT (links, brand badges): darker in the light theme so it stays readable */
  --bg: #07090d;
  --bg-2: #0d1117;
  --surface: #121821;
  --surface-2: #19212d;
  --line: #243041;
  --text: #e8eef6;
  --muted: #8b99ab;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f7fb; --bg-2: #eaf0f7; --surface: #ffffff; --surface-2: #f3f6fa; --line: #dbe3ee;
    --text: #0d1724; --muted: #5b6b80; --shadow: 0 8px 24px rgba(13, 23, 36, .08);
    /* The bright status colours are hard to read as text on white: darker shades for the light theme. */
    --brand-ink: #0369a1; --good: #15803d; --warn: #b45309; --bad: #dc2626;
    color-scheme: light;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand-ink); text-decoration: none; }
/* Long unbroken text (URLs, email addresses, joined-up names) wraps instead of pushing the page sideways. */
h1, h2, h3, h4, p, li, dd, td, th, pre, label, .t, .s { overflow-wrap: anywhere; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.appbar .logo { height: 30px; width: auto; display: block; }
.logo-on-light { display: none !important; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .logo-on-light { display: block !important; }
  :root:not([data-theme="dark"]) .logo-on-dark { display: none !important; }
}
.appbar h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: .2px; }
.appbar .spacer { flex: 1; }
.appbar .back { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--text); }
.appbar .back:hover { background: var(--surface-2); }

main.page { max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(32px + var(--safe-bottom)); }

/* ---------- tiles (home launcher) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-height: 132px; padding: 16px;
  background: linear-gradient(160deg, var(--surface-2), var(--surface)); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); transition: transform .12s ease, border-color .12s ease;
}
.tile:hover { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); transform: translateY(-1px); }
.tile:active { transform: scale(.98); }
.tile .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand-ink); }
.tile .ico svg { width: 22px; height: 22px; }
.tile .t { font-weight: 650; font-size: 16px; }
.tile .s { color: var(--muted); font-size: 13px; margin-top: auto; }
.tile .badge { position: absolute; top: 12px; right: 12px; }
.tile.hero { grid-column: 1 / -1; min-height: 150px;
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 60%),
              linear-gradient(160deg, var(--surface-2), var(--surface)); }

/* ---------- cards, lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--text); }
.row:first-child { border-top: 0; }
a.row:hover, button.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- badges, dots ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.badge.brand { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

/* ---------- buttons, inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; }
.btn:hover { border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #00131c; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input { width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-2); outline: none; }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.45; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; font-weight: 600; color: var(--muted); cursor: pointer;
  white-space: nowrap; flex: none; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }
/* Tab and chip rows scroll sideways with no scrollbar: hub.js fades the edge that has more behind it. */
.more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); }
.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); }

/* ---------- empty, toast, sheet ---------- */
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 36px; height: 36px; opacity: .6; }
#toast { position: fixed; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px;
  box-shadow: var(--shadow); transition: all .2s ease; z-index: 100; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { border-color: var(--bad); }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-bottom)); box-shadow: var(--shadow); }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 12px; font-size: 17px; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 14px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: color-mix(in srgb, var(--brand) 20%, var(--surface)); }
.msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 480px) { main.page { padding-left: 12px; padding-right: 12px; } .tiles { grid-template-columns: 1fr 1fr; } }
