:root {
  --bg: #0b1020;
  --bg2: #131a30;
  --card: rgba(255, 255, 255, 0.06);
  --card-solid: #161d33;
  --line: rgba(255, 255, 255, 0.10);
  --text: #eaf0ff;
  --muted: #9aa6c4;
  --accent: #6d8bff;
  --accent2: #a06bff;
  --good: #43d6a0;
  --warn: #ffb454;
  --danger: #ff6b7d;
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The screens use display:flex which (as author CSS) overrides the UA [hidden]
   rule, so a hidden screen would otherwise stay laid out + focusable. Force it. */
[hidden] { display: none !important; }

/* Screen-reader-only text (announced, not shown). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 20% -10%, #1b2547 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #2a1c47 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

/* ---------- phone frame ---------- */
.phone {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: min(880px, calc(100vh - 32px));
  background: linear-gradient(180deg, #0e1530, #0a0f1f);
  border-radius: 38px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 0 0 6px #05070f;
  overflow: hidden;
  isolation: isolate;
}
@media (max-width: 430px) {
  body { padding: 0; }
  .phone { max-width: 100%; height: 100vh; height: 100dvh; border-radius: 0; border: none; box-shadow: none; }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: fade .35s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- status bar ---------- */
.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
}
.statusbar-icons { display: inline-flex; gap: 7px; align-items: center; opacity: .85; font-size: 12px; }
.statusbar-icons .sig { width: 16px; height: 11px; background:
  linear-gradient(to right, currentColor 0 3px, transparent 3px 4px, currentColor 4px 7px, transparent 7px 8px, currentColor 8px 11px, transparent 11px 12px, currentColor 12px 16px);
  clip-path: polygon(0 100%, 0 70%, 25% 70%, 25% 45%, 50% 45%, 50% 22%, 75% 22%, 75% 0, 100% 0, 100% 100%); }

/* ================= LOCK SCREEN ================= */
.lock-screen {
  background:
    radial-gradient(700px 380px at 50% -5%, rgba(110,139,255,.28), transparent 60%),
    radial-gradient(600px 400px at 90% 110%, rgba(160,107,255,.25), transparent 60%),
    linear-gradient(180deg, #0c1330, #0a0f1f);
  padding-bottom: 30px;
}
.lock-clock { margin-top: 12vh; text-align: center; }
.lock-time { font-size: 76px; font-weight: 300; letter-spacing: -2px; line-height: 1; }
.lock-date { margin-top: 6px; font-size: 17px; color: var(--muted); font-weight: 500; }

.lock-notice {
  margin: 26px 22px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  align-items: center;
  backdrop-filter: blur(8px);
}
.lock-notice-icon { font-size: 17px; }

.lock-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lock-icon-btn {
  width: 78px; height: 78px; border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.08);
  color: var(--text);
  font-size: 30px; cursor: pointer;
  transition: transform .15s ease, background .2s ease;
  backdrop-filter: blur(6px);
}
.lock-icon-btn:active { transform: scale(.92); background: rgba(255,255,255,.16); }
.lock-hint { font-size: 14px; color: var(--muted); }
.swipe-hint { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); opacity: .7; }
.swipe-bar { width: 120px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.35); animation: nudge 1.8s ease-in-out infinite; }
@keyframes nudge { 0%,100% { transform: translateY(0); opacity: .6; } 50% { transform: translateY(-6px); opacity: 1; } }

/* ================= HOME SCREEN ================= */
.home-screen { padding: 0 16px 24px; gap: 0; }
.greeting { padding: 16px 6px 10px; }
.greeting-line { font-size: 15px; color: var(--muted); font-weight: 500; }
.greeting-name { font-size: 30px; font-weight: 700; letter-spacing: -.5px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(8px);
}
.briefing-card {
  background: linear-gradient(145deg, rgba(109,139,255,.18), rgba(160,107,255,.12));
  border-color: rgba(140,150,255,.30);
}
.briefing-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.briefing-title { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 700; }
.briefing-summary { margin: 0 0 14px; font-size: 16px; line-height: 1.5; }

.voice-quick { display: inline-flex; background: rgba(0,0,0,.25); border-radius: 999px; padding: 3px; gap: 2px; }
.vq-btn { border: none; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer; min-height: 36px; }
.vq-btn.active { background: var(--accent); color: #07102b; }

.briefing-controls { display: flex; align-items: center; gap: 8px; }

.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #06102b; }
.btn.ghost { background: rgba(255,255,255,.05); }
.btn.small { padding: 9px 14px; font-size: 13px; min-height: 44px; }
.btn.danger { color: var(--danger); border-color: rgba(255,107,125,.4); }
.btn.lock-btn { background: rgba(255,255,255,.05); }

.speaking-dot { display: inline-flex; gap: 4px; margin-left: 6px; }
.speaking-dot span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
.speaking-dot span:nth-child(2) { animation-delay: .2s; }
.speaking-dot span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 0%,100% { transform: scale(.6); opacity: .4; } 50% { transform: scale(1); opacity: 1; } }

.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 22px 6px 10px; font-weight: 700; }

.feed { display: flex; flex-direction: column; gap: 8px; }
.feed-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.feed-icon {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center; font-size: 19px;
  background: rgba(255,255,255,.06);
}
.feed-body { flex: 1; min-width: 0; }
.feed-row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.feed-title { font-size: 15px; font-weight: 600; }
.feed-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed-detail { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.feed-empty { color: var(--muted); font-size: 14px; padding: 8px 6px; }

.home-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.home-actions .btn { flex: 1 1 30%; text-align: center; }

/* ================= SETTINGS SHEET ================= */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); z-index: 20; animation: fade .25s ease; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: 92%;
  background: var(--card-solid);
  border-top-left-radius: 26px; border-top-right-radius: 26px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column;
  animation: slideUp .3s cubic-bezier(.2,.8,.2,1);
  box-shadow: 0 -20px 50px rgba(0,0,0,.5);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grabber { width: 42px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.25); margin: 10px auto 4px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 18px 10px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-body { overflow-y: auto; padding: 16px 18px 30px; display: flex; flex-direction: column; gap: 22px; }

.set-group { display: flex; flex-direction: column; gap: 9px; }
.set-group.demo { border-top: 1px dashed var(--line); padding-top: 18px; }
.set-label { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; margin: 0; }
.set-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.set-input {
  background: rgba(255,255,255,.05); border: 1px solid var(--line); color: var(--text);
  border-radius: 11px; padding: 11px 12px; font-size: 15px; width: 100%;
}
.set-input.small { width: auto; flex: 1; padding: 8px 10px; }
/* Custom caret so dropdowns read as selectable lists, not text inputs. */
select.set-input {
  appearance: none; -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa6c4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.seg { display: inline-flex; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px; gap: 3px; align-self: flex-start; }
.seg-btn { border: none; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; padding: 8px 18px; border-radius: 9px; cursor: pointer; min-height: 44px; }
.seg-btn.active { background: var(--accent); color: #07102b; }

.slider-row { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.slider-row.inline { flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
.slider-row input[type=range] { width: 100%; accent-color: var(--accent); }

.toggle-row, .radio-row { display: flex; gap: 11px; align-items: flex-start; font-size: 15px; cursor: pointer; padding: 4px 0; }
.toggle-row input, .radio-row input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; }
.radio-row span { display: flex; flex-direction: column; }
.radio-row small { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.cond { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-left: 28px; }

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cat-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  border-radius: 11px; padding: 10px 11px; font-size: 14px; cursor: pointer;
  user-select: none;
  /* reset <button> defaults */
  font-family: inherit; color: var(--text); text-align: left; width: 100%; min-height: 44px;
}
.cat-chip.on { background: rgba(109,139,255,.18); border-color: rgba(140,150,255,.4); }
.cat-chip .chk { margin-left: auto; opacity: .4; }
.cat-chip.on .chk { opacity: 1; color: var(--good); }

/* Apps & permissions */
.set-hint { margin: 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.perm-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.perm-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line);
  border-radius: 12px; padding: 8px 10px;
}
.perm-icon { font-size: 18px; width: 24px; text-align: center; flex: 0 0 auto; }
.perm-label { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 15px; font-weight: 600; }
.perm-label small { font-size: 11.5px; font-weight: 500; color: var(--muted); margin-top: 1px; }
.perm-sel { width: auto; flex: 0 0 auto; min-height: 40px; padding: 8px 30px 8px 11px; font-size: 14px; }

.hidden { display: none !important; }

/* Respect users who ask for reduced motion: kill the looping/entrance animations. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .swipe-bar, .speaking-dot span { animation: none !important; }
}
