:root {
  --bg: #F7F2E9;
  --card: #FFFDF8;
  --bar: #FBF8F1;
  --line: #E2DBCC;
  --ink: #3A352E;
  --ink-diary: #4A443A;
  --muted: #9A917F;
  --accent: #B5603C;
  --accent-text: #B5603C;
  --on-accent: #FBF8F1;
  --diary-mark: #D9A03C;
  --bubble-ai: #F3EDE0;
  --bubble-user: #E9DFCB;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #28231D;
    --card: #322C24;
    --bar: #221E18;
    --line: #4A4337;
    --ink: #EDE5D3;
    --ink-diary: #CFC5B0;
    --muted: #A39A88;
    --accent: #C97B52;
    --accent-text: #D98B66;
    --on-accent: #28231D;
    --diary-mark: #C9963F;
    --bubble-ai: #3A332A;
    --bubble-user: #443B2E;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15px; line-height: 1.7;
}
.wrap { max-width: 480px; margin: 0 auto; padding: 0 14px 84px; }
header.top {
  position: sticky; top: 0; background: var(--bg); z-index: 5;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 14px 2px 10px;
}
header.top .title { font-family: Georgia, "Yu Mincho", serif; font-size: 18px; }
header.top .sub { font-size: 11px; color: var(--muted); }
.card {
  background: var(--card); border: 0.5px solid var(--line);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 12px;
}
.serif { font-family: Georgia, "Yu Mincho", serif; }
.diary-text { font-family: Georgia, "Yu Mincho", serif; line-height: 1.95; color: var(--ink-diary); white-space: pre-wrap; }
.muted { color: var(--muted); font-size: 12px; }
a { color: var(--accent-text); text-decoration: none; }
table.cal { width: 100%; border-collapse: collapse; text-align: center; }
table.cal th { font-size: 11px; color: var(--muted); font-weight: 400; padding: 2px 0; }
table.cal td { padding: 2px 0; }
table.cal a, table.cal span.empty { display: block; padding: 7px 0; border-radius: 8px; color: var(--ink); font-size: 13px; }
table.cal a.diary { border-bottom: 2px solid var(--diary-mark); border-radius: 0; }
table.cal a.today { background: var(--accent); color: var(--on-accent); border-radius: 8px; }
table.cal a.silent { color: var(--muted); opacity: 0.55; }
.cal-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.cal-nav .ym { font-weight: 500; font-size: 14px; }
.bubble-row { display: flex; margin-bottom: 8px; gap: 8px; align-items: flex-end; }
.bubble-row.user { justify-content: flex-end; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--on-accent);
  font-size: 11px; display: flex; align-items: center; justify-content: center;
}
.bubble { max-width: 78%; padding: 8px 12px; font-size: 14px; white-space: pre-wrap; }
.bubble.ai { background: var(--bubble-ai); border-radius: 12px 12px 12px 3px; }
.bubble.user { background: var(--bubble-user); border-radius: 12px 12px 3px 12px; }
form.chat { display: flex; gap: 8px; position: fixed; bottom: 64px; left: 0; right: 0; padding: 8px 14px; background: var(--bg); }
form.chat .inner { display: flex; gap: 8px; max-width: 480px; margin: 0 auto; width: 100%; }
form.chat textarea {
  flex: 1; resize: none; border: 0.5px solid var(--line); border-radius: 18px;
  padding: 9px 14px; font: inherit; background: var(--card); color: var(--ink); height: 42px;
}
form.chat button {
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--on-accent); font-size: 18px; cursor: pointer;
}
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--bar); border-top: 0.5px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 0 12px;
}
nav.tabs a, nav.tabs span.off {
  font-size: 11px; color: var(--muted); text-align: center; min-width: 56px; padding: 4px 0;
}
nav.tabs a.active { color: var(--accent-text); font-weight: 500; }
nav.tabs span.off { opacity: 0.4; }
input[type=password] {
  width: 100%; border: 0.5px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font: inherit; background: var(--card); color: var(--ink);
}
.input {
  width: 100%; border: 0.5px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font: inherit; background: var(--bg); color: var(--ink);
  margin: 4px 0 8px; font-size: 14px;
}
select.input { appearance: auto; }
textarea.input { resize: vertical; }
label.muted { font-size: 12px; color: var(--muted); }
button.primary {
  width: 100%; margin-top: 12px; padding: 11px; border: none; border-radius: 10px;
  background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 500; cursor: pointer;
}
.error { color: #A32D2D; font-size: 13px; }
.legend { font-size: 11px; color: var(--muted); margin-top: 8px; }
.legend .mark { display: inline-block; width: 14px; border-bottom: 2px solid var(--diary-mark); vertical-align: middle; margin-right: 4px; }
