:root {
  --bg: #07060b;
  --bg2: #0e0c16;
  --ink: #f4f1ea;
  --ink-2: rgba(244, 241, 234, 0.62);
  --ink-3: rgba(244, 241, 234, 0.36);
  --line: rgba(255, 255, 255, 0.08);
  --glass: rgba(255, 255, 255, 0.045);
  --glass-2: rgba(255, 255, 255, 0.075);
  --opal-1: #9ee7ff;
  --opal-2: #c9a8ff;
  --opal-3: #ffb8d9;
  --opal-4: #ffe2a8;
  --opal-5: #a8ffd8;
  --danger: #ff7a7a;
  --ok: #8ff0c0;
  --radius: 22px;
  --serif: 'Instrument Serif', 'Times New Roman', serif;
  --sans: 'Manrope', -apple-system, 'Segoe UI', sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: -2;
  background:
    radial-gradient(40% 30% at 20% 10%, rgba(158, 231, 255, 0.10), transparent 70%),
    radial-gradient(35% 30% at 85% 25%, rgba(201, 168, 255, 0.12), transparent 70%),
    radial-gradient(50% 40% at 50% 100%, rgba(255, 184, 217, 0.07), transparent 70%),
    var(--bg);
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-t) + 18px) 18px calc(var(--safe-b) + 104px);
}
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.brand { font-family: var(--serif); font-size: 26px; letter-spacing: 0.01em; }
.brand i { color: var(--ink-3); }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2); font-weight: 600;
}
.pill b { color: var(--ink); }

.view { animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.h1 { font-family: var(--serif); font-size: 40px; line-height: 1.02; font-weight: 400; margin: 6px 0 4px; letter-spacing: -0.01em; }
.h1 em { font-style: italic; background: linear-gradient(100deg, var(--opal-1), var(--opal-2) 40%, var(--opal-3) 70%, var(--opal-4)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { color: var(--ink-2); margin: 0 0 18px; }
.label { font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin: 26px 2px 10px; }

/* ---------- opal orb ---------- */
.orb-wrap { position: relative; display: grid; place-items: center; margin: 14px auto 6px; width: 252px; height: 252px; }
.orb {
  position: absolute; inset: 0; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 22%),
    conic-gradient(from 0deg, var(--opal-1), var(--opal-2), var(--opal-3), var(--opal-4), var(--opal-5), var(--opal-1));
  filter: saturate(0.75) brightness(0.72);
  animation: spin 28s linear infinite;
  transition: filter 1.2s ease, transform 1.2s ease;
  transform: scale(0.86);
}
.orb::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 55%, rgba(7, 6, 11, 0) 38%, rgba(7, 6, 11, 0.55) 72%, rgba(7, 6, 11, 0.9));
}
.orb-glow {
  position: absolute; inset: -30px; border-radius: 50%;
  background: conic-gradient(from 90deg, var(--opal-1), var(--opal-2), var(--opal-3), var(--opal-4), var(--opal-5), var(--opal-1));
  filter: blur(46px); opacity: 0.12;
  animation: spin 40s linear infinite reverse;
  transition: opacity 1.2s ease;
}
.locked .orb { filter: saturate(1.1) brightness(1); transform: scale(1); animation: spin 14s linear infinite, breathe 6s ease-in-out infinite; }
.locked .orb-glow { opacity: 0.5; }
@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 50% { transform: scale(1.035); } }
.orb-core {
  position: relative; z-index: 2; text-align: center;
  width: 176px; height: 176px; border-radius: 50%;
  display: grid; place-content: center; gap: 2px;
  background: rgba(10, 9, 16, 0.62);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 20px 60px rgba(0, 0, 0, 0.5);
}
.orb-time { font-family: var(--serif); font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.orb-time.small { font-size: 30px; }
.orb-cap { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.ring { position: absolute; inset: 0; z-index: 1; rotate: -90deg; }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: rgba(255, 255, 255, 0.06); }
.ring .bar { stroke: url(#opal); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }

.state-line { text-align: center; color: var(--ink-2); margin: 10px 0 0; min-height: 22px; }
.state-line b { color: var(--ink); font-weight: 600; }
.task-quote { font-family: var(--serif); font-style: italic; font-size: 24px; text-align: center; margin: 4px 12px 0; line-height: 1.2; }

/* ---------- cards & controls ---------- */
.card {
  background: linear-gradient(180deg, var(--glass-2), var(--glass));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.card-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card-t { font-weight: 700; font-size: 16px; }
.card-s { color: var(--ink-3); font-size: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  flex: 1; min-width: 60px; padding: 11px 0; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03);
  font-weight: 700; color: var(--ink-2); transition: all 0.2s ease;
}
.chip[aria-pressed='true'] { color: #0b0a10; background: linear-gradient(120deg, var(--opal-1), var(--opal-2) 50%, var(--opal-3)); border-color: transparent; }
.field {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line);
  outline: none; transition: border-color 0.2s;
}
.field:focus { border-color: rgba(201, 168, 255, 0.55); }
.field::placeholder { color: var(--ink-3); }
textarea.field { resize: none; min-height: 52px; }
.btn {
  width: 100%; margin-top: 12px; padding: 15px 18px; border-radius: 16px;
  font-weight: 800; font-size: 15.5px; letter-spacing: 0.01em;
  color: #0b0a10;
  background: linear-gradient(110deg, var(--opal-1), var(--opal-2) 35%, var(--opal-3) 70%, var(--opal-4));
  background-size: 200% 100%;
  box-shadow: 0 10px 30px rgba(201, 168, 255, 0.22);
  transition: transform 0.15s ease, background-position 0.6s ease, opacity 0.2s;
}
.btn:hover { background-position: 100% 0; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; }
.btn.ghost { background: var(--glass); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.small { width: auto; padding: 10px 16px; margin: 0; font-size: 13.5px; }
.link { color: var(--ink-3); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; display: block; margin: 18px auto 0; }
.link.danger { color: rgba(255, 122, 122, 0.8); }
.or { text-align: center; color: var(--ink-3); font-size: 13px; margin: 14px 0 0; }
.or button { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.err { color: var(--danger); font-size: 13.5px; min-height: 18px; margin: 8px 2px 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--glass); border: 1px solid var(--line); border-radius: 18px; padding: 14px 12px; }
.stat-v { font-family: var(--serif); font-size: 30px; line-height: 1; }
.stat-v small { font-family: var(--sans); font-size: 12px; color: var(--ink-3); margin-left: 2px; }
.stat-l { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; font-weight: 600; }

.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.recent li:last-child { border: 0; }
.recent .what { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.tag.ok { color: var(--ok); background: rgba(143, 240, 192, 0.1); }
.tag.bad { color: var(--danger); background: rgba(255, 122, 122, 0.1); }
.tag.mid { color: var(--opal-2); background: rgba(201, 168, 255, 0.1); }

.emergency { text-align: center; margin-top: 14px; padding: 14px; border-radius: 16px; border: 1px dashed rgba(255, 122, 122, 0.35); color: var(--ink-2); font-size: 13.5px; }
.emergency b { color: var(--danger); font-variant-numeric: tabular-nums; }

/* ---------- apps list ---------- */
.row { display: flex; align-items: center; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.row:last-child { border: 0; }
.mono { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 16px; color: #0b0a10; flex: none; }
.row-t { flex: 1; font-weight: 600; }
.row-s { color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); transition: background 0.25s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.switch[aria-checked='true'] { background: linear-gradient(120deg, var(--opal-1), var(--opal-2)); }
.switch[aria-checked='true']::after { transform: translateX(20px); }
.switch:disabled { opacity: 0.4; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 150px; }
.msg { max-width: 84%; padding: 11px 14px; border-radius: 20px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; animation: rise 0.35s ease both; }
.msg.me { align-self: flex-end; background: linear-gradient(120deg, rgba(158, 231, 255, 0.22), rgba(201, 168, 255, 0.24)); border: 1px solid rgba(201, 168, 255, 0.25); border-bottom-right-radius: 6px; }
.msg.ai { align-self: flex-start; background: var(--glass-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg .who { display: flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 800; color: var(--ink-3); margin-bottom: 4px; }
.mini-orb { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(var(--opal-1), var(--opal-2), var(--opal-3), var(--opal-4), var(--opal-1)); }
.msg img { display: block; max-width: 100%; max-height: 220px; border-radius: 12px; margin-top: 6px; }
.msg .verdict { display: inline-block; margin-top: 8px; }
.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 50% { opacity: 0.2; transform: translateY(-2px); } }
.chat-empty { text-align: center; color: var(--ink-3); padding: 40px 20px 10px; }
.chat-empty .h1 { color: var(--ink); font-size: 32px; }
.suggest { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.suggest button { text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); color: var(--ink-2); font-size: 14px; }

.composer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-b) + 78px);
  max-width: 460px; margin: 0 auto; padding: 10px 14px;
}
.composer-in {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px;
  background: rgba(20, 18, 28, 0.82); border: 1px solid var(--line); border-radius: 24px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.composer textarea { flex: 1; border: 0; background: none; outline: none; resize: none; padding: 9px 4px; max-height: 120px; min-height: 22px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--glass-2); color: var(--ink-2); }
.icon-btn.send { background: linear-gradient(120deg, var(--opal-1), var(--opal-2) 60%, var(--opal-3)); color: #0b0a10; }
.icon-btn:disabled { opacity: 0.4; }
.thumbs { display: flex; gap: 8px; padding: 0 6px 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, 0.7); font-size: 12px; line-height: 20px; }

/* ---------- setup ---------- */
.step { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border: 0; padding-bottom: 2px; }
.step-n { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #0b0a10; background: linear-gradient(120deg, var(--opal-1), var(--opal-2)); }
.step-b { flex: 1; min-width: 0; color: var(--ink-2); font-size: 14px; }
.step-b b { color: var(--ink); }
.step-b ol { margin: 6px 0 0; padding-left: 18px; }
.step-b li { margin: 3px 0; }
.copy { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.copy code { flex: 1; min-width: 0; font-size: 11.5px; padding: 9px 10px; border-radius: 10px; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }

/* ---------- tab bar ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 8px 14px calc(var(--safe-b) + 10px);
  max-width: 460px; margin: 0 auto;
}
.tabs-in {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(16, 14, 22, 0.78); border: 1px solid var(--line); border-radius: 26px;
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  padding: 6px;
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 6px; border-radius: 20px; color: var(--ink-3); font-size: 11px; font-weight: 700; transition: color 0.2s, background 0.2s; }
.tab svg { width: 22px; height: 22px; }
.tab[aria-selected='true'] { color: var(--ink); background: rgba(255, 255, 255, 0.07); }

/* ---------- login & gate ---------- */
.center { min-height: 100%; display: grid; place-items: center; padding: 24px 18px calc(var(--safe-b) + 24px); text-align: center; }
.center-in { width: 100%; max-width: 380px; }
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%);
  padding: 10px 16px; border-radius: 999px; background: rgba(30, 27, 40, 0.92); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 600; z-index: 50; animation: rise 0.3s ease both;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.breath { width: 120px; height: 120px; margin: 0 auto; border-radius: 50%; background: conic-gradient(var(--opal-1), var(--opal-2), var(--opal-3), var(--opal-4), var(--opal-5), var(--opal-1)); filter: blur(1px); animation: inhale 5s ease-in-out both, spin 20s linear infinite; }
@keyframes inhale { 0% { transform: scale(0.55); opacity: 0.5; } 50% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.8); opacity: 0.9; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
