:root {
  color-scheme: light;
  --purple: #6323dc;
  --purple-dark: #4c16b8;
  --purple-light: #f0eafb;
  --ink: #171525;
  --muted: #55515f;
  --green: #22b14c;
  --red: #f04458;
  --line: #e8e5ed;
  --white: #fff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: #fff;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body { min-width: 320px; min-height: 100%; margin: 0; background: #fff; }
body { min-height: 100dvh; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #b28bff; outline-offset: 3px; }
[hidden] { display: none !important; }

.app {
  position: relative;
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--white);
  padding: max(16px, env(safe-area-inset-top)) 24px max(20px, env(safe-area-inset-bottom));
}
.screen { min-height: calc(100dvh - max(36px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); }
.material-symbols-rounded { font-family: "Material Symbols Rounded"; font-weight: normal; font-style: normal; font-size: 24px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-feature-settings: "liga"; -webkit-font-smoothing: antialiased; font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon-button:hover { background: #f7f5fa; }
.settings-shortcut { position: absolute; z-index: 2; right: 18px; top: max(64px, env(safe-area-inset-top)); }
.settings-shortcut .material-symbols-rounded { font-size: 28px; }
.screen-header { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.screen-header h1 { flex: 1; margin: 0; text-align: center; font-size: 24px; line-height: 1.2; font-weight: 750; letter-spacing: -.04em; }
.header-spacer { width: 44px; }

.home-screen { display: flex; flex-direction: column; justify-content: space-between; padding-top: 66px; padding-bottom: 58px; }
.home-content { width: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; margin: 47px 0 0; padding: 12px 0 28px; }
.home-mark { display: block; width: 177px; height: 183px; object-fit: fill; margin: 0 auto 24px; }
.home-content h1 { margin: 0; font-size: clamp(40px, 11.2vw, 44px); font-weight: 800; line-height: 1.05; letter-spacing: -.025em; }
.home-description { max-width: 286px; margin: 30px 0 0; font-size: 20px; line-height: 1.35; color: var(--ink); letter-spacing: -.018em; }
.home-actions { display: grid; gap: 18px; width: calc(100% - 12px); margin: 0 auto; }
.home-actions .button { min-height: 68px; border-radius: 22px; }
.button { min-height: 54px; border: 0; border-radius: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 11px; padding: 0 20px; font-weight: 700; font-size: 16px; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease; touch-action: manipulation; }
.button:active { transform: scale(.985); }
.button:disabled { cursor: wait; opacity: .62; }
.button-primary { color: #fff; background: linear-gradient(105deg, var(--purple), var(--purple-dark)); box-shadow: 0 7px 17px rgb(86 31 195 / 14%); }
.button-primary:hover { box-shadow: 0 9px 21px rgb(86 31 195 / 24%); }
.button-primary .material-symbols-rounded { font-size: 26px; }
.button-soft { color: var(--purple-dark); background: var(--purple-light); }
.button-soft:hover { background: #e8defb; }
.button-danger { color: #fff; background: var(--red); }

.setup-screen { display: flex; flex-direction: column; padding-bottom: 16px; }
.setup-heading { text-align: center; margin: 20px auto 18px; max-width: 350px; }
.setup-heading h1 { margin: 0 0 10px; font-size: 27px; line-height: 1.15; font-weight: 750; letter-spacing: -.045em; }
.setup-heading p { margin: 0; font-size: 15px; line-height: 1.34; color: var(--ink); }
.camera-frame { position: relative; width: 100%; overflow: hidden; border-radius: 20px; background: #f7f5fa; isolation: isolate; }
.setup-visual { aspect-ratio: 1.3 / 1; min-height: 205px; max-height: 290px; margin: auto 0 10px; }
.setup-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #eceaf0; visibility: hidden; }
.camera-frame.has-camera .camera-video { visibility: visible; }
.camera-overlay { position: absolute; inset: 0; pointer-events: none; }
.region-band { position: absolute; left: 8%; right: 8%; top: var(--region-top, 30%); height: var(--region-height, 40%); border-top: 1.5px dashed rgb(99 35 220 / 55%); border-bottom: 1.5px dashed rgb(99 35 220 / 55%); background: rgb(99 35 220 / 6%); }
.camera-guide { position: absolute; inset: 6%; border: 2px solid rgb(99 35 220 / 75%); border-radius: 14px; }
.camera-status { min-height: 38px; margin: 0 0 5px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.45; }
.camera-status[data-kind="error"] { color: #bf2d43; }
.setup-controls { display: flex; justify-content: center; align-items: center; gap: 14px; min-height: 34px; }
.compact-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.compact-field select, .select-setting select, .select-setting input { border: 1px solid var(--line); border-radius: 11px; min-height: 38px; background: #fff; padding: 0 10px; color: var(--ink); }
.setup-bottom { margin-top: auto; display: grid; gap: 8px; padding-top: 12px; }
.setup-calibrate { align-self: center; font-size: 12px; min-height: 30px; }
.setup-calibrate.calibration-success { color: #16733a; }
.text-button { border: 0; padding: 8px 10px; color: var(--purple-dark); background: transparent; font-weight: 650; cursor: pointer; }
.text-button:hover { text-decoration: underline; }
.demo-link { font-size: 13px; min-height: 35px; }
.setup-loading { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 11px; background: rgb(255 255 255 / 88%); color: var(--purple-dark); font-weight: 600; font-size: 14px; }
.spinner { width: 27px; height: 27px; border-radius: 50%; border: 3px solid var(--purple-light); border-top-color: var(--purple); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.activity-screen { display: flex; flex-direction: column; min-height: calc(100dvh - max(36px, env(safe-area-inset-top) + env(safe-area-inset-bottom))); padding-top: 6px; padding-bottom: 5px; }
.activity-topline { display: flex; justify-content: center; align-items: center; gap: 8px; min-height: 38px; color: #154b31; font-size: 13px; font-weight: 600; }
.live-indicator { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgb(34 177 76 / 9%); }
.small-icon-button { position: absolute; right: 17px; top: max(11px, env(safe-area-inset-top)); width: 38px; height: 38px; color: var(--muted); }
.small-icon-button .material-symbols-rounded { font-size: 21px; }
.view-switch { align-self: center; display: inline-flex; padding: 3px; margin: 3px auto 13px; border-radius: 14px; background: #f5f2fa; }
.view-choice { min-width: 84px; min-height: 33px; padding: 0 12px; border: 0; border-radius: 11px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 650; cursor: pointer; }
.view-choice.is-active { color: var(--purple-dark); background: #fff; box-shadow: 0 2px 7px rgb(36 22 60 / 9%); }
.activity-frame { aspect-ratio: 1 / 1; max-height: min(37vh, 310px); min-height: 200px; border-radius: 19px; background: #e6e3ea; }
.activity-frame .camera-video { object-fit: cover; }
.camera-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; color: #716c7a; font-size: 12px; }
.camera-placeholder img { max-width: 68%; max-height: 74%; object-fit: contain; }
.camera-local-label { position: absolute; bottom: 10px; left: 10px; display: flex; align-items: center; gap: 4px; padding: 6px 9px; border-radius: 999px; color: #fff; background: rgb(23 21 37 / 54%); font-size: 10px; font-weight: 600; backdrop-filter: blur(8px); }
.camera-local-label .material-symbols-rounded { font-size: 14px; }
.person-box { position: absolute; left: 35%; top: 16%; width: 30%; height: 70%; border: 2.5px solid #a252ff; border-radius: 5px; box-shadow: 0 0 0 1px rgb(255 255 255 / 40%); transition: left .12s linear, top .12s linear, width .12s linear, height .12s linear; }
.person-box::before { content: ""; position: absolute; inset: -5px; border: 1px solid rgb(203 148 255 / 50%); border-radius: 7px; }
.detection-status { min-height: 29px; margin: 7px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.activity-progress-view { display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 245px; flex: 1; }
.progress-ring { --progress: 0deg; position: relative; width: min(53vw, 230px); aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--purple) var(--progress), #e9e5f0 var(--progress)); transition: background 400ms ease; }
.progress-ring::before { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: #fff; }
.progress-ring-center { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; font-size: 17px; font-weight: 500; line-height: 1.1; }
.staircase-mark { width: 54px; height: 44px; color: var(--purple); margin-bottom: 5px; overflow: visible; }
.staircase-mark path { fill: none; stroke: currentColor; stroke-width: 4.2; stroke-linecap: round; stroke-linejoin: round; }
.progress-ring-center strong { font-size: 28px; font-weight: 750; letter-spacing: -.04em; }
.progress-caption { margin: 13px 0 0; color: var(--muted); font-size: 12px; }
.count-panel { display: flex; flex-direction: column; align-items: center; margin: auto 0 4px; text-align: center; }
.count-panel h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.03em; }
.count-number { color: var(--purple-dark); font-size: clamp(68px, 18vw, 88px); font-weight: 800; line-height: .98; letter-spacing: -.055em; font-variant-numeric: tabular-nums; }
.spoken-count { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 18px; color: var(--ink); }
.spoken-count .material-symbols-rounded { color: var(--purple); font-size: 23px; }
.session-mode { margin-top: 7px; color: #817b89; font-size: 10px; }
.demo-actions { display: flex; flex-direction: column; align-items: center; gap: 3px; margin: 8px 0 3px; }
.demo-badge { color: #6a36b9; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.demo-increment { min-height: 39px; border-radius: 13px; padding-inline: 15px; font-size: 13px; }
.demo-increment .material-symbols-rounded { font-size: 19px; }
.activity-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; padding-top: 13px; }
.activity-actions .button { min-height: 47px; border-radius: 17px; font-size: 13px; gap: 6px; padding: 0 12px; }
.activity-actions .material-symbols-rounded { font-size: 19px; }
.activity-screen.is-paused .live-indicator { background: #e9a421; }
.activity-screen.is-paused .activity-topline { color: #765314; }
.activity-screen.is-progress .view-switch { margin-bottom: 16px; }
.activity-screen.is-progress .count-panel { margin: 8px 0 0; }
.activity-screen.is-progress .count-panel h1 { margin-bottom: 8px; font-size: 22px; }
.activity-screen.is-progress .count-number { font-size: clamp(104px, 30vw, 122px); line-height: .92; }
.activity-screen.is-progress .spoken-count { margin-top: 8px; font-size: 20px; }
.activity-screen.is-progress .spoken-count .material-symbols-rounded { font-size: 27px; }
.activity-screen.is-progress .session-mode,
.activity-screen.is-progress .progress-caption { display: none; }
.activity-screen.is-progress .progress-ring { width: min(65vw, 260px); transform: translateY(24px); }
.activity-screen.is-progress .activity-progress-view { min-height: 245px; }
.activity-screen.is-progress .progress-ring-center { font-size: 20px; }
.activity-screen.is-progress .progress-ring-center strong { font-size: 38px; }
.activity-screen.is-progress .staircase-mark { width: 68px; height: 55px; margin-bottom: 5px; }
.activity-screen.is-progress { padding-bottom: 12px; }
.activity-screen.is-progress .activity-actions .button { min-height: 60px; font-size: 14px; }
.activity-screen.is-progress .demo-actions { margin-top: 3px; }

.completion-screen { display: flex; flex-direction: column; justify-content: space-between; padding: 8px 0 5px; text-align: center; }
.completion-content { display: flex; flex-direction: column; align-items: center; margin: auto 0; }
.trophy-art { width: min(64vw, 260px); aspect-ratio: 1.3 / 1; object-fit: contain; margin-bottom: 4px; }
.completion-content h1 { margin: 5px 0 8px; font-size: 37px; font-weight: 800; line-height: 1; letter-spacing: -.05em; }
.completion-lead { margin: 0; font-size: 19px; }
.completion-count { margin: -1px 0 0; color: var(--purple-dark); font-size: clamp(72px, 22vw, 91px); font-weight: 800; line-height: 1.05; letter-spacing: -.06em; }
.completion-subtitle { margin: 0; font-size: 18px; font-weight: 700; }
.celebration-card { display: flex; align-items: flex-start; gap: 11px; width: 100%; margin: 24px 0 14px; padding: 14px 16px; border-radius: 18px; background: #f2ebfc; text-align: left; }
.celebration-icon { flex: 0 0 auto; font-size: 25px; line-height: 1.1; }
.celebration-card p { margin: 0; font-size: 14px; line-height: 1.35; }
.completion-actions { display: grid; gap: 7px; width: 100%; }
.completion-actions .button { min-height: 51px; }

.history-screen, .detail-screen, .settings-screen { display: flex; flex-direction: column; }
.history-screen { width: calc(100% + 24px); margin-left: -12px; padding-top: 77px; }
.history-screen .screen-header, .detail-screen .screen-header, .settings-screen .screen-header { margin-bottom: 22px; }
.history-screen .screen-header { margin-bottom: 15px; }
.history-screen .screen-header h1 { font-size: 30px; }
.history-screen .screen-header .material-symbols-rounded { font-size: 28px; }
.history-note { margin: -4px 0 0; padding: 4px 12px; border-radius: 12px; background: #faf8fd; color: #716a7a; font-size: 11px; text-align: center; }
.history-list { display: grid; gap: 20px; }
.history-row { display: flex; align-items: center; width: 100%; min-height: 65px; gap: 16px; padding: 10px 18px; border: 0; border-bottom: 1px solid var(--line); border-radius: 18px; background: #fff; text-align: left; cursor: pointer; }
.history-row:hover { background: #faf8fd; }
.history-row.is-featured { min-height: 84px; border-bottom-color: transparent; background: linear-gradient(110deg, #efe8fb, #f4effc); }
.history-icon { color: #77717e; font-size: 26px; }
.history-row.is-featured .history-icon, .history-row.is-featured .history-chevron { color: var(--purple-dark); }
.history-copy { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.history-date { font-size: 18px; font-weight: 600; }
.history-count { font-size: 20px; }
.history-chevron { color: #77717e; font-size: 26px; }
.history-tag { color: #7e738a; font-size: 10px; }
.empty-history { margin: 30px 8px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.detail-card { padding: 22px 20px; border-radius: 20px; background: #f6f2fc; }
.detail-date { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.detail-number { margin: 0; color: var(--purple-dark); font-size: 62px; font-weight: 800; letter-spacing: -.06em; }
.detail-subtitle { margin: 0 0 21px; font-weight: 650; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; padding-top: 17px; border-top: 1px solid #e4dcec; }
.detail-item span { display: block; color: #77717e; font-size: 11px; margin-bottom: 4px; }
.detail-item strong { display: block; font-size: 14px; font-weight: 650; }
.detail-disclaimer { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.settings-screen { padding-top: 3px; }
.settings-screen .screen-header { flex: 0 0 auto; margin-bottom: 10px; }
.settings-scroll { overflow-y: auto; flex: 1; min-height: 0; padding: 0 1px 25px; scrollbar-width: thin; }
.settings-group { padding: 16px 0; border-bottom: 1px solid var(--line); }
.settings-group h2 { margin: 0 0 10px; font-size: 15px; font-weight: 750; letter-spacing: -.02em; }
.setting-row { min-height: 47px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.switch-input { appearance: none; position: relative; width: 46px; height: 27px; border-radius: 20px; background: #d9d5df; cursor: pointer; transition: background .15s; }
.switch-input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 16%); transition: transform .15s; }
.switch-input:checked { background: var(--purple); }
.switch-input:checked::after { transform: translateX(19px); }
.range-setting { display: block; padding: 9px 0; font-size: 12px; }
.range-setting > span { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ink); }
.range-setting output { color: var(--purple-dark); font-weight: 650; }
.range-setting input[type="range"] { width: 100%; accent-color: var(--purple); }
.select-setting { display: flex; flex-direction: column; gap: 7px; margin: 11px 0; color: var(--ink); font-size: 12px; }
.select-setting select, .select-setting input { width: 100%; font-size: 13px; }
.setting-help { margin: 6px 0 10px; color: var(--muted); font-size: 11px; line-height: 1.42; }
.goal-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 11px 0 13px; }
.goal-chip { min-height: 39px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: #fff; font-size: 12px; font-weight: 650; cursor: pointer; }
.goal-chip.is-selected { color: var(--purple-dark); border-color: #c9b6f0; background: var(--purple-light); }
.calibration-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.calibration-row .button { min-height: 39px; border-radius: 12px; font-size: 12px; padding: 0 12px; white-space: nowrap; }
.calibration-row span { color: var(--muted); font-size: 10px; line-height: 1.35; }
.settings-danger-zone { border-bottom: 0; }
.danger-text { color: #c42d42; padding-left: 0; font-size: 13px; }
.settings-done { width: 100%; margin: 14px 0 8px; }
.install-note { margin: 14px 0 2px; color: var(--muted); font-size: 11px; line-height: 1.4; text-align: center; }
.install-button { width: 100%; }

.confirm-dialog { width: min(calc(100% - 36px), 370px); padding: 0; border: 0; border-radius: 22px; color: var(--ink); background: transparent; box-shadow: 0 16px 50px rgb(15 8 34 / 20%); }
.confirm-dialog::backdrop { background: rgb(23 21 37 / 44%); backdrop-filter: blur(4px); }
.dialog-card { padding: 23px; border-radius: 22px; background: #fff; }
.dialog-card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: -.03em; }
.dialog-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.dialog-actions .button { min-height: 45px; padding: 0 10px; font-size: 13px; border-radius: 14px; }
.calibration-card { text-align: center; }
.calibration-progress { min-height: 42px; display: grid; place-items: center; margin-top: 14px; color: var(--purple-dark); font-size: 13px; font-weight: 650; }
.toast { position: absolute; z-index: 20; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); width: max-content; max-width: calc(100% - 42px); padding: 11px 15px; border-radius: 13px; color: #fff; background: #282432; font-size: 12px; line-height: 1.4; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.screen-reader-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (min-width: 600px) {
  body { padding: 22px 0; background: #f5f3f8; }
  .app { min-height: min(860px, calc(100dvh - 44px)); border-radius: 32px; box-shadow: 0 18px 60px rgb(34 20 60 / 9%); }
  .screen { min-height: min(824px, calc(100dvh - 80px)); }
  .activity-screen { min-height: min(824px, calc(100dvh - 80px)); }
}

@media (max-height: 700px) and (max-width: 599px) {
  .app { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .home-screen { padding-top: 45px; padding-bottom: 24px; }
  .home-content { margin-top: 24px; }
  .home-mark { width: 140px; height: 145px; margin-bottom: 12px; }
  .home-content h1 { font-size: 36px; }
  .home-description { margin-top: 15px; font-size: 17px; }
  .home-actions { gap: 12px; }
  .home-actions .button { min-height: 54px; }
  .setup-heading { margin: 10px auto 10px; }
  .setup-heading h1 { font-size: 23px; }
  .setup-heading p { font-size: 13px; }
  .setup-visual { min-height: 160px; max-height: 230px; }
  .activity-frame { min-height: 170px; max-height: 30vh; }
  .view-switch { margin-bottom: 8px; }
  .count-number { font-size: 66px; }
  .trophy-art { width: min(48vw, 190px); }
  .completion-content h1 { font-size: 31px; }
  .completion-count { font-size: 70px; }
  .celebration-card { margin: 15px 0 8px; padding: 10px 13px; }
}

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