:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece5;
  --ink: #23262b;
  --muted: #6b6f76;
  --line: #e2ded5;
  --accent: #3d6b62;
  --accent-ink: #ffffff;
  --accent-soft: #e3ece9;
  --sign: #a8661f;
  --sign-soft: #f5e9da;
  --danger: #b4443a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b;
    --surface: #1f2226;
    --surface-2: #272b30;
    --ink: #e9e7e2;
    --muted: #9a9ea5;
    --line: #33373d;
    --accent: #7fb3a7;
    --accent-ink: #10201c;
    --accent-soft: #24332f;
    --sign: #e0a35c;
    --sign-soft: #3a2f22;
    --danger: #e57d72;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
header.top { display: flex; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top)) 0 8px; }
header.top h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h2 { font-size: 18px; margin: 28px 0 10px; }
h3 { font-size: 16px; margin: 18px 0 8px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 12px 0; }
.card.soft { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.card.warn { background: var(--sign-soft); border-color: transparent; box-shadow: none; }

.big-actions { display: grid; gap: 12px; margin-top: 12px; }
.big-btn {
  display: flex; gap: 14px; align-items: center; text-align: left; width: 100%;
  padding: 20px 18px; border-radius: 20px; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
}
.big-btn.sign { background: var(--sign); color: #fff; }
@media (prefers-color-scheme: dark) { .big-btn.sign { color: #241808; } }
.big-btn .ico { font-size: 30px; line-height: 1; }
.big-btn b { display: block; font-size: 18px; }
.big-btn span.sub { opacity: .85; font-size: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.signc { background: var(--sign); color: #fff; border-color: var(--sign); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }

label.f { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 15px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 84px; resize: vertical; }

.scale { display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 3px; }
.scale button {
  height: 40px; min-width: 0; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 15px; cursor: pointer; padding: 0;
}
.scale button.on { color: #fff; border-color: transparent; transform: scale(1.08); }
.scale-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.sign-form .chip.on { background: var(--sign); border-color: var(--sign); color: #fff; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); font-size: 12px; color: var(--muted); margin: 2px 4px 0 0; }

.banner { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); margin: 8px 0 4px; }
.sign-form .banner { background: var(--sign-soft); }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a { display: flex; flex-direction: column; align-items: center; padding: 8px 0 6px; font-size: 12px; color: var(--muted); text-decoration: none; }
nav.tabs a .i { font-size: 20px; line-height: 1.2; }
nav.tabs a.on { color: var(--accent); font-weight: 600; }

.entry { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: none; }
.entry .badge { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; }
.entry .badge.sign { background: var(--sign); }
.entry .body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.entry .meta { font-size: 13px; color: var(--muted); }
.entry .del { flex: none; align-self: flex-start; border: none; background: none; color: var(--muted); cursor: pointer; padding: 4px 6px; font-size: 18px; }
.day-head { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 0; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.tile .v { font-size: 26px; font-weight: 700; line-height: 1.2; }
.tile .l { font-size: 13px; color: var(--muted); }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.bars .bar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr 64px; gap: 8px; align-items: center; margin: 6px 0; font-size: 14px; }
.bars .bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar .track { height: 10px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bars .bar .fill { height: 100%; border-radius: 6px; }
.bars .bar .num { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

.md h2 { font-size: 17px; margin: 22px 0 6px; }
.md h3 { font-size: 15px; }
.md p, .md li { margin: 6px 0; }
.md ul, .md ol { padding-left: 22px; }

.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav b { font-size: 18px; }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; transition: .2s; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 20; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.auth { max-width: 420px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 16px 40px; }
.auth .logo { width: 72px; height: 72px; border-radius: 20px; display: block; margin-bottom: 16px; }
.switch { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin: 16px 0; }
.switch button { flex: 1; border: none; background: none; padding: 8px; border-radius: 9px; cursor: pointer; }
.switch button.on { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
