@font-face {
  font-family: "Google Sans";
  src: url("fonts/google-sans-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Google Sans";
  src: url("fonts/google-sans-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #F4F5F9;
  --card: #FFFFFF;
  --border: #E6E8EF;
  --text: #14161C;
  --muted: #6B7080;
  --primary: #16A34A;
  --primary-hover: #12893E;
  --subtle: #EEF0F5;
  --subtle-hover: #E2E5EC;
  --switch-off: #D5D9E2;
  --switch-knob: #7A8090;
  --flame: #F97316;
  --hero: #FFF4EA;
  --ok: #16A34A;
  --ok-bg: #DCFCE7;
  --err: #DC2626;
  --err-bg: #FEE2E2;
  --warn: #B45309;
  --warn-bg: #FEF3C7;
  --link: #2563EB;
  --segment-selected: #FFFFFF;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0F1115;
    --card: #1A1D24;
    --border: #262A33;
    --text: #F2F3F7;
    --muted: #8D93A3;
    --primary: #22C55E;
    --primary-hover: #1DB053;
    --subtle: #242833;
    --subtle-hover: #2E3340;
    --switch-off: #3A3F4B;
    --switch-knob: #FFFFFF;
    --flame: #FB923C;
    --hero: #2A1E14;
    --ok: #4ADE80;
    --ok-bg: #163322;
    --err: #F87171;
    --err-bg: #3B1717;
    --warn: #FBBF24;
    --warn-bg: #3A2E12;
    --link: #60A5FA;
    --segment-selected: #3A3F4B;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0F1115;
  --card: #1A1D24;
  --border: #262A33;
  --text: #F2F3F7;
  --muted: #8D93A3;
  --primary: #22C55E;
  --primary-hover: #1DB053;
  --subtle: #242833;
  --subtle-hover: #2E3340;
  --switch-off: #3A3F4B;
  --switch-knob: #FFFFFF;
  --flame: #FB923C;
  --hero: #2A1E14;
  --ok: #4ADE80;
  --ok-bg: #163322;
  --err: #F87171;
  --err-bg: #3B1717;
  --warn: #FBBF24;
  --warn-bg: #3A2E12;
  --link: #60A5FA;
  --segment-selected: #3A3F4B;
  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(18px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(24px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1, h2, p, dl, dd {
  margin: 0;
}

a {
  color: var(--link);
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.error-text { color: var(--err); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.header-text {
  flex: 1;
  min-width: 0;
}

.header-text p {
  font-size: 13px;
}

.app-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.icon-button {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--subtle);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  text-decoration: none;
  font-family: -apple-system, system-ui, sans-serif;
}

.icon-button:hover,
.icon-button:active {
  background: var(--subtle-hover);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--hero);
  border-radius: 14px;
  padding: 16px 18px;
}

.hero-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-flame {
  font-size: 40px;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

.hero-number {
  font-size: 40px;
  font-weight: 700;
  color: var(--flame);
  line-height: 1.1;
}

.pill {
  display: inline-block;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
}

.pill-ok { color: var(--ok); background: var(--ok-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }

.account {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 2px;
}

.account strong {
  font-size: 15px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 0;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

.btn-primary {
  min-height: 50px;
  border-radius: 14px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 16px;
  padding: 10px 16px;
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--primary-hover);
}

.btn-secondary {
  min-height: 40px;
  border-radius: 10px;
  background: var(--subtle);
  font-size: 13px;
  padding: 8px 12px;
}

.btn-secondary:hover,
.btn-secondary:active {
  background: var(--subtle-hover);
}

.btn[disabled] {
  opacity: .5;
  cursor: default;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
}

.button-row form {
  display: flex;
}

.link-button {
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px;
}

.row-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.row-text {
  flex: 1 1 160px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-title {
  font-size: 14px;
  font-weight: 700;
}

.row-sub {
  font-size: 12px;
}

.row-extra {
  display: flex;
  align-items: center;
}

.time-sep {
  font-weight: 700;
  padding: 0 4px;
}

.pill-select {
  min-height: 36px;
  min-width: 58px;
  border: 0;
  border-radius: 10px;
  background: var(--subtle);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 6px 10px;
  text-align: center;
}

.switch {
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track,
.switch-button {
  display: block;
  width: 52px;
  height: 32px;
  border-radius: 16px;
  background: var(--switch-off);
  position: relative;
  transition: background .15s ease;
}

.switch-track::after,
.switch-button::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--switch-knob);
  transition: transform .15s ease, width .15s ease, height .15s ease, top .15s ease, left .15s ease;
}

.switch input:checked + .switch-track,
.switch-button[aria-checked="true"] {
  background: var(--primary);
}

.switch input:checked + .switch-track::after,
.switch-button[aria-checked="true"]::after {
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  background: #FFFFFF;
  transform: translateX(20px);
}

.switch input:focus-visible + .switch-track,
.switch-button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.switch-button {
  flex: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.facts dd {
  font-weight: 700;
  font-size: 14px;
  margin-top: 2px;
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-row {
  display: flex;
  gap: 10px;
  padding: 5px 2px;
}

.dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 5px;
  margin-top: 5px;
}

.dot-ok { background: var(--ok); }
.dot-err { background: var(--err); }

.history-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}

.history-message {
  font-size: 13px;
}

.history-meta {
  font-size: 11px;
  white-space: pre-wrap;
}

.empty {
  text-align: center;
  padding: 20px 0;
  font-size: 13px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.flashes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flash,
.alert {
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn, .alert-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error, .alert-error { background: var(--err-bg); color: var(--err); }

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  padding: 12px;
}

.field textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 0;
  border-color: transparent;
}

.code-input {
  letter-spacing: .3em;
  text-align: center;
  font-size: 22px !important;
  font-weight: 700 !important;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--subtle);
}

.segment {
  flex: 1;
  position: relative;
}

.segment input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

.segment input:checked + span {
  background: var(--segment-selected);
}

.segment input:focus-visible + span {
  outline: 2px solid var(--link);
}

.segmented .save-button {
  flex: 0 0 auto;
  width: auto;
}

.js .save-button {
  display: none;
}

.secret-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--subtle);
  border-radius: 12px;
  padding: 12px;
}

.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .05em;
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}

.auth {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 6vh;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.auth-logo {
  border-radius: 18px;
}

@media (max-width: 360px) {
  .screen {
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
  }

  .card {
    padding: 14px;
  }

  .hero-number,
  .hero-flame {
    font-size: 34px;
  }

  .facts {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
