/* I am a star — หน้าตาหลัก (เลือกเมื่อ 17 พ.ย. 2026: "ท้องฟ้าไว้ดู กระดาษไว้เขียน")
   หน้าที่ไว้มองเส้นทาง (หน้าแรก, ฝึก) = ท้องฟ้าพลบค่ำ  data-theme="sky"
   หน้าที่ไว้เขียน (บันทึก, สมุด, ตั้งค่า) = กระดาษครีม  data-theme="paper"
   หน้าไหนใช้ธีมอะไร ตั้งที่ THEMES ใน app.js
   ฟอนต์ลายมือ (Mali) ใช้กับหัวข้อ ตัวเลข ป้าย ปุ่ม  ฟอนต์อ่านง่าย (Anuphan) ใช้กับเนื้อความ */

/* ───── ฟอนต์ (ฝังในแอพ ใช้ได้ตอนไม่มีเน็ต) ใบอนุญาตอยู่ที่ fonts/OFL-*.txt ───── */
@font-face { font-family: "Mali"; font-weight: 500; font-display: swap; src: url(../fonts/mali-500-thai.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Mali"; font-weight: 500; font-display: swap; src: url(../fonts/mali-500-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Mali"; font-weight: 600; font-display: swap; src: url(../fonts/mali-600-thai.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Mali"; font-weight: 600; font-display: swap; src: url(../fonts/mali-600-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Anuphan"; font-weight: 400 600; font-display: swap; src: url(../fonts/anuphan-thai.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Anuphan"; font-weight: 400 600; font-display: swap; src: url(../fonts/anuphan-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Sarabun"; font-weight: 400; font-display: swap; src: url(../fonts/sarabun-thai.woff2) format("woff2"); unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC; }
@font-face { font-family: "Sarabun"; font-weight: 400; font-display: swap; src: url(../fonts/sarabun-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ───── สี ───── */
:root {
  /* ค่าที่ใช้ร่วมกันทั้งสองธีม */
  --hand: "Mali", "Thonburi", "Leelawadee UI", sans-serif;
  --read: "Anuphan", "Sukhumvit Set", "Thonburi", "Leelawadee UI", sans-serif;
  --write: "Sarabun", "TH Sarabun New", "Thonburi", sans-serif; /* ตัวหนังสือที่เจ้าของจดเอง (เลือกเมื่อ 21 พ.ย. 2026) */
  --night: #33304a;          /* พื้นพลบค่ำ และแถบบนสุดของหน้ากระดาษ */
  --tab-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --wobble: 14px 17px 13px 16px; /* มุมมนไม่เท่ากันแบบวาดมือ */
}

[data-theme="paper"] {
  --bg: #f3ead7;
  --surface: #fbf5e8;        /* ช่องกรอก */
  --ink: #3b4270;            /* หมึกน้ำเงิน */
  --dim: #5f6489;
  --pen: #3b4270;
  --star: #f6dc7a;           /* ปากกาเน้น / ดาวที่สว่าง */
  --star-ink: #3b4270;
  --rule: #c9c2b0;
  --dots: #ddd3bd;
  --tape-a: #e9a3ad; --tape-a-ink: #4a2f3b;
  --tape-b: #bcd0c4; --tape-b-ink: #2f4a3e;
  --danger: #a8404f;
  --bar: #f3ead7;
}

[data-theme="sky"] {
  --bg: #33304a;
  --surface: #403b5a;        /* แผ่นด้านล่าง */
  --ink: #f4ead8;            /* ตัวหนังสือครีม */
  --dim: #bdb2d2;
  --pen: #cfc4e2;
  --star: #f3d48a;
  --star-ink: #3a3147;
  --rule: #5a5378;
  --tape-a: #8f6f86; --tape-a-ink: #fbeef0;
  --tape-b: #5f7f78; --tape-b-ink: #eef6f1;
  --danger: #f2a5a5;
  --bar: #403b5a;
  --sky-deep: #241f37;       /* ขอบมืดของกรอบแผนที่ดาว */
  --geo: #e9dcc0;            /* เส้นเรขาคณิตบาง ๆ บนแผนที่ดาว */
  --sk-compo: #eaa7b2;       /* สีของทักษะ 4 ด้าน */
  --sk-light: #f3d48a;
  --sk-finish: #a9bbe9;
  --sk-line: #9fcdb7;
  --sk-none: #e6dccb;        /* ยังไม่เลือกทักษะ */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--read);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* พื้นหลัง */
.backdrop { position: fixed; inset: 0; z-index: -1; }
[data-theme="paper"] .backdrop { background: radial-gradient(circle, var(--dots) 1.1px, transparent 1.3px) 0 0 / 20px 20px, var(--bg); }
[data-theme="sky"] .backdrop { background: linear-gradient(180deg, #2f2c45, #3d3552 62%, #564560); }

/* แถบใต้นาฬิกา iPhone: ตัวเลขนาฬิกาเป็นสีขาวเสมอ หน้ากระดาษจึงต้องมีแถบสีเข้มรองไว้ */
.statusband { position: fixed; top: 0; left: 0; right: 0; z-index: 11; height: var(--safe-top); background: var(--night); }

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 22px) 20px calc(var(--tab-h) + var(--safe-bottom) + 28px);
  outline: none;
}

/* ───── ตัวหนังสือ ───── */
h1, h2, h3, .hand { font-family: var(--hand); }
h1 { margin: 0; font-size: 34px; font-weight: 600; line-height: 1.25; text-wrap: balance; }
h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
p { margin: 0 0 10px; }
.date { margin: 0; font-size: 14px; color: var(--dim); }
.dim { color: var(--dim); }
.faint { color: var(--dim); font-size: 13px; }

/* ปากกาเน้นใต้หัวเรื่องบนกระดาษ */
[data-theme="paper"] .marked {
  display: inline; padding: 0 6px;
  background: linear-gradient(transparent 55%, var(--star) 55%, var(--star) 92%, transparent 92%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* เทปกาว: ป้ายหัวข้อของแต่ละส่วน */
.tape {
  display: inline-block; margin: 0 0 8px -4px; padding: 3px 14px;
  background: var(--tape-a); color: var(--tape-a-ink);
  font-family: var(--hand); font-size: 15px; font-weight: 500; line-height: 1.5;
  transform: rotate(-1.5deg);
}
.tape.b { background: var(--tape-b); color: var(--tape-b-ink); transform: rotate(1.2deg); }

.part { margin-top: 28px; }
.part > :last-child { margin-bottom: 0; }

/* ───── ปุ่มและช่องกรอก ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border: 1.8px solid var(--pen); border-radius: var(--wobble);
  background: transparent; color: var(--ink);
  font-family: var(--hand); font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--pen); color: var(--bg); }
[data-theme="sky"] .btn.primary { border-color: var(--star); background: var(--star); color: var(--star-ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

label.field { display: block; margin-top: 12px; font-size: 14px; color: var(--dim); }
input[type="date"], input[type="time"], input[type="text"], input[type="number"], textarea, select {
  display: block; width: 100%; margin-top: 6px; min-height: 48px; padding: 10px 12px;
  border: 1.8px solid var(--pen); border-radius: 12px 15px 11px 14px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px; /* 16px กัน iPhone ซูมเอง */
}
[data-theme="paper"] input, [data-theme="paper"] textarea, [data-theme="paper"] select { color-scheme: light; }
[data-theme="sky"] input, [data-theme="sky"] textarea, [data-theme="sky"] select { color-scheme: dark; }
:focus-visible { outline: 2.5px solid var(--star); outline-offset: 2px; }
[data-theme="paper"] :focus-visible { outline-color: var(--pen); }

/* รายการบรรทัดเส้นประ */
.list { margin: 0; padding: 0; list-style: none; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1.5px dashed var(--rule); }
.list .num { font-weight: 600; font-variant-numeric: tabular-nums; } /* ไม่ใช้ลายมือ: 0 ของ Mali ดูเหมือนตัว o */

/* ───── หน้าแรก ───── */
.hud { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.hud h1 { font-size: 44px; line-height: 1.05; margin-top: 2px; }
.countdown { text-align: right; }
.countdown b { display: block; font-family: var(--hand); font-size: 28px; font-weight: 600; line-height: 1.1; color: var(--star); }
.countdown span { font-size: 13px; color: var(--dim); }

.round { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 18px; }
.round .tape { margin-bottom: 0; }

.constellation { display: block; width: 100%; height: auto; margin: 4px 0 0; }
.constellation .path { fill: none; stroke: var(--pen); stroke-width: 1.8; stroke-dasharray: 2 7; stroke-linecap: round; opacity: .7; }
.constellation .path.walked { stroke-dasharray: none; opacity: 1; }
.constellation .s { fill: var(--bg); stroke: var(--pen); stroke-width: 1.8; stroke-linejoin: round; }
.constellation .s.done { fill: var(--pen); }
.constellation .s.now { fill: var(--star); stroke: var(--star); }
.constellation text { font-family: var(--hand); font-size: 12px; fill: var(--dim); }
.constellation text.now { fill: var(--ink); font-weight: 600; font-size: 13px; }

.sheet { margin: 6px -20px 0; padding: 20px 20px 8px; border-radius: 28px; background: var(--surface); }
.sheet .tape { margin-bottom: 4px; }
.steps li:last-child { border-bottom: 0; }

/* ───── ชิ้นส่วนที่ใช้ร่วม: ชิป ลิงก์ ───── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 6px 15px;
  border: 1.6px solid var(--pen); border-radius: var(--wobble);
  background: transparent; color: var(--ink);
  font-family: var(--hand); font-size: 15px; font-weight: 500; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--star); color: var(--star-ink); font-weight: 600; }
.chip.add { border-style: dashed; color: var(--dim); }
.linkbtn {
  min-height: 44px; padding: 8px 0; border: 0; background: none; cursor: pointer;
  color: var(--dim); font-family: var(--hand); font-size: 15px;
  text-decoration: underline dashed 1.5px; text-underline-offset: 5px;
}
.linkbtn:disabled { text-decoration: none; cursor: default; opacity: .8; }

/* ───── บันทึกรายวัน ───── */
.log-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.save-state { margin: 0 0 6px; text-align: right; white-space: nowrap; }
.daytype .chip { letter-spacing: .04em; }

.did { margin: 0 0 12px; padding: 0; list-style: none; }
.did li { padding: 10px 0 12px; border-bottom: 1.5px dashed var(--rule); }
.what-row { display: flex; align-items: center; gap: 4px; }
.what-row .what { margin-top: 0; }
.x { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--dim); font-size: 24px; line-height: 1; cursor: pointer; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 8px; }
select.piece { margin-top: 8px !important; max-width: 100%; }
select.cat, select.piece {
  width: auto; min-height: 44px; margin: 0; padding: 6px 30px 6px 14px;
  border-radius: var(--wobble); font-family: var(--hand); font-weight: 500;
  -webkit-appearance: none; appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235f6489' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
}
.dur { display: flex; align-items: center; gap: 5px; font-size: 14px; color: var(--dim); }
.dur input { width: 54px; min-height: 44px; margin: 0; padding: 6px 4px; text-align: center; font-variant-numeric: tabular-nums; }

.total { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 16px; }
.total .label { font-family: var(--hand); font-weight: 600; }
.total b { font-family: var(--hand); font-size: 22px; font-weight: 600; }
.total .meta { margin-top: 0; }

.q { display: block; margin-top: 18px; font-family: var(--hand); font-size: 16px; font-weight: 600; color: var(--ink); }
textarea.lined {
  min-height: 70px; padding: 6px 12px; resize: none; overflow: hidden; line-height: 28px;
  background: linear-gradient(transparent 27px, var(--dots) 27px, var(--dots) 28.5px) 0 6px / 100% 28px, var(--surface);
}
/* ที่จด: ช่องเขียนมีเส้น (บันทึก สมุด คำตอบตอนปิดภาพ) และข้อ "ทำอะไร" ใช้ฟอนต์สารบรรณ */
textarea.lined, .did .what { font-family: var(--write); font-size: 17px; }
textarea::placeholder, input::placeholder { color: var(--dim); opacity: .75; }

/* คะแนน: แถวเดียว ชื่อ | แถบเลื่อน | ตัวเลข */
.score {
  display: grid; grid-template-columns: 78px 1fr 40px; align-items: center; gap: 10px;
  min-height: 50px; padding: 2px 0; border-bottom: 1.5px dashed var(--rule);
}
.score:last-child { border-bottom: 0; }
.score .name { font-family: var(--hand); font-size: 16px; font-weight: 600; line-height: 1.2; }
.score .name small { display: block; font-family: var(--read); font-size: 11px; font-weight: 400; color: var(--dim); }
.score .val { font-family: var(--hand); font-size: 22px; font-weight: 600; line-height: 1; text-align: right; font-variant-numeric: tabular-nums; }
.score.unset .val { color: var(--dim); }
input[type="range"] { flex: 1; min-width: 0; height: 44px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; --fill-color: var(--pen); }
.fuel input[type="range"] { --fill-color: var(--tape-a); }
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 8px;
  background: linear-gradient(var(--fill-color), var(--fill-color)) 0 0 / var(--fill, 0%) 100% no-repeat, var(--dots);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%;
  background: var(--star); border: 2px solid var(--pen);
}
input[type="range"]::-moz-range-track { height: 8px; border-radius: 8px; background: var(--dots); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: 8px; background: var(--fill-color); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--star); border: 2px solid var(--pen); }
.score.unset input[type="range"]::-webkit-slider-runnable-track { background: var(--dots); }
.score.unset input[type="range"]::-webkit-slider-thumb { background: var(--surface); }
.score[data-k="mood"] input[type="range"] { --fill-color: var(--tape-b); }
.sleep { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sleep label.field { margin-top: 6px; }
.sleep input { font-family: var(--hand); font-size: 18px; -webkit-appearance: none; appearance: none; text-align: left; }
#slept { margin: 8px 0 0; }

#deleteRow:empty { display: none; }
.past li { padding: 0; }
.past a { display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 48px; padding: 11px 2px; color: inherit; text-decoration: none; }
.past .hand { font-weight: 600; white-space: nowrap; }
.past .dim { font-size: 14px; }
.past .num { margin-left: auto; font-weight: 500; font-size: 14px; color: var(--dim); white-space: nowrap; }

/* ตารางวันนี้: ติ๊กได้ หลอดชั่วโมงเติมขึ้น (ไม่บอกว่าขาด) */
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head .tape { margin-bottom: 0; }
select.preset-pick {
  width: auto; min-height: 44px; margin: 0; padding: 6px 30px 6px 14px;
  border: 1.6px solid var(--pen); border-radius: var(--wobble); background: transparent;
  font-family: var(--hand); font-weight: 500; -webkit-appearance: none; appearance: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23cfc4e2' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
}
.quiet { margin: 10px 2px 0; }
.fuelbar { display: flex; align-items: center; gap: 12px; margin: 12px 2px 2px; }
.fuelbar .got { white-space: nowrap; font-size: 14px; color: var(--dim); }
.fuelbar .got b { font-family: var(--hand); font-size: 18px; font-weight: 600; color: var(--ink); }
.fuelbar .bar { flex: 1; height: 8px; border-radius: 8px; background: var(--rule); overflow: hidden; }
.fuelbar .bar i { display: block; height: 100%; border-radius: 8px; background: var(--star); transition: width .3s; }
.steps li { padding: 0; }
.tick {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 8px 2px;
  border: 0; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.tick svg { flex: none; width: 22px; height: 22px; fill: none; stroke: var(--pen); stroke-width: 1.8; stroke-linejoin: round; }
.tick[aria-pressed="true"] svg { fill: var(--star); stroke: var(--star); }
.tick[aria-pressed="true"] .n { color: var(--dim); text-decoration: line-through; text-decoration-color: var(--rule); }
.tick .t { margin-left: auto; color: var(--dim); font-size: 14px; white-space: nowrap; }
.ask { margin: 4px 0 14px; padding: 14px 16px; border: 1.6px dashed var(--pen); border-radius: var(--wobble); }
.ask p { margin: 0; }
.ask .btn-row { margin-top: 10px; }

/* ตั้งค่า: วันในสัปดาห์ → พรีเซ็ต */
.weekmap li { padding: 6px 2px; }
.weekmap select { width: auto; min-width: 150px; margin: 0; min-height: 44px; font-family: var(--hand); }
p.q { margin-bottom: 0; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; }

/* ดาวที่บันทึกต่อถึง (หน้าบันทึก) */
.linked { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.linked p { margin: 0; }
.linked-say { flex-basis: 100%; }
.starchip { display: inline-flex; align-items: center; min-height: 40px; border: 1.6px solid var(--pen); border-radius: var(--wobble); background: var(--star); font-family: var(--hand); font-size: 15px; }
.starchip a { padding: 6px 4px 6px 12px; color: var(--star-ink); text-decoration: none; font-weight: 600; }
.starchip button { width: 36px; min-height: 40px; border: 0; background: none; color: var(--star-ink); font-size: 18px; cursor: pointer; }
.starchip.off { padding: 6px 12px; background: transparent; color: var(--dim); border-style: dashed; cursor: pointer; }

/* ───── แท็บฝึก: ดาวความรู้ ───── */
.trainpage h1 { font-size: 32px; }
.lead { margin: 4px 0 0; font-size: 15px; }
/* แผนที่วงโคจร: ที่เดียวในแอพที่มีแสงเรือง (นุ่ม จาง แบบ sacred) */
.sk-compo { --sk: var(--sk-compo); }
.sk-light { --sk: var(--sk-light); }
.sk-finish { --sk: var(--sk-finish); }
.sk-line { --sk: var(--sk-line); }
.sk-none { --sk: var(--sk-none); }
.skyframe { margin: 10px -12px 0; padding: 8px 4px 12px; border-radius: 26px; background: radial-gradient(420px 360px at 50% 210px, var(--surface), var(--bg) 62%, var(--sky-deep)); }
.kmap { display: block; width: 100%; height: auto; -webkit-tap-highlight-color: transparent; }
.kmap .geo { fill: none; stroke: var(--geo); stroke-width: .7; }
.kmap .ring.r0 { stroke-opacity: .2; }
.kmap .ring.r1 { stroke-opacity: .15; }
.kmap .ring.r2 { stroke-opacity: .11; }
.kmap .sq { stroke-opacity: .1; }
.kmap .sq.faint { stroke-opacity: .06; }
.kmap .ax { stroke-opacity: .07; stroke-dasharray: 1 5; }
.kmap .ax.faint { stroke-opacity: .035; }
.kmap .pins circle { fill: var(--geo); fill-opacity: .35; }
.kmap .skname { font: 600 13px var(--hand); fill: var(--sk); opacity: .85; }
.kmap .today-ring { fill: none; stroke: var(--ink); stroke-opacity: .4; stroke-width: .7; }
.kmap .today { fill: var(--ink); opacity: .9; }
.kmap .hit { fill: transparent; }
.kmap .node { cursor: pointer; outline: none; }
.kmap .core { fill: var(--sk); }
.kmap .eye { fill: var(--ink); }
.kmap .node.unseen .core { fill: none; stroke: var(--sk); stroke-width: 1.2; }
.kmap .node.unseen .eye { display: none; }
.kmap .clear-ring { fill: none; stroke: var(--star); stroke-width: 1.2; }
.kmap .lbl { font-family: var(--hand); font-size: 12px; fill: var(--ink); letter-spacing: .02em; }
.kmap .lbl.big { font-size: 13.5px; }
.kmap .lbl .n { font-family: var(--read); font-weight: 500; font-size: 11px; fill: var(--dim); }
.kmap .lbl.soft { display: none; }
.kmap .near .lbl.soft, .kmap .node:focus-visible .lbl.soft { display: inline; }
.kmap .node:focus-visible .core { stroke: var(--ink); stroke-width: 1.5; }
.kmap .co line { display: none; stroke: var(--ink); stroke-opacity: .4; stroke-width: .8; stroke-dasharray: 1 4; stroke-linecap: round; }
.kmap .co line.on { display: inline; }
.kmap .halos circle, .kmap .node { transition: opacity .2s; }
.kmap.picked .halos circle:not(.near), .kmap.picked .node:not(.near) { opacity: .18; }
.key { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 4px 0 0; padding: 0 10px; list-style: none; font-size: 13px; color: var(--dim); }
.key i { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--sk); }
.keynote { margin: 2px 0 0; padding: 0 10px; font-size: 12.5px; color: var(--dim); }
.focus { margin: 10px 4px 0; padding: 12px 16px 14px; border-radius: 20px; background: var(--surface); }
.focus p { margin: 0 0 8px; }
.focus b { font: 600 19px var(--hand); color: var(--sk); margin-right: 6px; }
.focus .dim { font-size: 13.5px; }
.clearbox { margin: 14px 0 4px; }
.clearbox .faint { margin: 8px 0 0; }
.cleared-tag { display: inline-block; padding: 1px 12px; border: 1.4px solid var(--star); border-radius: var(--wobble); font: 600 15px var(--hand); color: var(--star); letter-spacing: .04em; }
.btn.small { min-height: 44px; padding: 6px 16px; font-size: 15px; }
.newstar { margin-top: 6px; }
.starname { color: var(--star); }
.tl { margin: 4px 0 6px; padding: 0 0 0 22px; list-style: none; position: relative; }
.tl::before { content: ""; position: absolute; left: 6px; top: 12px; bottom: 12px; border-left: 1.8px dashed var(--rule); }
.tl li { position: relative; padding: 8px 0; }
.tl li::before { content: ""; position: absolute; left: -21px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 1.8px solid var(--pen); }
.tl li.win::before { background: var(--star); border-color: var(--star); }
.tl .d { font-family: var(--hand); font-weight: 600; font-size: 15px; color: var(--ink); text-decoration: none; }
.tl p { margin: 3px 0 0; font-size: 15px; }
.tl .k { display: inline-block; margin-right: 4px; padding: 0 8px; border-radius: 8px; font-size: 12px; background: var(--rule); color: var(--ink); }
.tl .k.good { background: var(--tape-b); color: var(--tape-b-ink); }

/* ───── สัปดาห์นี้: หน้าแรก (แถบสั้น) แท็บฝึก (กล่อง) หน้าภาพ/หน้าสัปดาห์ (กระดาษ) ───── */
.weekstrip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; margin: 0 0 14px; padding: 10px 16px;
  border: 1.6px dashed var(--rule); border-radius: var(--wobble);
  color: var(--ink); text-decoration: none;
}
.weekstrip small { display: block; font-size: 12px; color: var(--dim); }
.wk-focus { min-width: 0; font-family: var(--hand); font-weight: 600; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.wk-pieces { flex: none; text-align: right; }
.pstars { display: inline-flex; gap: 3px; }
.pstar { width: 20px; height: 20px; fill: none; stroke: var(--pen); stroke-width: 1.8; stroke-linejoin: round; }
.pstar.done { fill: var(--star); stroke: var(--star); }
.pstar.open { stroke: var(--star); }
.pstar.empty { stroke: var(--dim); stroke-width: 1.4; opacity: .6; }

.trainpage > h1 + .weekbox { margin-top: 10px; }
.weekbox { margin: 10px -20px 4px; padding: 16px 20px 6px; border-radius: 26px; background: var(--surface); }
.weekbox .sheet-head .linkbtn { font-size: 14px; }
.focusline { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0 4px; padding: 6px 0; color: var(--ink); text-decoration: none; font-family: var(--hand); font-weight: 600; font-size: 17px; line-height: 1.35; }
.focusline small { display: block; font-family: var(--read); font-weight: 400; font-size: 12px; color: var(--dim); }
.maptitle { margin: 26px 0 0; font-size: 22px; }
.slots li { padding: 0; }
.slots a { display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 48px; padding: 11px 2px; color: inherit; text-decoration: none; }
.slots .hand { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.slots .dim { font-size: 13px; white-space: nowrap; }
.slots .num { margin-left: auto; font-size: 14px; font-weight: 500; color: var(--dim); white-space: nowrap; }
.slots .done .hand { color: var(--star); }
[data-theme="paper"] .slots .done .hand { color: var(--ink); }
.slot.empty { min-height: 48px; padding: 11px 2px; border-bottom-style: dotted; }

.workpage .log-head h1 { font-size: 30px; overflow-wrap: anywhere; }
.cleared-stamp { flex: none; margin-bottom: 6px; padding: 2px 12px; border: 2px solid var(--pen); border-radius: var(--wobble); font: 600 15px var(--hand); letter-spacing: .05em; transform: rotate(-4deg); background: var(--star); color: var(--star-ink); }
.hours { margin: 2px 0 4px; }
.hours b { font-family: var(--hand); font-size: 30px; font-weight: 600; }
.entries li { padding: 0; }
.entries li.dim { padding: 10px 2px; font-size: 14px; }
.entries a { display: flex; align-items: baseline; gap: 10px; width: 100%; min-height: 46px; padding: 10px 2px; color: inherit; text-decoration: none; }
.entries .hand { font-weight: 600; white-space: nowrap; }
.entries .dim { min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entries .num { margin-left: auto; font-size: 14px; white-space: nowrap; }
.extra .q { margin-top: 16px; }
.extra .faint { margin: 6px 0 0; }
.extra .faint .linkbtn { min-height: 32px; padding: 0 4px; font-size: 13px; }
.weeknav { display: flex; justify-content: space-between; gap: 12px; margin-top: -6px; }
.workpage input[type="text"]#main, .workpage input#side { font-family: var(--hand); font-weight: 500; }
#nextPick .chips { margin-top: 8px; }

/* ───── คลัง gap · การ์ดศึกษา · สมุดกฎ ───── */
.gapform { display: flex; gap: 8px; align-items: stretch; margin-top: 14px; }
.gapform input { flex: 1; min-width: 0; margin: 0; }
.gapform .btn { flex: none; }
.gapbox { margin: 14px 0 0; }
.gapbox .gapform { margin-top: 0; }
.gapbox .gapform input { min-height: 44px; }
.gaplinks { display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; }
.gaplinks b { font-family: var(--hand); color: var(--ink); }
.gaplist { margin: 18px 0 0; padding: 0; list-style: none; }
.gaplist li { padding: 12px 2px; border-bottom: 1.5px dashed var(--rule); }
.gaplist .gt { margin: 0; font-family: var(--write); font-size: 17px; overflow-wrap: anywhere; }
.gaplist .faint { margin: 2px 0 8px; }
.gap-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gap-acts .linkbtn { margin-left: auto; }
.moved li { font-size: 15px; }
.moved a { color: inherit; }
.moved .linkbtn { min-height: 32px; padding: 0 4px; font-size: 13px; }
.draftbox { margin-bottom: 4px; }
.draftbox .faint { margin: 8px 0 0; }
.cardpage input#c-topic { font-family: var(--hand); font-weight: 600; }
.cardsteps { margin: 0; padding: 0; list-style: none; }
.cardsteps li { padding: 4px 0 12px; border-bottom: 1.5px dashed var(--rule); }
.cardsteps .tick { min-height: 46px; }
.cardsteps .n { font-family: var(--hand); font-weight: 600; }
.cardsteps textarea { margin-top: 0; min-height: 44px; }
.rules { margin: 16px 0 0; padding: 0; list-style: none; counter-reset: none; }
.rules li { display: grid; grid-template-columns: 30px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1.5px dashed var(--rule); }
.rules .rn { font-family: var(--hand); font-weight: 600; font-size: 20px; text-align: center; padding-top: 8px; }
.rules textarea { margin-top: 0; min-height: 44px; }
.rules .faint { margin: 6px 0 0; }
.rules .faint a { color: inherit; }
.rules .linkbtn { min-height: 32px; padding: 0 6px; font-size: 13px; }
.cmp { padding: 2px 0 12px; border-bottom: 1.5px dashed var(--rule); }
.cmp .q { margin-top: 12px; margin-bottom: 6px; }
.cmp .chip { min-height: 40px; padding: 4px 12px; font-size: 14px; }
.cmp textarea { margin-top: 8px; min-height: 44px; }
.cmp .faint { margin: 6px 0 0; }

/* ───── สมุดเขียนอิสระ ───── */
a.chip { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.chip .n { font-family: var(--read); font-size: 12px; font-weight: 500; opacity: .75; }
.cat-hint { margin: 12px 2px 0; font-size: 14px; }
.notes { margin-top: 18px; }
.notes li { padding: 0; }
.notes a { display: block; width: 100%; min-height: 56px; padding: 10px 2px; color: inherit; text-decoration: none; }
.notes .nt { display: block; font-family: var(--hand); font-size: 17px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.notes .faint { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-note { margin-top: 18px; }
.note-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.note-top .back { margin-bottom: 0; }
.note-top .save-state { margin: 0; }
input.note-title {
  margin-top: 4px; padding: 4px 2px; border: 0; border-bottom: 1.8px dashed var(--rule); border-radius: 0;
  background: transparent; font-family: var(--hand); font-size: 26px; font-weight: 600; line-height: 1.3;
}
.note-day { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin: 10px 0 12px; }
.note-day .hand { font-size: 16px; font-weight: 600; }
.note-day label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.note-day input[type="date"] { width: auto; min-height: 40px; margin: 0; padding: 4px 10px; font-size: 16px; -webkit-appearance: none; appearance: none; }
textarea.note-text { min-height: 300px; }

/* ───── AI: รีวิวบันทึก และแชท ───── */
details.more { margin-top: 14px; }
details.more summary { list-style: none; display: inline-block; }
details.more summary::-webkit-details-marker { display: none; }
.ai-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16px; line-height: 1.7; }
.review { margin-top: 4px; }
.review .ai-text { padding: 14px 16px; border: 1.6px dashed var(--pen); border-radius: var(--wobble); background: var(--surface); }
.review .faint { margin: 8px 0 0; }
.thinking { color: var(--dim); font-family: var(--hand); }
.chatpage { display: flex; flex-direction: column; min-height: calc(100dvh - var(--safe-top) - var(--tab-h) - var(--safe-bottom) - 50px); }
.msgs { flex: 1; display: flex; flex-direction: column; gap: 12px; margin: 18px 0 14px; padding: 0; list-style: none; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: var(--wobble); }
.msg.user { align-self: flex-end; background: var(--pen); color: var(--bg); }
.msg.assistant { align-self: flex-start; border: 1.6px solid var(--pen); background: var(--surface); }
.msg.err { align-self: center; max-width: 100%; color: var(--danger); font-size: 14px; text-align: center; }
.msg .ai-text { font-size: 15.5px; line-height: 1.65; }
.composer { position: sticky; bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px); display: flex; align-items: flex-end; gap: 8px; padding-top: 8px; background: var(--bg); }
.composer textarea { flex: 1; min-height: 48px; max-height: 160px; margin: 0; resize: none; line-height: 1.5; }
.composer .btn { flex: none; }
.chat-empty { margin-top: 18px; }
.chat-empty .chips { margin-top: 10px; }

/* ───── หน้าที่ยังไม่เปิด ───── */
.locked { margin-top: 28px; text-align: center; }
.locked svg { width: 56px; height: 56px; fill: none; stroke: var(--pen); stroke-width: 1.4; stroke-linejoin: round; opacity: .6; }
.locked p { margin: 6px 0 0; }

/* ───── แถบเมนูล่าง ───── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--tab-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  border-top: 1.8px solid var(--rule);
  background: var(--bar);
}
[data-theme="paper"] .tabs { border-top-color: var(--pen); }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--dim); text-decoration: none; font-family: var(--hand); font-size: 11px; font-weight: 500;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
[data-theme="sky"] .tab[aria-current="page"] { color: var(--star); }
.tab[aria-current="page"] svg { fill: var(--star); stroke: var(--ink); }
[data-theme="sky"] .tab[aria-current="page"] svg { stroke: var(--star); }

/* ───── ข้อความแจ้งสั้น ๆ ───── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-bottom) + 16px); z-index: 20;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: var(--wobble);
  background: var(--ink); color: var(--bg); font-family: var(--hand); font-size: 15px; font-weight: 500;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
