/* Aura Connect. Boot = pure black. Apps follow prefers-color-scheme like the real iOS apps. */
:root {
  --font: -apple-system, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", Arial, sans-serif;
  /* Notes (light) */
  --n-bg: #ffffff; --n-panel: #f7f7f7; --n-stroke: rgba(0, 0, 0, 0.08); --n-label: #000000; --n-secondary: rgba(60, 60, 67, 0.6);
  /* Phone (light) */
  --d-bg: #ffffff; --d-key: #e5e5ea; --d-key-down: #c7c7cc; --d-key-line: rgba(0, 0, 0, 0.06); --d-text: #000000;
  --d-letters: #000000; --d-blue: #007aff; --d-green: #34c759; --d-tab: #8e8e93; --d-tabbar: rgba(249, 249, 249, 0.94);
  /* Calculator (light) */
  --c-bg: #ffffff; --c-digit: #e9e9eb; --c-fn: #cfced2; --c-op: #ff9f0a; --c-text: #000000; --c-optext: #ffffff;
  --c-hist: #8e8e93; --c-main: #000000; --c-icon: #e5e5ea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --n-bg: #000000; --n-panel: #0d0d0d; --n-stroke: rgba(255, 255, 255, 0.16); --n-label: #ffffff; --n-secondary: rgba(235, 235, 245, 0.6);
    --d-bg: #000000; --d-key: #0d0d0d; --d-key-down: #3a3a3c; --d-key-line: rgba(255, 255, 255, 0.16); --d-text: #ffffff;
    --d-letters: #ffffff; --d-blue: #0a84ff; --d-green: #30d158; --d-tab: #8e8e93; --d-tabbar: rgba(22, 22, 22, 0.94);
    --c-bg: #000000; --c-digit: #2a2a2a; --c-fn: #686868; --c-op: #ff9f0a; --c-text: #f8f8f8; --c-optext: #f8f8f8;
    --c-hist: #95949a; --c-main: #fbfbfb; --c-icon: #2c2c2e;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
[hidden] { display: none !important; }
#black { position: fixed; inset: 0; background: #000; z-index: 5; }
.app { position: fixed; inset: 0; z-index: 10; }
#fallback { position: fixed; left: -200px; top: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; caret-color: transparent; }
svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg .f { fill: currentColor; stroke: none; }
button { font-family: inherit; border: 0; padding: 0; background: none; color: inherit; cursor: pointer; }

/* ---------------- Notes (iOS 26 style, values from Cosmos Connect's NotesInputView) ---------------- */
.notes { position: absolute; inset: 0; background: var(--n-bg); color: var(--n-label); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); --ink: var(--n-label); }
.n-top { display: flex; align-items: center; height: 50px; padding: 0 16px; flex: none; }
.n-spacer { flex: 1; }
.n-circle { width: 40px; height: 40px; border-radius: 50%; background: var(--n-panel); box-shadow: inset 0 0 0 0.7px var(--n-stroke);
  display: grid; place-items: center; margin-right: 12px; }
.n-circle svg { width: 20px; height: 20px; stroke-width: 2.3; }
.n-top .n-circle:first-child { margin-right: 0; }
.n-pill { height: 42px; padding: 0 10px; border-radius: 21px; background: var(--n-panel); box-shadow: inset 0 0 0 0.7px var(--n-stroke);
  display: flex; align-items: center; gap: 12px; }
.n-glyph { width: 30px; height: 30px; display: grid; place-items: center; }
.n-glyph svg { width: 22px; height: 22px; }
.n-date { text-align: center; font-size: 13px; color: var(--n-secondary); padding-top: 6px; flex: none; }
.n-body { position: relative; flex: 1; margin: 34px 22px 70px; --ink: var(--n-label); }
.pen-canvas { position: absolute; left: 0; top: 0; pointer-events: none; }
.n-bottom { position: absolute; left: 0; right: 0; bottom: calc(8px + env(safe-area-inset-bottom)); padding: 0 16px; display: flex; align-items: center; }
.n-bar { width: 119px; height: 48px; border-radius: 24px; background: var(--n-panel); box-shadow: inset 0 0 0 0.7px var(--n-stroke);
  display: flex; align-items: center; justify-content: space-around; padding: 0 6px; }
.n-bar .n-glyph svg { width: 21px; height: 21px; }
.n-square { width: 48px; height: 48px; border-radius: 24px; background: var(--n-panel); box-shadow: inset 0 0 0 0.7px var(--n-stroke);
  display: grid; place-items: center; color: var(--n-secondary); }
.n-square svg { width: 22px; height: 22px; }
.n-black { position: fixed; inset: 0; background: #000; z-index: 50; }

/* ---------------- Phone keypad (fractions from Cosmos Connect's DialerView) ---------------- */
.dialer { position: absolute; inset: 0; background: var(--d-bg); color: var(--d-text);
  --kd: clamp(44px, 19.6vw, 120px); --gap: 6vw; --pitch: 11.4dvh; }
.d-number { position: absolute; left: 6vw; right: 6vw; top: calc(21dvh - 30px); height: 60px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.d-num { font-size: 42px; font-weight: 400; letter-spacing: 0.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.d-add { position: absolute; left: 0; right: 0; top: calc(21dvh + 30px); text-align: center; color: var(--d-blue); font-size: 17px; visibility: hidden; }
.d-pad { position: absolute; left: 50%; transform: translateX(-50%); top: calc(49.2dvh - 2 * var(--pitch));
  display: grid; grid-template-columns: repeat(3, var(--kd)); grid-auto-rows: var(--pitch); column-gap: var(--gap); }
.d-key { width: var(--kd); height: var(--kd); align-self: center; border-radius: 50%; background: var(--d-key); box-shadow: inset 0 0 0 0.6px var(--d-key-line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--d-text); transition: background 0.25s, transform 0.12s; }
.d-key.down, .d-key:active { background: var(--d-key-down); transition: none; }
.d-digit { font-size: calc(var(--kd) * 0.42); line-height: 1; font-weight: 400; }
.d-digit.star { font-size: calc(var(--kd) * 0.5); transform: translateY(12%); }
.d-letters { font-size: calc(var(--kd) * 0.115); font-weight: 700; letter-spacing: 2px; height: 1.2em; margin-top: 1px; color: var(--d-letters); }
.d-call-row { position: absolute; left: 50%; transform: translateX(-50%); top: calc(78.3dvh - var(--kd) / 2);
  display: grid; grid-template-columns: repeat(3, var(--kd)); column-gap: var(--gap); align-items: center; }
.d-call { width: var(--kd); height: var(--kd); border-radius: 50%; background: var(--d-green); color: #fff; display: grid; place-items: center; }
.d-call svg { width: 42%; height: 42%; }
.d-call:active { filter: brightness(1.2); }
.d-del { width: var(--kd); height: var(--kd); display: grid; place-items: center; color: var(--d-text); visibility: hidden; }
.d-del svg { width: 34%; height: 34%; stroke-width: 1.6; }
.d-tabs { position: absolute; left: 0; right: 0; bottom: 0; height: calc(10.4dvh); padding-bottom: env(safe-area-inset-bottom);
  background: var(--d-tabbar); display: flex; justify-content: space-around; align-items: center; }
.d-tab { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--d-tab); font-size: 10px; font-weight: 500; width: 20%; }
.d-tab svg { width: 26px; height: 26px; }
.d-tab.on { color: var(--d-blue); }

/* ---------------- Calculator ---------------- */
.calc { position: absolute; inset: 0; background: var(--c-bg); color: var(--c-text); display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px calc(16px + env(safe-area-inset-bottom)); }
.c-head { height: 56px; display: flex; align-items: center; flex: none; }
.c-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--c-icon); display: grid; place-items: center; color: var(--c-op); }
.c-icon svg { width: 20px; height: 20px; stroke-width: 2.2; }
.c-display { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; padding: 0 8px 12px; overflow: hidden; }
.c-hist { font-size: 28px; color: var(--c-hist); min-height: 34px; white-space: nowrap; }
.c-main { font-size: 84px; font-weight: 300; color: var(--c-main); white-space: nowrap; line-height: 1.05; font-variant-numeric: tabular-nums; }
.c-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; flex: none; }
.c-key { aspect-ratio: 1; border-radius: 50%; font-size: clamp(28px, 9vw, 40px); font-weight: 400; display: grid; place-items: center;
  background: var(--c-digit); color: var(--c-text); transition: filter 0.2s, transform 0.12s; }
.c-key.fn { background: var(--c-fn); color: var(--c-text); font-size: clamp(24px, 7.5vw, 34px); }
.c-key.op { background: var(--c-op); color: var(--c-optext); font-size: clamp(32px, 10vw, 46px); }
.c-key svg { width: 38%; height: 38%; stroke-width: 1.7; }
.c-key.down, .c-key:active { filter: brightness(1.35); transform: scale(0.96); transition: none; }

/* ---------------- Debug overlay ---------------- */
#debug { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, 0.88); color: #e8e8e8; overflow-y: auto;
  padding: calc(8px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom)); -webkit-user-select: text; user-select: text; }
.dbg-panel { display: flex; flex-direction: column; gap: 8px; max-width: 620px; margin: 0 auto; }
#debug pre { margin: 0; font: 10.5px/1.35 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
#dbg-log { max-height: 30vh; overflow-y: auto; background: rgba(255, 255, 255, 0.06); padding: 6px; border-radius: 8px; }
.dbg-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dbg-grid button, .dbg-row button { background: #2c2c2e; color: #fff; border-radius: 10px; min-height: 40px; font-size: 15px; font-weight: 600; }
.dbg-grid button.letter { background: #3a3a6a; }
.dbg-grid button.wide { grid-column: span 2; }
.dbg-row { display: flex; gap: 6px; }
.dbg-row input { flex: 1; min-width: 0; min-height: 40px; border-radius: 10px; border: 1px solid #444; background: #111; color: #fff; padding: 0 10px; font-size: 16px; }
.dbg-row button { padding: 0 14px; }
