:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #dbeafe;
  --blue-text: #1e40af;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #4b5563;
  --line: #e5e7eb;
  --line-soft: #f1f3f6;
  --ground: #f5f6f8;
  --card: #ffffff;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;
  --red: #b91c1c;
  --red-line: #fca5a5;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--ground);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue-dark); }
:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.app { max-width: 520px; margin: 0 auto; height: 100%; display: flex; flex-direction: column; background: var(--ground); }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.topbar { padding: calc(20px + var(--safe-top)) 20px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.content { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.loading { flex: 1; display: grid; place-items: center; color: var(--muted); }

/* Day header with arrows */
.daybar { padding: calc(16px + var(--safe-top)) 8px 12px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; }
.daybar .title { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.daybar h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.daybar p { margin: 0; font-size: 14px; color: var(--muted); }
.icon-btn { width: 48px; height: 48px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:disabled { color: #c3c7cf; cursor: default; }
.icon-btn:not(:disabled):active { background: var(--line-soft); }

/* Sections and cards */
.section { display: flex; flex-direction: column; gap: 8px; }
.section-title { margin: 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.section-heading { margin: 0 4px; font-size: 15px; font-weight: 600; color: var(--ink-2); }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05); }
.card h2 { margin: 0; font-size: 20px; font-weight: 700; }
.card p { margin: 0; }
.subtle { color: var(--muted); font-size: 14px; line-height: 1.45; }
.rows { background: var(--card); border-radius: var(--radius); padding: 2px 14px; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .label { font-size: 15px; }
.row .hint { font-size: 13px; color: var(--muted); }
.row .value { font-size: 15px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* People */
.avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700; }
.pill { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.pill.office { background: var(--blue-soft); color: var(--blue-text); }
.pill.home, .pill.off { background: #f3f4f6; color: var(--ink-2); }
.pill.unset { background: #fff; color: #6b7280; border: 1px dashed #9ca3af; }
.pill.admin { background: var(--blue-soft); color: var(--blue-text); }

/* Office / Home / Off choice */
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice { height: 88px; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card); color: var(--ink-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 15px; font-weight: 600; }
.choice[aria-checked="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
.choice:disabled { opacity: 0.6; cursor: default; }

/* Notices */
.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.45; display: flex; gap: 10px; align-items: flex-start; }
.notice.warning { background: var(--amber-bg); color: var(--amber-text); }
.notice.info { background: var(--blue-soft); color: var(--blue-text); }
.notice.error { background: #fee2e2; color: #991b1b; }
.notice svg { flex-shrink: 0; margin-top: 1px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid transparent; font-size: 16px; font-weight: 600; text-decoration: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-dark); }
.btn.secondary { background: var(--card); color: var(--ink); border-color: #d1d5db; }
.btn.danger { background: var(--card); color: var(--red); border-color: var(--red-line); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.link { min-height: 44px; padding: 0; background: none; color: var(--blue-dark); justify-content: flex-start; }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field input { height: 50px; padding: 0 14px; border: 1px solid #d1d5db; border-radius: 12px; background: #fff;
  font-size: 16px; font-weight: 400; color: var(--ink); }
.field input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.time-input { height: 40px; border: 0; border-radius: 8px; background: var(--line-soft); padding: 0 10px; font-size: 15px; font-weight: 600; }
.team-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 32px; font-weight: 700; letter-spacing: 0.12em;
  text-align: center; background: var(--line-soft); border-radius: 12px; padding: 14px; user-select: all; }
.field input.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: 0.1em; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; background: var(--line-soft);
  border-radius: 10px; padding: 12px; word-break: break-all; user-select: all; }

/* Switch */
.switch { width: 52px; height: 32px; border: 0; border-radius: 16px; padding: 3px; flex-shrink: 0; display: flex;
  background: #9ca3af; justify-content: flex-start; transition: background 0.15s; }
.switch::after { content: ""; width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.switch[aria-checked="true"] { background: var(--blue); justify-content: flex-end; }

/* Auth and install screens */
.auth { flex: 1; overflow-y: auto; background: var(--card); padding: calc(56px + var(--safe-top)) 24px calc(28px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 28px; }
.auth h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.auth .lead { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); }
.auth .footer { margin-top: auto; text-align: center; font-size: 15px; color: var(--muted); }
.logo { width: 56px; height: 56px; border-radius: 14px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.45; }
.inline-icon { display: inline-flex; vertical-align: -4px; }

/* Bottom navigation */
.tabbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + var(--safe-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; min-height: 48px;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.tabbar a[aria-current="page"] { color: var(--blue-dark); font-weight: 600; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); z-index: 10; }
