@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("/fonts/instrument-sans.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --cream: #F7F1E7; --sand: #EDE4D6; --line: #D9CFBF; --white: #FFFFFF;
  --ink: #17212D; --muted: #5B6470; --blue: #2F5D8A; --blue-dark: #1F4268;
  --red: #9A3B1E; --green: #1D6B3A;
  --display: "Bricolage Grotesque", Georgia, serif;
  --body: "Instrument Sans", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--body); font-size: 16px; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.hidden-label { position: absolute; left: -9999px; }

.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
.top { display: flex; justify-content: space-between; align-items: flex-end; padding: calc(20px + env(safe-area-inset-top)) 20px 12px; }
.brand { font-size: 13px; color: var(--muted); }
.top h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 32px; }
.summary { font-size: 13px; color: var(--muted); text-align: right; }

.screen { padding: 0 20px; }
.btn { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--white); font-size: 15px; cursor: pointer; }
.btn.primary { background: var(--ink); color: var(--white); border-color: var(--ink); font-weight: 600; }
.btn.line { background: transparent; border-color: var(--ink); font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: default; }

.add { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.seg { display: inline-flex; align-self: flex-start; background: var(--sand); border-radius: 10px; padding: 3px; }
.seg label { min-height: 36px; display: flex; align-items: center; padding: 0 14px; border-radius: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg label:has(input:checked) { background: var(--white); color: var(--ink); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--blue); }
.add-row { display: flex; gap: 8px; }
.add-row input, .filter input, .filter select { flex: 1; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--white); font-size: 15px; min-width: 0; }
.filter { display: flex; gap: 8px; margin-bottom: 16px; }
.filter select { flex: 0 0 auto; }

.list { display: flex; flex-direction: column; gap: 10px; }
.group { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.group.over { color: var(--red); }
.card { background: var(--white); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.kind { font-weight: 600; color: var(--blue); }
.over .kind, .kind.over { color: var(--red); }
.card .title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.card .body { font-size: 14px; color: var(--muted); white-space: pre-line; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 0 0 auto; }
.actions .btn.primary { flex: 1 1 auto; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; line-height: 1.5; }
.entry { background: var(--white); border-radius: 12px; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 14px; }
.entry .what { overflow-wrap: anywhere; }
.entry .when { font-size: 12px; color: var(--muted); margin-top: 2px; }

.ask { position: fixed; right: max(16px, calc(50vw - 344px)); bottom: calc(88px + env(safe-area-inset-bottom)); min-height: 48px; padding: 0 18px 0 14px; border-radius: 24px; background: var(--ink); color: var(--cream); display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; text-decoration: none; box-shadow: 0 4px 14px rgba(23, 33, 45, 0.25); z-index: 5; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: var(--white); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); z-index: 4; }
.nav a { display: flex; align-items: center; justify-content: center; color: var(--muted); text-decoration: none; font-size: 13px; }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

.signin { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; gap: 8px; }
.signin img { border-radius: 24px; }
.signin h1 { font-family: var(--display); font-size: 28px; margin: 8px 0 16px; }
.signin form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; }
.signin label { font-size: 14px; font-weight: 600; }
.signin input { min-height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--white); font-size: 16px; }
.msg { min-height: 20px; color: var(--red); font-size: 14px; margin: 0; }

dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(23, 33, 45, 0.55); }
.chat { width: 100%; max-width: 720px; height: min(86dvh, 760px); margin: auto auto 0; border-radius: 20px 20px 0 0; background: var(--white); display: none; flex-direction: column; }
.chat[open] { display: flex; }
.chat header { padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--sand); display: flex; justify-content: space-between; align-items: center; }
.chat h2 { margin: 0; font-family: var(--display); font-size: 20px; }
.about { font-size: 12px; color: var(--muted); }
.icon { width: 44px; height: 44px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; font-size: 15px; line-height: 1.45; }
.bubble { max-width: 85%; padding: 10px 14px; white-space: pre-line; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--blue); color: var(--white); border-radius: 16px 16px 4px 16px; }
.bubble.claude { align-self: flex-start; background: var(--cream); border-radius: 16px 16px 16px 4px; }
.bubble.wait { color: var(--muted); }
.chat-form { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--sand); display: flex; gap: 8px; }
.chat-form input { flex: 1; min-height: 48px; border: 1px solid var(--line); border-radius: 24px; padding: 0 16px; font-size: 16px; min-width: 0; }
.send { width: 48px; height: 48px; border: 0; border-radius: 24px; background: var(--ink); color: var(--cream); display: flex; align-items: center; justify-content: center; cursor: pointer; }

.sheet { width: calc(100% - 32px); max-width: 420px; border-radius: 16px; background: var(--white); }
.sheet form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; font-size: 18px; }
.sheet input[type="text"], .sheet input[type="date"] { width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 16px; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--cream); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 10; max-width: calc(100% - 32px); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
