[hidden] { display: none !important; }
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #aeaeb2;
  --line: rgba(0, 0, 0, 0.08);
  --blue: #0071e3;
  --warn: #c93400;
  --warn-bg: #fff4ec;
  --ok: #1f8a3b;
  --orange: #ff9500;
  --purple: #8e5cf7;
  --green: #34c759;
  --pink: #ff2d55;
  --gray: #8e8e93;
  --pen-blue: #0a84ff;
  --radius: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: env(safe-area-inset-top) 0 calc(env(safe-area-inset-bottom) + 24px); }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, select { font: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; max-width: 560px; margin: 0 auto; }
.top h1 { font: 700 34px/1.1 -apple-system, "SF Pro Display", sans-serif; letter-spacing: -0.02em; margin: 0; }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; }
.icon-btn:active { background: var(--line); }

main { max-width: 560px; margin: 0 auto; padding: 8px 16px; }
.pens { display: grid; gap: 14px; }

.pen { background: var(--card); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.04); }
.pen-head { display: flex; align-items: center; gap: 10px; }
.dot { width: 12px; height: 12px; border-radius: 6px; flex: none; background: var(--c, var(--gray)); }
.pen-name { font-weight: 600; font-size: 17px; }
.pen-kind { color: var(--muted); font-size: 15px; }
.badge { margin-left: auto; font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.done { color: var(--ok); background: #eaf7ee; }
.badge.late { color: var(--warn); background: var(--warn-bg); }
.since { font: 600 44px/1.05 -apple-system, "SF Pro Display", sans-serif; letter-spacing: -0.03em; margin: 14px 0 2px; font-variant-numeric: tabular-nums; }
.since small { font-size: 20px; font-weight: 500; color: var(--muted); letter-spacing: -0.01em; }
.detail { color: var(--muted); font-size: 15px; margin: 0 0 14px; }
.log-btn { width: 100%; border: 0; border-radius: 14px; padding: 15px; font-weight: 600; font-size: 17px; color: #fff; background: var(--c, var(--ink)); }
.log-btn:active { filter: brightness(0.92); }

.aid { color: var(--faint); font-size: 12px; text-align: center; margin: 14px 8px 4px; }

.history h2 { font-size: 20px; letter-spacing: -0.01em; margin: 22px 4px 8px; }
.day { margin-bottom: 14px; }
.day h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; margin: 0 6px 6px; }
.rows { background: var(--card); border-radius: 16px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px; border: 0; background: transparent; text-align: left; border-top: 0.5px solid var(--line); }
.row:first-child { border-top: 0; }
.row:active { background: var(--bg); }
.row .name { font-weight: 500; }
.row .units { color: var(--muted); }
.row .time { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .src { color: var(--faint); font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 22px; background: var(--card); border-radius: 16px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); background: rgba(29,29,31,0.94); color: #fff; padding: 12px 14px 12px 18px; border-radius: 16px; display: flex; gap: 14px; align-items: center; font-size: 15px; width: max-content; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,0.2); z-index: 30; }
.toast button { border: 0; background: rgba(255,255,255,0.16); color: #fff; border-radius: 10px; padding: 7px 12px; font-weight: 600; }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,0.28); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px); max-height: 92vh; overflow-y: auto; animation: up 0.22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.grab { width: 36px; height: 5px; border-radius: 3px; background: var(--faint); margin: 0 auto 12px; opacity: 0.6; }
.sheet h2 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.sheet .sub { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.group { background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }

.stepper { display: flex; align-items: center; justify-content: space-between; }
.stepper button { width: 56px; height: 56px; border-radius: 28px; border: 0; background: var(--bg); font-size: 28px; font-weight: 500; }
.stepper button:active { background: var(--line); }
.stepper .val { text-align: center; }
.stepper input { width: 120px; border: 0; text-align: center; font: 600 44px/1 -apple-system, "SF Pro Display", sans-serif; background: transparent; font-variant-numeric: tabular-nums; color: var(--ink); }
.stepper input:focus { outline: none; }
.stepper .unit { color: var(--muted); font-size: 14px; }
.skip { display: block; margin: 10px auto 0; border: 0; background: none; color: var(--blue); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 0; background: var(--bg); padding: 9px 14px; border-radius: 999px; font-size: 15px; }
.chip.on { background: var(--ink); color: #fff; }
.when-input { margin-top: 10px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }

.warn { background: var(--warn-bg); color: var(--warn); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; font-weight: 500; line-height: 1.35; }
.primary { width: 100%; border: 0; border-radius: 14px; padding: 16px; font-weight: 600; font-size: 17px; color: #fff; background: var(--c, var(--ink)); margin-top: 4px; }
.primary.danger { background: var(--warn); }
.secondary { width: 100%; border: 0; border-radius: 14px; padding: 14px; font-weight: 600; font-size: 16px; background: var(--card); margin-top: 10px; }
.secondary.red { color: var(--warn); }
.primary:disabled { opacity: 0.5; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--muted); }
.field input, .field select { padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); width: 100%; color: var(--ink); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pen-edit { border-top: 0.5px solid var(--line); padding-top: 14px; margin-top: 14px; }
.pen-edit:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.steps { margin: 0; padding-left: 20px; line-height: 1.5; font-size: 15px; }
.steps li { margin-bottom: 8px; }
.copy { display: flex; gap: 8px; align-items: center; margin: 6px 0 2px; }
.copy code { flex: 1; font: 12px ui-monospace, "SF Mono", Menlo, monospace; background: var(--bg); padding: 9px 10px; border-radius: 10px; overflow-x: auto; white-space: nowrap; }
.copy button { border: 0; background: var(--ink); color: #fff; border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.4; margin: 6px 0 0; }

/* Login and tap pages */
.center { min-height: 90vh; display: grid; place-items: center; padding: 24px; }
.panel { width: 100%; max-width: 380px; background: var(--card); border-radius: 24px; padding: 26px 22px; box-shadow: 0 8px 30px rgba(0,0,0,0.06); text-align: center; }
.panel h1 { font: 700 28px/1.1 -apple-system, "SF Pro Display", sans-serif; margin: 6px 0 6px; }
.panel p { color: var(--muted); margin: 0 0 18px; line-height: 1.4; }
.panel input { width: 100%; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); text-align: center; font-size: 22px; letter-spacing: 0.12em; margin-bottom: 12px; }
.panel .err { color: var(--warn); min-height: 20px; font-size: 14px; margin: 8px 0 0; }
.link { border: 0; background: none; color: var(--blue); font-size: 15px; margin-top: 14px; }
.big-dot { width: 56px; height: 56px; border-radius: 28px; margin: 0 auto 8px; background: var(--c, var(--gray)); display: grid; place-items: center; color: #fff; font-size: 26px; font-weight: 700; }
