/* SwearGuard Parent: grouped lists, plain line icons, system fonts. It should
   feel like the phone's own Settings and Screen Time screens. */
:root {
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --ink: #111318;
  --ink-2: #5f6570;
  --ink-3: #8e939c;
  --hair: rgba(60, 60, 67, .16);
  --track: #e6e6eb;
  --seg-on: #ffffff;
  --brand: #2759e6;
  --brand-tint: #e8eefd;
  --green: #1f9d55;
  --green-tint: #e4f4ea;
  --red: #d63a3a;
  --red-tint: #fbe8e8;
  --orange: #c96f00;
  --orange-tint: #fcf0df;
  --violet: #6d4ae0;
  --violet-tint: #eeeafc;
  --grey-tint: #ececf0;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --ink: #f2f2f7;
    --ink-2: #aeaeb4;
    --ink-3: #7c7c83;
    --hair: rgba(84, 84, 88, .6);
    --track: #2c2c2e;
    --seg-on: #636366;
    --brand: #5b8bff;
    --brand-tint: #1a2546;
    --green: #32c46e;
    --green-tint: #10301e;
    --red: #ff5f57;
    --red-tint: #3b1614;
    --orange: #ffa53d;
    --orange-tint: #3a2810;
    --violet: #9d80ff;
    --violet-tint: #271e48;
    --grey-tint: #2c2c2e;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.inline { width: 15px; height: 15px; vertical-align: -2px; stroke-width: 2; }

main {
  max-width: 600px; margin: 0 auto;
  padding: calc(8px + env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom));
}
body.bare main { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }

/* ----- page titles ----- */
.title { padding: 16px 4px 4px; }
.title h1, .title .pc {
  margin: 0; font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em;
  display: inline-flex; align-items: center; gap: 6px; text-align: left;
}
.title .pc .i { width: 20px; height: 20px; color: var(--ink-3); stroke-width: 2.4; margin-top: 4px; }
.title .pc[disabled] { cursor: default; }
.title .sub { display: flex; align-items: center; gap: 7px; margin-top: 3px; color: var(--ink-2); font-size: 15px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.dot.on { background: var(--green); }
.dot.problem { background: var(--red); }

/* ----- grouped lists ----- */
.sec {
  margin: 28px 16px 7px; font-size: 13px; font-weight: 600; letter-spacing: .03em;
  text-transform: uppercase; color: var(--ink-3);
}
.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.foot { margin: 8px 16px 0; color: var(--ink-3); font-size: 13px; line-height: 1.4; }
.foot.center { text-align: center; margin-top: 30px; }
.row-item {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 50px; padding: 10px 16px; text-align: left; background: none;
}
.row-item + .row-item::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--hair); }
.row-item.has-tile + .row-item::before, .row-item + .row-item.has-tile::before { left: 58px; }
button.row-item:active, label.row-item:active { background: var(--surface-2); }
label.row-item { cursor: pointer; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-size: 16px; }
.row-sub { font-size: 13px; color: var(--ink-2); }
.row-sub.bad { color: var(--red); }
.row-end { flex: none; display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.chev { width: 15px; height: 15px; color: var(--ink-3); stroke-width: 2.4; margin-right: -4px; }
.brand-text { color: var(--brand); }
.danger-text { color: var(--red); }
.when { font-size: 13px; color: var(--ink-3); align-self: flex-start; margin-top: 2px; }
.badge {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 6px;
  background: var(--brand-tint); color: var(--brand); font-size: 11px; font-weight: 600; vertical-align: 2px;
}

/* coloured icon squares, like the phone's own settings */
.tile { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; color: #fff; font-weight: 700; font-size: 15px; }
.tile .i { width: 18px; height: 18px; stroke-width: 2; }
.tile.red { background: #ee4b3f; }
.tile.orange { background: #f59a0b; }
.tile.green { background: #22a95b; }
.tile.blue { background: #3478f6; }
.tile.violet { background: #7b5cf5; }
.tile.teal { background: #11a39a; }
.tile.pink { background: #e5487d; }
.tile.grey { background: #8e8e93; }
.tile.plain { background: none; color: var(--brand); }
.tile.plain .i { width: 22px; height: 22px; }
.tile.num { background: var(--brand-tint); color: var(--brand); border-radius: 50%; }
.tile.lg { width: 56px; height: 56px; border-radius: 14px; font-size: 24px; }
.tile img { width: 100%; height: 100%; border-radius: inherit; }

.bar { height: 6px; margin-top: 7px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > div { height: 100%; border-radius: 3px; background: var(--brand); }
.bar.violet > div { background: var(--violet); }
.bar > div.full { background: var(--red); }

/* ----- the status panel on Home ----- */
.panel { margin-top: 12px; padding: 18px; border-radius: 18px; background: var(--surface); }
.panel.tint-red { background: var(--red-tint); }
.panel.tint-violet { background: var(--violet-tint); }
.panel.tint-orange { background: var(--orange-tint); }
.panel.tint-grey { background: var(--grey-tint); }
.panel.request { background: var(--brand-tint); }
.state { display: flex; align-items: center; gap: 14px; }
.state h2 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; }
.state p { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.request .state { align-items: flex-start; }
.request h2 { font-size: 17px; font-weight: 600; }
.orb { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; }
.orb .i { width: 24px; height: 24px; stroke-width: 2; }
.orb.green { background: var(--green); }
.orb.red { background: var(--red); }
.orb.violet { background: var(--violet); }
.orb.orange { background: var(--orange); }
.orb.grey { background: var(--ink-3); }
.orb.blue { background: var(--brand); }
.countdown { margin: 16px 0 0; font-size: 46px; line-height: 1; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.countdown-label { margin-top: 4px; color: var(--ink-2); font-size: 14px; }
.panel-split {
  display: flex; align-items: center; gap: 16px; width: calc(100% + 36px); text-align: left;
  margin: 16px -18px -4px; padding: 14px 18px 0; border-top: .5px solid var(--hair);
}
.panel-split .grow { flex: 1; }
.big { font-size: 22px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); font-size: 14px; }

.ring { display: block; }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring .track { stroke: var(--track); }
.ring-wrap { position: relative; flex: none; }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: 17px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.ring-label small { font-size: 11px; color: var(--ink-2); }
.summary { display: flex; align-items: center; gap: 18px; }
.summary .muted + .muted { margin-top: 6px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 18px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.wd .col { width: 100%; max-width: 28px; height: 52px; display: flex; align-items: flex-end; border-radius: 7px; background: var(--track); overflow: hidden; }
.wd .col > div { width: 100%; border-radius: 7px; background: var(--violet); opacity: .45; }
.wd.today .col > div { opacity: 1; }
.wd b { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.wd.today b { color: var(--violet); }

/* ----- quick actions ----- */
.qa { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 20px; }
.qa button { display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.qa .circle { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--brand); transition: transform .12s; }
.qa .circle.red { color: var(--red); }
.qa .circle.green { color: var(--green); }
.qa button:active .circle { transform: scale(.93); }

/* ----- buttons and controls ----- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; border-radius: 13px;
  background: var(--surface); color: var(--brand); font-size: 16px; font-weight: 600;
}
.btn .i { width: 20px; height: 20px; stroke-width: 2; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.dark { background: var(--ink); color: var(--bg); }
.btn.tonal { background: rgba(127, 127, 140, .14); color: var(--ink); }
.btn.plain { background: none; }
.btn.danger { color: var(--red); }
.btn:active { opacity: .75; }
.btn[disabled] { opacity: .45; }
.btns { display: flex; gap: 10px; margin-top: 16px; }
.btns > .btn { flex: 1; }
.btns.col { flex-direction: column; }
.pill {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 999px;
  background: var(--brand-tint); color: var(--brand); font-size: 14px; font-weight: 600;
}
.pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 4px 0; }
.pills .label { color: var(--ink-3); font-size: 13px; margin-right: 2px; }

.seg { display: flex; padding: 2px; margin-bottom: 10px; border-radius: 10px; background: var(--track); }
.seg button { flex: 1; min-height: 34px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg button.on.bad { color: var(--red); }

.stepper { display: flex; align-items: center; gap: 4px; }
.stepper .val { min-width: 86px; text-align: center; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.stepper .val.none { color: var(--ink-3); }
.step { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--brand); }
.step .i { width: 17px; height: 17px; stroke-width: 2.6; }
.step:active { background: var(--track); }

.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--track); transition: background .2s; pointer-events: none; }
.switch span::before {
  content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(20px); }

.select {
  -webkit-appearance: none; appearance: none; max-width: 200px; padding: 6px 18px 6px 0; border: 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e939c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 10l4-4 4 4M8 14l4 4 4-4'/%3E%3C/svg%3E") no-repeat right center / 15px;
  color: var(--ink-2); font-size: 15px; text-align: right; text-align-last: right;
}
.time {
  -webkit-appearance: none; appearance: none; min-width: 92px; padding: 6px 10px; border: 0; border-radius: 8px;
  background: var(--surface-2); color: var(--ink); font-size: 16px; text-align: center; font-variant-numeric: tabular-nums;
}
.days { display: flex; justify-content: space-between; gap: 4px; width: 100%; }
.daychip { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font-size: 14px; font-weight: 600; }
.daychip.on { background: var(--brand); color: #fff; }
.dim { opacity: .45; }

.plain-input { width: 100%; padding: 4px 0; border: 0; outline: none; background: none; font-size: 16px; }
.search { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; padding: 0 10px; border-radius: 10px; background: var(--track); color: var(--ink-3); }
.search .i { width: 18px; height: 18px; }
.search input { flex: 1; padding: 9px 0; border: 0; outline: none; background: none; font-size: 16px; color: var(--ink); }
.message-box { display: block; width: 100%; min-height: 96px; padding: 12px 14px; border: 0; border-radius: 12px; outline: none; background: var(--surface); resize: none; font-size: 16px; }
.app-head { display: flex; align-items: center; gap: 14px; margin: 6px 4px 18px; }
.app-head .name { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }

/* ----- welcome ----- */
.welcome { padding: 44px 12px 4px; text-align: center; }
.app-icon { width: 88px; height: 88px; border-radius: 21px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); }
.welcome h1 { margin: 20px 0 8px; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.welcome p { max-width: 360px; margin: 0 auto; color: var(--ink-2); }
.empty { padding: 48px 24px; text-align: center; color: var(--ink-3); }
.empty .i { width: 40px; height: 40px; stroke-width: 1.5; }

.notice { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--red-tint); color: var(--red); font-size: 14px; }
.notice .i { width: 18px; height: 18px; margin-top: 1px; }

/* ----- tab bar and save bar ----- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--hair);
}
.tabs[hidden] { display: none; }
.tabs button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 3px 0; font-size: 11px; font-weight: 500; color: var(--ink-3); }
.tabs .i { width: 25px; height: 25px; stroke-width: 1.7; }
.tabs button.on { color: var(--brand); }
.tabs button.on .i { stroke-width: 2.1; }

.savebar {
  position: fixed; left: 12px; right: 12px; z-index: 11; bottom: calc(66px + env(safe-area-inset-bottom));
  max-width: 576px; margin: 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--ink); color: var(--bg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.savebar[hidden] { display: none; }
.savebar span { flex: 1; font-size: 15px; font-weight: 500; }
.savebar button { min-height: 38px; padding: 0 14px; border-radius: 10px; font-size: 15px; font-weight: 600; color: inherit; }
.savebar .primary { background: var(--brand); color: #fff; }

/* ----- sheets ----- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; background: rgba(0, 0, 0, .4); animation: fade .2s ease-out; }
.sheet[hidden] { display: none; }
.sheet-card {
  width: 100%; max-width: 600px; max-height: 92vh; margin: 0 auto; overflow: auto;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0;
  background: var(--bg); animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}
.grabber { width: 36px; height: 5px; margin: 0 auto 8px; border-radius: 3px; background: var(--ink-3); opacity: .4; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 4px 14px; }
.sheet-head h3 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.x { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--track); color: var(--ink-2); flex: none; }
.x .i { width: 15px; height: 15px; stroke-width: 2.6; }
.sheet-head + .sec { margin-top: 4px; }
@keyframes rise { from { transform: translateY(48px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

/* ----- QR scanner ----- */
.scanner { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: #000; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 24% 14%; border: 3px solid #fff; border-radius: 26px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5); }
.scanner .tip { position: absolute; left: 0; right: 0; bottom: calc(100px + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-weight: 600; }
.scanner .close { position: absolute; left: 16px; right: 16px; bottom: calc(28px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .16); color: #fff; }

.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); z-index: 40; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}
.toast[hidden] { display: none; }
