/* 한 줄 기둥: 인용 → 설정 → 숫자 → 점 그림 → 기억하는 날. 휴대폰(360px)을 먼저 맞춘다. */
:root {
  --bg: #f2f3f6;
  --surface: #ffffff;
  --ink: #232a3d;
  --muted: #5d6479;
  --lived: #2c3552;
  --left: #cfd3de;
  --today: #d9791c;
  --kept: #2f8a76;
  --period: #8fc3b4;
  --line: #dde0e8;
  --display: "Gowun Batang", "Nanum Myeongjo", "AppleMyungjo", "Noto Serif KR", Georgia, serif;
  --body: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1320; --surface: #171c2c; --ink: #e4e8f3; --muted: #9aa2b8;
    --lived: #c4cde6; --left: #2a3147; --today: #f2a640; --kept: #4fc0a4; --period: #2d5f55; --line: #262c3f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1320; --surface: #171c2c; --ink: #e4e8f3; --muted: #9aa2b8;
  --lived: #c4cde6; --left: #2a3147; --today: #f2a640; --kept: #4fc0a4; --period: #2d5f55; --line: #262c3f;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.6;
  word-break: keep-all; overflow-wrap: break-word;
}
.wrap {
  max-width: 960px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px 56px;
  display: flex; flex-direction: column; gap: 28px;
}
h1, h2, figcaption { text-wrap: balance; }
p, li { text-wrap: pretty; }
header { display: flex; flex-direction: column; gap: 10px; }
h1 { font-family: var(--display); font-weight: 700; font-size: clamp(36px, 7vw, 56px); line-height: 1.1; margin: 0; letter-spacing: -0.01em; }
.quote { font-family: var(--display); font-size: 17px; color: var(--muted); margin: 0; max-width: 40em; }
.quote cite { font-style: normal; font-family: var(--body); font-size: 13px; display: block; margin-top: 4px; }

.topbar { display: flex; flex-wrap: wrap; gap: 12px 20px; justify-content: flex-end; align-items: flex-end; }
.controls { display: flex; flex-wrap: wrap; gap: 16px 20px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 200px; }
.field label, .label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); }
input, select, button { font: inherit; color: var(--ink); }
input[type="date"], input[type="text"], select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; max-width: 100%;
}
input[type="text"] { width: 100%; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); max-width: 100%; }
.seg button { border: 0; background: transparent; padding: 8px 12px; min-height: 40px; cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--lived); color: var(--bg); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--today); outline-offset: 2px; }
.example { font-size: 13px; color: var(--today); }
.example[hidden] { display: none; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--display); font-size: clamp(24px, 4vw, 32px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { font-size: 13px; color: var(--muted); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.field-box { margin: 0; position: relative; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.canvas-box { position: relative; }
canvas { display: block; touch-action: manipulation; }
.cursor {
  position: absolute; pointer-events: none; border: 2px solid var(--today); border-radius: 50%;
  transform: translate(-50%, -50%); box-sizing: content-box;
}
.tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--bg);
  font-size: 12px; line-height: 1.4; padding: 6px 10px; border-radius: 6px;
  width: max-content; max-width: min(280px, calc(100% - 8px)); z-index: 2;
}
.tip[hidden], .cursor[hidden] { display: none; }
.yearmarks { font-size: 11px; color: var(--muted); }

.kept { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.kept h2 { font-family: var(--display); font-size: 20px; margin: 0; }
.kept p { margin: 0; color: var(--muted); font-size: 14px; }
.kept p[hidden] { display: none; }
.kept form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.kept form button, .del {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 14px; min-height: 40px; cursor: pointer;
}
.kept ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.kept li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 14px; }
.kept li time { font-variant-numeric: tabular-nums; color: var(--muted); }
.kept li .what { flex: 1 1 8em; min-width: 0; }
.del { padding: 2px 10px; min-height: 32px; font-size: 12px; }

footer { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 16px; }
footer a { color: inherit; }
.c-lived { background: var(--lived); } .c-today { background: var(--today); } .c-kept { background: var(--kept); }
.c-period { background: var(--period); } .c-left { background: var(--left); }
