:root {
  --bg: #f3f3f4;
  --surface: #ffffff;
  --surface-soft: #fbfbfb;
  --line: #e9e9e9;
  --line-soft: #f2f2f2;
  --ink: #1d1d1f;
  --ink-2: #69696d;
  --ink-3: #a0a0a5;
  --ani-bg: #d5e5f2;
  --ani-fg: #315a75;
  --oto-bg: #d7ead5;
  --oto-fg: #416b3f;
  --haha-bg: #f2d9dc;
  --haha-fg: #85555c;
  --chichi-bg: #f2e1bf;
  --chichi-fg: #725924;
  --mute-bg: #efefef;
  --mute-fg: #85858a;
  --timeline-hour: 56px;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .035), 0 12px 34px rgba(0, 0, 0, .055);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt" 1;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 14px max(34px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 14px;
}

.brand { color: var(--ink); display: inline-flex; }
.brand svg { width: 112px; height: 39px; }

.icon-button, .date-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.icon-button:hover, .date-button:hover { background: rgba(0, 0, 0, .035); }
.icon-button svg, .date-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 6vw, 1.75rem); font-weight: 850; letter-spacing: .015em; }
h2 { margin-bottom: 0; font-size: .95rem; font-weight: 850; }

.eyebrow {
  margin: 0 0 3px;
  color: var(--ink-3);
  font-size: .69rem;
  font-weight: 750;
  letter-spacing: .13em;
}

.date-row {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  text-align: center;
  padding: 2px 0 16px;
}

.today-shortcut {
  display: block;
  margin: -8px auto 16px;
  padding: 5px 12px;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
}

.lane-card, .preparation-card, .setup-card, .error-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.lane-card { overflow: hidden; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 17px 16px 13px; }
.section-heading p { margin: 3px 0 0; color: var(--ink-3); font-size: .72rem; }

.quiet-chip {
  flex: none;
  padding: 4px 8px;
  color: var(--ink-3);
  background: var(--surface-soft);
  border-radius: 999px;
  font-size: .62rem;
  font-variant-numeric: tabular-nums;
}

.lane-head {
  display: grid;
  grid-template-columns: 38px repeat(4, minmax(62px, 1fr));
  padding: 0 8px 7px 0;
  color: var(--ink-2);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
  font-size: .72rem;
  font-weight: 800;
  text-align: center;
}

.lane-head::before { content: ""; }
.lane-person { display: flex; align-items: center; justify-content: center; gap: 5px; }
.person-dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; }

.timeline-scroll { overflow-x: auto; overscroll-behavior-inline: contain; }
.timeline { display: grid; grid-template-columns: 38px repeat(4, minmax(62px, 1fr)); min-width: 330px; padding-right: 8px; }
.time-axis, .lane-column { position: relative; }
.time-axis { color: var(--ink-3); font-size: .62rem; font-variant-numeric: tabular-nums; }
.time-label { position: absolute; right: 7px; transform: translateY(-50%); }

.lane-column {
  border-left: 1px solid var(--line-soft);
  background-image: linear-gradient(to bottom, transparent calc(100% - 1px), var(--line-soft) 1px);
  background-size: 100% var(--timeline-hour);
}

.event-block, .gap-block {
  position: absolute;
  left: 3px;
  right: 3px;
  z-index: 2;
  min-height: 28px;
  overflow: hidden;
  border-radius: 10px;
  padding: 6px 6px 5px;
  font-size: .66rem;
  font-weight: 800;
  line-height: 1.3;
}

.event-time, .event-detail { display: block; margin-top: 2px; font-size: .57rem; font-weight: 600; opacity: .76; font-variant-numeric: tabular-nums; }
.event-detail { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.event-block.is-tentative { color: var(--mute-fg); background: var(--mute-bg); }
.event-block.is-overlap { right: 22%; }
.event-block.is-overlap + .event-block { left: 22%; }

.person-ani { color: var(--ani-fg); background: var(--ani-bg); }
.person-oto { color: var(--oto-fg); background: var(--oto-bg); }
.person-haha { color: var(--haha-fg); background: var(--haha-bg); }
.person-chichi { color: var(--chichi-fg); background: var(--chichi-bg); }

.gap-block {
  z-index: 4;
  display: grid;
  place-items: center;
  color: var(--mute-fg);
  background: repeating-linear-gradient(135deg, #fafafa, #fafafa 5px, #f0f0f0 5px, #f0f0f0 10px);
  border: 1px dashed #c9c9cd;
  text-align: center;
}

.legend { display: flex; flex-wrap: wrap; gap: 7px 12px; padding: 12px 14px 15px; color: var(--ink-3); border-top: 1px solid var(--line-soft); font-size: .65rem; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 4px; }
.legend-gap { background: var(--mute-bg); border: 1px dashed #c9c9cd; }

.all-day { margin: 0 0 12px; }
.all-day h2 { margin: 0 0 7px 3px; color: var(--ink-3); font-size: .7rem; letter-spacing: .09em; }
.all-day-list { display: grid; gap: 6px; }
.all-day-item { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 8px 11px; border-radius: 12px; font-size: .75rem; font-weight: 800; }
.all-day-item.is-tentative { color: var(--mute-fg); background: var(--mute-bg); }
.all-day-person { opacity: .7; }

.preparation-card { margin-top: 13px; padding: 16px; }
.preparation-card h2 { margin-bottom: 9px; color: var(--ink-3); font-size: .72rem; letter-spacing: .08em; }
.preparation-card ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.preparation-card li { display: flex; align-items: baseline; gap: 8px; font-size: .85rem; line-height: 1.5; }
.preparation-card li::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 2px; background: var(--mute-fg); }
.preparation-person { color: var(--ink-3); font-size: .68rem; font-weight: 750; }
.empty-copy { margin: 0; color: var(--ink-3); font-size: .78rem; }

.source-note { margin: 14px 0 0; color: var(--ink-3); font-size: .65rem; text-align: center; }
.connection-button { display: block; margin: 8px auto 0; padding: 4px 9px; color: var(--ink-3); background: transparent; border: 0; font-size: .65rem; text-decoration: underline; cursor: pointer; }

.setup-card, .error-card { margin-top: 42px; padding: 22px; }
.setup-card > p:not(.eyebrow), .error-card > p:not(.eyebrow) { margin: 10px 0 20px; color: var(--ink-2); font-size: .84rem; line-height: 1.7; }
.setup-card form { display: grid; gap: 9px; }
.setup-card label { color: var(--ink-2); font-size: .72rem; font-weight: 750; }
.setup-card input { width: 100%; min-height: 48px; padding: 10px 12px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--line); border-radius: 12px; font-size: .78rem; }
.setup-card input:focus { outline: 2px solid var(--ink); outline-offset: 2px; }
.form-error { min-height: 1.2em; margin: 0 !important; color: var(--mute-fg) !important; font-size: .68rem !important; }

.primary-button { min-height: 46px; padding: 10px 18px; color: #fff; background: var(--ink); border: 1px solid var(--ink); border-radius: 999px; font-size: .82rem; font-weight: 800; cursor: pointer; }

.loading { display: grid; place-items: center; min-height: 60dvh; color: var(--ink-3); font-size: .76rem; }
.loading p { margin: 9px 0 0; }
.spinner { width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 560px) {
  .app-shell { padding-inline: 20px; }
  .event-block, .gap-block { font-size: .72rem; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}
