@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url(/fonts/dm-sans-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-display: swap; src: url(/fonts/dm-sans-latin-500.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-display: swap; src: url(/fonts/dm-sans-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url(/fonts/dm-sans-latin-ext-400.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-display: swap; src: url(/fonts/dm-sans-latin-ext-500.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-display: swap; src: url(/fonts/dm-sans-latin-ext-700.woff2) format('woff2'); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'DM Mono'; font-weight: 500; font-display: swap; src: url(/fonts/dm-mono-latin-500.woff2) format('woff2'); }

:root {
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --ink: #1C1B19;
  --muted: #5F5C56;
  --line: #EEECE7;
  --border: #D9D6CF;
  --chip: #F0EEE9;
  --accent: #1F6B4F;
  --accent-dark: #164D39;
  --accent-soft: #E7F0EC;
  --stop: #B93A0C;
  --warn-bg: #FBF1DE;
  --warn-ink: #5C3D06;
  --warn-icon: #8A5A00;
  --warn-border: #E5CFA3;
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.mono { font-family: var(--mono); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.stack-2, .stack-4, .stack-8, .stack-14, .stack-16, .stack-18, .stack-20 { display: flex; flex-direction: column; }
.stack-2 { gap: 2px; } .stack-4 { gap: 4px; } .stack-8 { gap: 8px; } .stack-14 { gap: 14px; }
.stack-16 { gap: 16px; } .stack-18 { gap: 18px; } .stack-20 { gap: 20px; }
.pad-x { padding-inline: 20px; }
.pad-x-4 { padding-inline: 4px; }
.grow { flex: 1; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- screens ---------- */
.screen {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
}
.center { align-items: center; justify-content: center; gap: 16px; }

.login { padding-inline: 28px; gap: 40px; padding-top: calc(24px + env(safe-area-inset-top, 0px)); }
.topbar-end { display: flex; justify-content: flex-end; }
.brand { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.brand h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.5px; }
.logo { width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.hint { margin-top: auto; font-size: 14px; line-height: 1.5; color: var(--muted); text-align: center; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 14px; font-weight: 500; color: var(--muted); }
.warn .field label { color: var(--warn-ink); }
.input {
  height: 56px; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface);
  padding: 0 16px; font-size: 22px; width: 100%; min-width: 0;
}
.warn .input { border-color: var(--warn-border); }
.input.pin { letter-spacing: 6px; }
.input:focus { border-color: var(--accent); outline: none; }

.btn {
  height: 56px; border: 0; border-radius: 14px; font-size: 17px; font-weight: 700; padding: 0 18px;
  display: flex; align-items: center; justify-content: center; gap: 10px; background: #E4E1DA; color: #6E6A63;
}
.btn:disabled { cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:disabled { background: #E4E1DA; color: #6E6A63; }
.btn-big { height: 64px; border-radius: 16px; font-size: 19px; }
.btn-tall { height: 60px; border-radius: 16px; font-size: 18px; }
.btn-stop { background: var(--stop); color: #fff; }
.btn-ghost { height: 48px; background: transparent; color: var(--ink); font-weight: 500; font-size: 16px; }
.btn-ghost.danger { color: var(--stop); }
.btn-ghost.danger.armed { background: #FBE7DF; }
.link {
  background: none; border: 0; padding: 4px 0; font-size: 15px; font-weight: 500;
  color: var(--accent); text-align: center; min-height: 44px;
}
.link.on-dark { color: #fff; text-decoration: underline; }

.icon-btn {
  width: 44px; height: 44px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; color: var(--ink); flex-shrink: 0;
}
.icon-btn.plain { border: 0; background: transparent; margin-left: -10px; }

.lang {
  position: relative; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px;
  border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink);
}
.lang select { appearance: none; border: 0; background: transparent; font-size: 14px; font-weight: 500; padding: 0; max-width: 92px; }
.lang select:focus { outline: none; }
.lang:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- home ---------- */
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 24px 20px 16px; }
.hello { font-size: 22px; font-weight: 700; }
.card { padding: 20px; background: var(--surface); border-radius: 20px; }
.card.dark { background: var(--ink); color: #fff; }
.card.warn { background: var(--warn-bg); color: var(--warn-ink); }
.card.warn h2 { font-size: 18px; font-weight: 700; }
.card.warn p { font-size: 15px; line-height: 1.5; }
.card.warn svg { color: var(--warn-icon); flex-shrink: 0; }
.live { display: flex; align-items: center; gap: 8px; font-size: 15px; color: #CFE6DC; }
.dot { width: 10px; height: 10px; border-radius: 5px; background: #4ADE80; }
.timer { font-size: 52px; letter-spacing: -1px; line-height: 1.1; }
.on-dark-muted { color: #B8B4AC; }

.history { padding: 28px 20px 0; display: flex; flex-direction: column; gap: 20px; }
.history h2 { font-size: 18px; font-weight: 700; }
.week { display: flex; flex-direction: column; gap: 8px; }
.week-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 700; color: var(--muted); padding: 0 4px; }
.list { background: var(--surface); border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.list-row {
  min-height: 56px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 0 16px;
  display: flex; align-items: center; gap: 12px; font-size: 16px; text-align: left; width: 100%;
}
.list-row:last-child { border-bottom: 0; }
.list-row .d { width: 96px; flex-shrink: 0; }
.list-row .tm { flex: 1; font-size: 15px; color: var(--muted); }
.list-row .dur { font-size: 15px; }
.list-row svg { color: #8F8B83; flex-shrink: 0; }
.tag { font-size: 13px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 8px; border-radius: 8px; }

/* ---------- picker sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(28, 27, 25, 0.5); display: flex; align-items: flex-end; justify-content: center;
  z-index: 10; animation: fade .15s ease-out;
}
.sheet {
  width: 100%; max-width: 480px; background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 12px 20px calc(28px + env(safe-area-inset-bottom, 0px)); animation: rise .2s ease-out;
}
.sheet h2 { font-size: 24px; font-weight: 700; }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border); align-self: center; }
.wheels {
  position: relative; height: 240px; background: var(--surface); border-radius: 20px;
  display: flex; justify-content: center; align-items: center; gap: 8px; overflow: hidden;
}
.wheel-band { position: absolute; left: 16px; right: 16px; top: 96px; height: 48px; border-radius: 12px; background: var(--accent-soft); }
.wheel {
  position: relative; list-style: none; margin: 0; padding: 96px 0; width: 96px; height: 240px;
  overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel:focus-visible { outline: none; }
.wheels:focus-within .wheel-band { box-shadow: inset 0 0 0 2px var(--accent); }
.wheel li {
  height: 48px; display: flex; align-items: center; justify-content: center; scroll-snap-align: center;
  font-size: 24px; color: #C9C5BD; transition: color .1s, font-size .1s; cursor: pointer;
}
.wheel li.near { color: #8F8B83; }
.wheel li.sel { color: var(--ink); font-size: 34px; }
.colon { position: relative; font-size: 34px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- edit ---------- */
.edit-head { padding: 20px 20px 8px; }
.edit-head h1 { font-size: 22px; font-weight: 700; }
.form-list .form-row {
  min-height: 60px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--line); font-size: 16px;
}
.form-list .form-row:last-child { border-bottom: 0; }
.chip-input {
  border: 0; background: var(--chip); border-radius: 10px; padding: 8px 12px; font-size: 17px; min-height: 40px;
  text-align: right; min-width: 0;
}
.chip-input[type="date"] { font-family: var(--sans); font-weight: 500; font-size: 16px; }
.big-num { font-size: 28px; }
.big-num small { font-family: var(--sans); font-size: 14px; color: var(--muted); font-weight: 400; }
.note {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; background: var(--warn-bg);
  border-radius: 14px; font-size: 14px; line-height: 1.45; color: var(--warn-ink);
}
.note svg { color: var(--warn-icon); flex-shrink: 0; margin-top: 1px; }
.bottom { margin-top: auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(16px + env(safe-area-inset-top, 0px)); transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 32px)); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px;
  font-size: 15px; z-index: 20; box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}

/* ---------- tabs: schedule & leave ---------- */
:root { --red-bg: #FBE4DD; --red-ink: #8A2A07; --red-border: #E8B9A8; --seg: #E9E7E1; }
.stack-10, .stack-12 { display: flex; flex-direction: column; }
.stack-10 { gap: 10px; } .stack-12 { gap: 12px; }
.medium { font-weight: 500; }
.nowrap { white-space: nowrap; }
body.with-tabs .screen, body.with-tabs .tab-screen { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
.tab-screen { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-top: env(safe-area-inset-top, 0px); }
.tab-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 24px 20px 14px; }
.tab-head h1 { font-size: 26px; font-weight: 700; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid #E4E1DA; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar button {
  flex: 1; max-width: 160px; height: 62px; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 500;
}
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 700; }
.bell { position: relative; }
.bell-dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; border-radius: 5px; background: var(--stop); border: 2px solid var(--surface); }
.section-title { margin: 8px 4px 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.field-label { font-size: 14px; font-weight: 500; color: var(--muted); }

.segmented { display: flex; background: var(--seg); border-radius: 12px; padding: 4px; gap: 2px; }
.segmented button {
  flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-size: 15px; font-weight: 500;
  color: var(--muted); padding: 0 10px; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.segmented.scroll { overflow-x: auto; scrollbar-width: none; }
.segmented.scroll::-webkit-scrollbar { display: none; }
.segmented.scroll button { flex: 1 0 auto; }

.day-card {
  min-height: 64px; background: var(--surface); border: 1.5px solid var(--surface); border-radius: 16px; padding: 10px 14px;
  display: flex; align-items: center; gap: 12px;
}
.day-card.mine { border-color: #BFD8CC; }
.day-card.closed { background: #EFEDE8; border-color: #EFEDE8; color: var(--muted); }
.dc-date { width: 44px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.dc-date span { font-size: 13px; font-weight: 500; color: var(--muted); }
.dc-date b { font-size: 20px; }
.dc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dc-main b { font-size: 16px; }
.dc-time { font-size: 14px; color: var(--muted); }
.dc-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.open-ink { color: var(--red-ink); }
.tag-warn { color: var(--warn-ink); background: var(--warn-bg); }
.tag-grey { color: var(--muted); background: var(--chip); }
.tag-red { color: var(--red-ink); background: var(--red-bg); }
.tag-blue { color: #3B3A6B; background: #E8E8F4; }
.btn-chip { height: 40px; padding: 0 14px; border-radius: 10px; font-size: 14px; }
.btn-small { height: 44px; border-radius: 12px; font-size: 15px; }
.btn-outline {
  min-height: 40px; padding: 0 14px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface);
  font-size: 14px; font-weight: 500; color: var(--ink);
}
.btn-outline.tall { min-height: 44px; border-radius: 12px; font-size: 15px; }
.btn-outline:disabled, .btn-chip:disabled { opacity: .5; }
.link.left { text-align: left; align-self: flex-start; min-height: 32px; padding: 0; }
.note-text { font-size: 14px; line-height: 1.45; color: var(--warn-ink); }
.list-row.static { cursor: default; padding-block: 10px; }
.list-row .grow { min-width: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 18px; border: 1.5px solid var(--border); border-radius: 22px; background: var(--surface); font-size: 15px; font-weight: 500; }
.chip[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); font-weight: 700; }
.radio-row { min-height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; font-size: 15px; }
.radio-row:last-child { border-bottom: 0; }
.radio-row input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.balance-big { font-size: 40px; letter-spacing: -1px; line-height: 1.1; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { background: #2C2A27; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.tile span { font-size: 12px; color: #CFCBC3; }
.tile b { font-size: 16px; font-weight: 500; }
.expire { color: #F5D9A6; }
.sick-card { background: var(--red-bg); color: #6E2105; font-size: 15px; line-height: 1.45; }
.btn-sick { background: var(--surface); color: var(--red-ink); border: 1.5px solid var(--red-border); }
.btn-sick.armed { background: var(--red-bg); }
.type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.type-btn { min-height: 56px; border: 1.5px solid var(--border); border-radius: 14px; background: var(--surface); font-size: 14px; font-weight: 500; padding: 4px 6px; }
.type-btn[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); font-weight: 700; }
.total-row { font-weight: 700; }
.total-row .mono { font-size: 18px; }
.note.warn-red { background: var(--red-bg); color: #6E2105; }
.notif-list .list-row { min-height: 60px; padding-block: 10px; gap: 10px; font-size: 15px; line-height: 1.4; }
.notif-list .unread { background: #F3F8F5; }
.notif-list .unread span:first-child { font-weight: 500; }
.sheet { max-height: 88vh; overflow-y: auto; }
.sheet h2 { font-size: 22px; }
@media (min-width: 720px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 24px; max-width: 520px; }
  .sheet .grabber { display: none; }
}
.bottom { display: flex; flex-direction: column; gap: 8px; }
.sheet:focus { outline: none; }
.sheet > * { flex-shrink: 0; }
