/* keyissue look (same in every app; only the accent changes): soft grey ground,
   white cards, the phone's own font. Light and dark follow the phone. */
:root {
  --bg: #F2F2F5; --surface: #FFFFFF; --sunk: #EDEDF1; --line: #E4E4E9;
  --fg: #111114; --muted: #5F5F6B;
  --accent: #9F1239; --accent-ink: #FFFFFF; --accent-soft: #FCE7EB;
  --warn: #B42318;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow: 0 1px 2px rgb(17 17 20 / .04), 0 4px 16px rgb(17 17 20 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0B0E; --surface: #1C1C21; --sunk: #26262C; --line: #2E2E35;
    --fg: #F4F4F6; --muted: #A1A1AA;
    --accent: #FDA4AF; --accent-ink: #0B0B0E; --accent-soft: #3A1520;
    --warn: #F97066; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B0B0E; --surface: #1C1C21; --sunk: #26262C; --line: #2E2E35;
    --fg: #F4F4F6; --muted: #A1A1AA;
    --accent: #FDA4AF; --accent-ink: #0B0B0E; --accent-soft: #3A1520;
    --warn: #F97066; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; text-wrap: balance; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 2.125rem; line-height: 1.1; letter-spacing: -.025em; }
h2 { font-size: 1.2rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.wrap { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(96px + env(safe-area-inset-bottom, 0px)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.brand img { border-radius: 8px; }
main { display: flex; flex-direction: column; gap: 18px; }
.section-title { font-size: .82rem; letter-spacing: .01em; color: var(--muted); font-weight: 600; margin: 6px 0 -6px; }

.btn { font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid transparent; background: var(--sunk); transition: transform .1s ease, filter .15s ease; color: var(--fg); }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--warn); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; }
.btn:disabled { opacity: .6; cursor: progress; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; border: 0; background: var(--surface); box-shadow: var(--shadow); color: var(--fg); cursor: pointer; font-size: 1.1rem; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--sunk); position: sticky; top: calc(6px + env(safe-area-inset-top, 0px)); z-index: 2; }
.tabs button { flex: 1; font: inherit; font-weight: 600; font-size: .92rem; min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; position: relative; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.tabs .dot { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--wait); color: #fff; font-size: .72rem; }

.card { background: var(--surface); border: 1px solid transparent; border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }



.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: .84rem; }
.empty { color: var(--muted); font-size: .95rem; text-align: center; padding: 18px 8px; }

dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto; border: 0; border-radius: 22px; background: var(--surface); color: var(--fg); box-shadow: 0 20px 60px rgb(0 0 0 / .25); }
dialog::backdrop { background: rgb(10 10 25 / .45); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-body { padding: 4px 16px 16px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.sheet-foot .left { margin-right: auto; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-weight: 600; font-size: .9rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .84rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
input, select { font: inherit; font-size: 1rem; padding: 10px 12px; min-height: 44px; border-radius: 12px; min-width: 0; width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: .88rem; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--accent); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.msg { color: var(--warn); font-size: .92rem; margin-top: 10px; }
.msg:empty { display: none; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem; box-shadow: 0 8px 24px rgb(0 0 0 / .2); z-index: 10; }
@media (max-width: 420px) { .pair { grid-template-columns: 1fr; } }

/* ---------- calendar ---------- */
:root { --k-event: var(--accent); --k-birthday: #C2410C; --k-school: #1D4ED8; --k-holiday: #15803D; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --k-birthday: #FDBA74; --k-school: #93B4FB; --k-holiday: #86D9A0; } }
:root[data-theme="dark"] { --k-birthday: #FDBA74; --k-school: #93B4FB; --k-holiday: #86D9A0; }
.k-event { --k: var(--k-event); } .k-birthday { --k: var(--k-birthday); } .k-school { --k: var(--k-school); } .k-holiday { --k: var(--k-holiday); }

.monthbar { display: flex; align-items: center; gap: 8px; }
.monthbar h2 { flex: 1; font-size: 1.35rem; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.grid .wd { text-align: center; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 2px 0; }
.day { font: inherit; color: var(--fg); text-align: left; min-height: 64px; padding: 5px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow: hidden; }
.day.out { background: transparent; color: var(--muted); border-color: transparent; }
.day .n { font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 999px; }
.day.today .n { background: var(--accent); color: var(--accent-ink); }
.day[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.day .bars { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day .bar { display: block; font-size: .7rem; line-height: 1.35; padding: 0 4px; border-radius: 4px; background: color-mix(in srgb, var(--k) 18%, transparent); color: var(--fg);
  border-left: 3px solid var(--k); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day .more { font-size: .7rem; color: var(--muted); padding-left: 4px; }
@media (max-width: 560px) {
  .day { min-height: 52px; align-items: center; padding: 4px 2px; }
  .day .bars { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .day .bar { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 999px; background: var(--k); font-size: 0; }
  .day .more { display: none; }
}

.agenda { display: flex; flex-direction: column; gap: 14px; }
.dayhead { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.dayhead.is-today { color: var(--accent); }
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); border-left: 5px solid var(--k);
  background: var(--surface); color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
.item .em { font-size: 1.25rem; flex: none; width: 26px; text-align: center; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .sub { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.item .when { flex: none; font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.lock { font-size: .8rem; }

.kinds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.kinds label { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: .82rem; font-weight: 600; }
.kinds label span { font-size: 1.3rem; }
.kinds input { position: absolute; opacity: 0; pointer-events: none; }
.kinds label:has(input:checked) { border-color: var(--k); background: color-mix(in srgb, var(--k) 14%, transparent); box-shadow: 0 0 0 2px var(--k); }
.kinds label:has(input:focus-visible) { outline: 3px solid var(--accent); }
textarea { font: inherit; font-size: 1rem; padding: 10px 12px; border-radius: 12px; width: 100%; min-height: 80px; resize: vertical; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.inline { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.inline input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.detail dt { font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-top: 12px; }
.detail dd { margin: 2px 0 0; overflow-wrap: anywhere; white-space: pre-wrap; }

.fab { position: fixed; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 5; font: inherit; font-weight: 700; font-size: 1rem;
  min-height: 52px; padding: 12px 20px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; box-shadow: 0 8px 24px rgb(0 0 0 / .22); }
.fab span { font-size: 1.3rem; line-height: 0; margin-right: 2px; }
