:root {
  --accent: #4F7CFF;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --muted: #6E6E73;
  --line: #E5E5EA;
  --fill: #E9E9EE;
  --green: #34C759;
  --orange: #FF9500;
  --red: #FF3B30;
  --radius: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --text: #F2F2F7;
    --muted: #98989F;
    --line: #2C2C2E;
    --fill: #2C2C2E;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#app { max-width: 600px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); min-height: 100vh; }
.splash { padding: 40vh 0 0; text-align: center; color: var(--muted); }

h1 { font-size: 30px; margin: 18px 0 12px; letter-spacing: -0.02em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; margin: 22px 4px 8px; }
p { margin: 6px 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.danger { color: var(--red); }
.ok { color: var(--green); }
.warn { color: var(--orange); }

.top { display: flex; align-items: center; justify-content: space-between; padding-top: calc(10px + env(safe-area-inset-top)); }
.top .family { font-weight: 600; color: var(--muted); font-size: 14px; }

.card { background: var(--card); border-radius: var(--radius); padding: 4px 16px; margin: 0 0 10px; }
.card.pad { padding: 14px 16px; }
.row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { font-size: 13px; color: var(--muted); }
.time { width: 52px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.time b { display: block; }
.time span { font-size: 12px; color: var(--muted); }
.bar { width: 4px; align-self: stretch; border-radius: 2px; flex-shrink: 0; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; border: 2px solid; }

button, .btn {
  font: inherit; border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer;
  background: var(--fill); color: var(--accent); font-weight: 600; text-decoration: none; display: inline-block;
}
button.primary, .btn.primary { background: var(--accent); color: white; }
button.green { background: var(--green); color: white; }
button.red { background: var(--red); color: white; }
button.small { padding: 6px 10px; font-size: 14px; border-radius: 10px; }
button.link { background: none; padding: 6px 0; }
button:disabled { opacity: 0.45; cursor: default; }
button.full { width: 100%; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--fill); border: 0; border-radius: 10px;
  padding: 11px 12px; width: 100%; margin: 4px 0 8px;
}
textarea { min-height: 70px; resize: vertical; }
label { font-size: 14px; color: var(--muted); display: block; margin-top: 6px; }
.code-input { font: 600 26px ui-monospace, Menlo, monospace; letter-spacing: 0.25em; text-transform: uppercase; text-align: center; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; margin: 8px 0; }
.check input { width: auto; margin: 0; }

.week { display: flex; gap: 4px; align-items: center; }
.week button.day { flex: 1; padding: 6px 0; background: none; color: var(--text); font-weight: 400; display: flex; flex-direction: column; align-items: center; }
.week button.day .l { font-size: 11px; color: var(--muted); }
.week button.day.sel { background: color-mix(in srgb, var(--accent) 18%, transparent); font-weight: 700; }
.week button.day.today { outline: 1px solid var(--accent); }
.week button.day.off .n { color: var(--orange); }
.week .nav { background: none; padding: 6px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10;
}
.tabs button { flex: 1; max-width: 120px; background: none; color: var(--muted); font-size: 11px; font-weight: 500; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tabs button .i { font-size: 22px; line-height: 1; }
.tabs button.on { color: var(--accent); }
.badge { position: absolute; top: 0; right: calc(50% - 22px); background: var(--red); color: white; border-radius: 9px; font-size: 11px; min-width: 18px; padding: 0 5px; line-height: 18px; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--fill); }
.banner { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 10px; display: flex; gap: 12px; align-items: center; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }

.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--fill); display: block; cursor: pointer; }
.photo-full img { width: 100%; border-radius: 12px; }

dialog { border: 0; border-radius: 18px; padding: 18px; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog h3 { margin: 0 0 10px; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #1C1C1E; color: white; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: 0.25s; pointer-events: none; z-index: 20; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hero { text-align: center; padding: 8vh 0 12px; }
.hero .logo { font-size: 64px; }
.hero h1 { font-size: 40px; margin: 6px 0; }
.seg { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; margin: 10px 0; }
.seg button { flex: 1; background: none; color: var(--text); font-weight: 500; padding: 8px; border-radius: 8px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 600; }
.bubble { padding: 10px 14px; border-radius: 18px; max-width: 80%; white-space: pre-wrap; }
.bubble.mine { background: var(--accent); color: white; margin-left: auto; }
.bubble.theirs { background: var(--card); }
.msg { margin: 8px 0; display: flex; flex-direction: column; }
.msg .meta { font-size: 11px; color: var(--muted); margin: 2px 6px; }
.msg.mine .meta { text-align: right; }
footer.legal { text-align: center; font-size: 12px; color: var(--muted); margin: 30px 0; }
