/* Target Path: style.css */
/* เขียนโค้ดจาก agent version: .agents-3.6 */
/* ════════════════════════════════════════════════════════════════════
   🎨 TaskPop — Design System (คัดลอกตรงจาก prototypes/taskpop/prototype.html
   กฎเหล็ก: tokens/คลาส/keyframes ทั้งหมดต้องตรงต้นแบบ — ห้ามออกแบบใหม่/เดาสี)
   ════════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Sarabun:wght@300;400;500;600;700&display=swap');

/* ═══════════ TOKENS — Light ═══════════ */
:root {
  --font: 'Outfit', 'Sarabun', system-ui, -apple-system, sans-serif;

  --bg: #FBF6F1;
  --bg-soft: #FFFDFB;
  --card: #FFFFFF;
  --card-2: #FFF3EA;
  --text: #2A2A3E;
  --muted: #7C7C96;
  --border: #EFE5DB;
  --border-soft: #F6EFE8;

  /* แบรนด์ (เปลี่ยนได้จากตั้งค่า → สีหลัก) */
  --accent: #FF7A59;
  --accent-2: #FF5D8F;
  --accent-soft: #FFEDE6;
  --accent-ink: #E85D3C;

  /* หมวดสี */
  --c-work: #4D96FF;
  --c-personal: #F472B6;
  --c-study: #9B72FF;
  --c-health: #2FC0A0;
  --c-errand: #FFB454;

  /* ความสำคัญ */
  --p-high: #FF6B6B;
  --p-mid: #FFB454;
  --p-low: #2FC0A0;

  --success: #2FB98F;
  --danger: #F2445C;
  --warning: #FFB454;

  --radius: 18px;
  --radius-lg: 26px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --shadow-sm: 0 1px 2px rgba(42,42,62,.04), 0 2px 8px rgba(42,42,62,.05);
  --shadow-md: 0 2px 4px rgba(42,42,62,.05), 0 10px 28px -10px rgba(42,42,62,.16);
  --shadow-lg: 0 2px 6px rgba(42,42,62,.06), 0 24px 60px -18px rgba(42,42,62,.28);
  --shadow-accent: 0 12px 26px -10px color-mix(in srgb, var(--accent) 60%, transparent);
}

/* ═══════════ TOKENS — Dark ═══════════ */
[data-theme="dark"] {
  --bg: #141420;
  --bg-soft: #1B1B2A;
  --card: #20202F;
  --card-2: #2A2A3E;
  --text: #F2F2F8;
  --muted: #9C9CB5;
  --border: #2E2E44;
  --border-soft: #26263A;
  --accent-soft: rgba(255, 122, 89, .16);
  --accent-ink: #FF9A7E;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.2), 0 2px 8px rgba(0,0,0,.25);
  --shadow-md: 0 2px 4px rgba(0,0,0,.3), 0 12px 30px -12px rgba(0,0,0,.5);
  --shadow-lg: 0 2px 8px rgba(0,0,0,.4), 0 30px 70px -20px rgba(0,0,0,.65);
  --shadow-accent: 0 12px 26px -10px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ═══════════ RESET ═══════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: var(--font); }
input, textarea, select { font-family: var(--font); }
button:focus:not(:focus-visible), input:focus:not(:focus-visible), textarea:focus:not(:focus-visible) { outline: none; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color .35s ease, color .35s ease;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ MOBILE FRAME ═══════════ */
@media (min-width: 769px) {
  body.mobile-framed {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 18px;
    background:
      radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
      radial-gradient(700px 420px at 90% 10%, color-mix(in srgb, var(--c-study) 12%, transparent), transparent 55%),
      #16161F;
  }
  body.mobile-framed .app-container {
    /* ขนาดเฟรมยืดหยุ่นตามจอ: กว้างสุด 430px, สูงสุด 92vh แต่ห้ามเกินหน้าต่าง (กัน bottom nav ตกขอบ) */
    width: min(430px, calc(100vw - 36px));
    height: min(92vh, calc(100vh - 36px));
    min-height: 0;
    border-radius: 32px; overflow: hidden; position: relative;
    border: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 40px 90px -30px rgba(0,0,0,.6);
    display: flex; flex-direction: column; background: var(--bg);
  }
}
.app-container { position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg); transition: background .35s; }

/* ═══════════ TABLET (481–768px): กันเนื้อหายืดเต็มจอจนดูพัง ═══════════ */
@media (min-width: 481px) and (max-width: 768px) {
  .app-container { max-width: 560px; margin: 0 auto; border-inline: 1px solid var(--border-soft); }
}

/* ═══════════ HEADER ═══════════ */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 10px 18px 8px; flex: none;
  background: var(--bg);
}
.header-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 14px; flex: none;
  display: grid; place-items: center; color: #fff; font-size: 19px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-accent);
  animation: logoFloat 4s var(--ease) infinite;
}
@keyframes logoFloat { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-3px) rotate(-3deg); } }
.header-brand h1 { font-size: 1.14rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; white-space: nowrap; }
.header-brand small { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.header-right { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--card); color: var(--text); font-size: 1.05rem; cursor: pointer;
  display: grid; place-items: center; transition: transform .2s var(--ease), box-shadow .25s, border-color .2s;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.icon-btn:active { transform: scale(.92); }
.icon-btn i { transition: transform .5s var(--ease); }
.icon-btn.swap i { transform: rotate(360deg) scale(1.15); }

/* ═══════════ CONTENT / VIEWS ═══════════ */
.app-content { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 6px 18px 120px; scroll-behavior: smooth; }
.view { display: none; }
.view.active { display: block; }
.view.active.anim { animation: viewIn .5s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h2 { font-size: 1.06rem; font-weight: 800; letter-spacing: -.01em; }
.section-title .count-badge { font-size: .72rem; font-weight: 700; color: var(--muted); background: var(--card); border: 1px solid var(--border); padding: 2px 9px; border-radius: 99px; }
.section-title button { background: none; border: none; color: var(--accent); font-weight: 700; font-size: .82rem; cursor: pointer; padding: 4px; display: inline-flex; align-items: center; gap: 4px; }

/* ═══════════ HERO (วันนี้) ═══════════ */
.hero { padding: 8px 2px 4px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hero h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.hero .date-line { font-size: .86rem; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.streak-pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: .78rem; font-weight: 800; color: #B45309;
  background: #FFF3DC; border: 1.5px solid #FFDFAE; border-radius: 99px; padding: 7px 12px;
  animation: streakGlow 2.6s ease-in-out infinite;
}
[data-theme="dark"] .streak-pill { color: #FFC466; background: rgba(255,170,50,.12); border-color: rgba(255,170,50,.3); }
.streak-pill i { font-size: .9rem; }
@keyframes streakGlow { 0%,100% { box-shadow: 0 0 0 0 rgba(255,170,50,.25); } 50% { box-shadow: 0 0 0 6px rgba(255,170,50,0); } }

/* ═══════════ CARDS ═══════════ */
.t-card {
  background: var(--card); border: 1.5px solid var(--border-soft);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .3s var(--ease), border-color .25s;
}
.t-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border); }

.day-progress { display: flex; align-items: center; gap: 18px; padding: 18px; margin-top: 14px; }
.ring-wrap { position: relative; width: 104px; height: 104px; flex: none; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border-soft); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-center strong { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.ring-center span { font-size: .64rem; font-weight: 700; color: var(--muted); margin-top: 3px; }
.day-progress-info { flex: 1; min-width: 0; }
.day-progress-info h3 { font-size: .98rem; font-weight: 800; }
.day-progress-info p { font-size: .82rem; color: var(--muted); margin-top: 3px; }
.mini-bar { height: 8px; border-radius: 99px; background: var(--border-soft); margin-top: 12px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 1.1s var(--ease); }

.quick-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.qstat {
  background: var(--card); border: 1.5px solid var(--border-soft); border-radius: 16px;
  padding: 13px 12px; text-align: left; transition: transform .2s var(--ease), box-shadow .25s;
}
.qstat:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.qstat i { font-size: .95rem; }
.qstat .num { font-size: 1.28rem; font-weight: 800; line-height: 1.1; margin-top: 6px; }
.qstat .lbl { font-size: .7rem; font-weight: 600; color: var(--muted); }

.focus-card { display: flex; align-items: center; gap: 16px; padding: 16px 18px; margin-top: 12px; }
.focus-ring { position: relative; width: 84px; height: 84px; flex: none; }
.focus-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.focus-ring .ring-bg { stroke-width: 8; }
.focus-ring .ring-fg { stroke: var(--c-study); stroke-width: 8; }
.focus-time { position: absolute; inset: 0; display: grid; place-items: center; font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.focus-info { flex: 1; min-width: 0; }
.focus-info h3 { font-size: .95rem; font-weight: 800; display: flex; align-items: center; gap: 6px; }
.focus-info p { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.focus-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ═══════════ TASKS ═══════════ */
.t-task {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  text-align: left; background: var(--card); border: 1.5px solid var(--border-soft);
  border-radius: 16px; padding: 13px 14px; margin-bottom: 9px;
  transition: transform .2s var(--ease), box-shadow .25s var(--ease), border-color .2s, opacity .3s, max-height .4s var(--ease);
  animation: taskIn .55s var(--ease) both; animation-delay: var(--d, 0s);
}
.t-task::after {
  content: "\f054"; font-family: "Font Awesome 6 Free"; font-weight: 900;
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  font-size: .62rem; color: var(--muted); opacity: .45;
}
.t-task-open { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; text-align: left; background: none; border: none; padding: 0; cursor: pointer; }
@keyframes taskIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.t-task:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border); }
.t-task.done { opacity: .62; }
.t-task.leaving { opacity: 0; transform: translateX(24px) scale(.96); max-height: 0; margin-bottom: 0; border-width: 0; padding-top: 0; padding-bottom: 0; }
.t-check {
  width: 27px; height: 27px; border-radius: 10px; flex: none;
  border: 2px solid var(--border); background: var(--card); cursor: pointer;
  display: grid; place-items: center; color: transparent; padding: 0;
  transition: all .25s var(--ease);
}
.t-check:hover { border-color: var(--accent); }
.t-check svg { width: 14px; height: 14px; }
.t-task.done .t-check {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff; animation: checkPop .5s var(--ease);
}
@keyframes checkPop { 0% { transform: scale(1); } 45% { transform: scale(1.28) rotate(-8deg); } 70% { transform: scale(.92); } 100% { transform: scale(1); } }
.t-task-body { flex: 1; min-width: 0; }
.t-task-title { font-size: .95rem; font-weight: 600; line-height: 1.35; display: block; transition: color .25s; }
.t-task-created { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: .68rem; font-weight: 500; color: var(--muted); }
.t-task.done .t-task-created { opacity: .6; }
.t-task.done .t-task-title { text-decoration: line-through; color: var(--muted); }
.t-task-meta { display: flex; align-items: center; gap: 7px; margin-top: 4px; font-size: .74rem; font-weight: 600; color: var(--muted); flex-wrap: wrap; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.prio-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.time-tag { font-variant-numeric: tabular-nums; }
.t-task-more { color: var(--muted); font-size: .8rem; flex: none; opacity: .6; }

.task-group-title { display: flex; align-items: center; gap: 8px; margin: 18px 2px 9px; }
.task-group-title h3 { font-size: .84rem; font-weight: 800; color: var(--muted); letter-spacing: .02em; text-transform: uppercase; }
.task-group-title span { font-size: .7rem; font-weight: 700; color: var(--muted); opacity: .7; }
.task-group-title::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }

/* ═══════════ CHIPS / FILTERS ═══════════ */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.t-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 700; color: var(--muted);
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: 99px; padding: 8px 14px; cursor: pointer;
  min-height: 36px; transition: all .22s var(--ease);
}
.t-chip:active { transform: scale(.94); }
.t-chip.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.t-chip .cat-dot { display: none; }
.t-chip.cat.active { background: color-mix(in srgb, var(--cc, var(--accent)) 14%, var(--card)); border-color: color-mix(in srgb, var(--cc, var(--accent)) 55%, transparent); color: var(--cc, var(--accent)); }
.t-chip.cat.active .cat-dot { display: inline-block; }

.search-wrap { position: relative; margin: 4px 0 12px; }
.search-wrap > i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; pointer-events: none; }
.t-input {
  width: 100%; font-size: 1rem; font-weight: 500; color: var(--text);
  background: var(--card); border: 1.5px solid var(--border); border-radius: 15px;
  padding: 13px 14px 13px 42px; transition: border-color .2s, box-shadow .25s;
}
.t-input::placeholder { color: var(--muted); opacity: .75; }
.t-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }

.view-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 12px; }
.view-head h1 { font-size: 1.42rem; font-weight: 800; letter-spacing: -.02em; }
.view-head .count-badge { font-size: .76rem; font-weight: 700; color: var(--muted); }

.empty-state { text-align: center; padding: 44px 20px; }
.empty-state .big { font-size: 2.6rem; animation: bounceSoft 2.4s var(--ease) infinite; display: inline-block; }
@keyframes bounceSoft { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.empty-state h3 { font-size: 1rem; font-weight: 800; margin-top: 10px; }
.empty-state p { font-size: .84rem; color: var(--muted); margin-top: 4px; }

/* ═══════════ NOTES ═══════════ */
.notes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.t-note {
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  text-align: left; background: var(--card); border: 1.5px solid var(--border-soft);
  border-radius: 16px; padding: 14px; cursor: pointer; position: relative;
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .22s var(--ease), box-shadow .28s var(--ease), border-color .2s;
  animation: taskIn .55s var(--ease) both; animation-delay: var(--d, 0s);
}
.t-note::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--nc, var(--accent)); }
.t-note:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--border); }
.t-note .pin { position: absolute; top: 12px; right: 12px; color: var(--warning); font-size: .8rem; animation: pinWiggle 3s ease-in-out infinite; transform-origin: top center; }
@keyframes pinWiggle { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(14deg); } 94% { transform: rotate(-10deg); } 98% { transform: rotate(6deg); } }
.t-note-tag { font-size: .66rem; font-weight: 800; letter-spacing: .04em; color: var(--nc, var(--accent)); background: color-mix(in srgb, var(--nc, var(--accent)) 13%, transparent); padding: 3px 9px; border-radius: 99px; }
.t-note-title { font-size: .92rem; font-weight: 700; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-right: 18px; }
.t-note-snip { font-size: .76rem; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.t-note-date { font-size: .68rem; font-weight: 600; color: var(--muted); margin-top: 2px; }

/* ═══════════ TIMELINE (สถิติ — ไทม์ไลน์เพิ่งสร้าง) ═══════════ */
.tl-day {
  display: flex; align-items: center; gap: 8px; margin: 14px 0 8px;
  font-size: .72rem; font-weight: 800; color: var(--muted); letter-spacing: .02em;
}
.tl-day::after { content: ""; flex: 1; height: 1px; background: var(--border-soft); }
.tl-day:first-child { margin-top: 2px; }
.tl-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: var(--card); border: 1.5px solid var(--border-soft); border-radius: 14px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer; text-align: left;
  transition: transform .2s var(--ease), box-shadow .25s, border-color .2s;
  animation: taskIn .45s var(--ease) both; animation-delay: var(--d, 0s);
}
.tl-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border); }
.tl-item:active { transform: scale(.985); }
.tl-ico {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; color: #fff; font-size: .95rem;
  box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--tc, var(--accent)) 70%, transparent);
}
.tl-body { flex: 1; min-width: 0; }
.tl-title { display: block; font-size: .86rem; font-weight: 700; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-meta { display: flex; align-items: center; gap: 5px; margin-top: 3px; font-size: .68rem; font-weight: 600; color: var(--muted); }
.tl-type {
  flex: none; padding: 3px 8px; border-radius: 99px; font-size: .62rem; font-weight: 800; letter-spacing: .03em;
}

/* ═══════════ STATS ═══════════ */
.stat-hero { display: flex; align-items: center; gap: 18px; padding: 20px; margin-top: 4px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--card)), color-mix(in srgb, var(--c-study) 10%, var(--card))); }
.stat-hero .flame { font-size: 2.4rem; animation: flameFlick 1.4s ease-in-out infinite; transform-origin: bottom center; }
@keyframes flameFlick { 0%,100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.12) rotate(2deg); } }
.stat-hero h2 { font-size: 1.05rem; font-weight: 800; }
.stat-hero .big { font-size: 2rem; font-weight: 800; line-height: 1; color: var(--warning); }
.stat-hero p { font-size: .78rem; color: var(--muted); margin-top: 4px; }

.chart-card { padding: 18px; margin-top: 12px; }
.chart-card h3 { font-size: .95rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.chart-card .sub { font-size: .74rem; color: var(--muted); margin-bottom: 14px; }
.bars { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; height: 132px; padding: 0 2px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.bar-val { font-size: .68rem; font-weight: 800; color: var(--muted); opacity: 0; transition: opacity .4s .5s; }
.bar-col.ready .bar-val { opacity: 1; }
.bar {
  width: 100%; max-width: 26px; border-radius: 8px 8px 5px 5px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 85%, #fff), var(--accent));
  transform: scaleY(0); transform-origin: bottom;
  transition: transform .7s var(--ease); transition-delay: var(--bd, 0s);
}
.bar-col.ready .bar { transform: scaleY(1); }
.bar-col.today .bar { background: linear-gradient(180deg, var(--accent-2), var(--accent)); box-shadow: var(--shadow-accent); }
.bar-day { font-size: .68rem; font-weight: 700; color: var(--muted); }
.bar-col.today .bar-day { color: var(--accent); font-weight: 800; }
.bar-col.today .bar-val { color: var(--accent); font-weight: 800; }

.donut-row { display: flex; align-items: center; gap: 18px; margin-top: 4px; }
.donut-wrap { position: relative; width: 108px; height: 108px; flex: none; }
.donut-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; flex-direction: column; }
.donut-center strong { font-size: 1.4rem; font-weight: 800; line-height: 1; }
.donut-center span { font-size: .62rem; font-weight: 700; color: var(--muted); margin-top: 3px; }
.donut-side { flex: 1; min-width: 0; }
.donut-side p { font-size: .84rem; color: var(--muted); }
.legend { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: .78rem; font-weight: 600; }
.legend-row .lbl { flex: 1; color: var(--muted); }
.legend-row .val { font-weight: 800; font-variant-numeric: tabular-nums; }
.lbar { height: 8px; flex: 1.2; border-radius: 99px; background: var(--border-soft); overflow: hidden; }
.lbar i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--lc); transition: width 1s var(--ease); transition-delay: var(--ld, 0s); }

.slot-row { display: flex; flex-direction: column; gap: 11px; }
.slot { display: flex; align-items: center; gap: 10px; font-size: .8rem; font-weight: 600; }
.slot .ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: .85rem; flex: none; }
.slot .lbl { width: 46px; flex: none; color: var(--muted); }
.slot .lbar { flex: 1; }
.slot .pct { width: 42px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ═══════════ SETTINGS ═══════════ */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 18px; margin-top: 4px; }
.avatar { width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center; font-size: 1.5rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex: none; }
.profile-card h3 { font-size: 1rem; font-weight: 800; }
.profile-card p { font-size: .78rem; color: var(--muted); }
.pro-badge { display: inline-flex; align-items: center; gap: 5px; font-size: .66rem; font-weight: 800; color: #8A5A00; background: #FFE9B8; border-radius: 99px; padding: 2px 8px; margin-top: 3px; }
[data-theme="dark"] .pro-badge { color: #FFD98C; background: rgba(255,185,60,.14); }

.set-group { margin-top: 16px; }
.set-group > h3 { font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 4px; margin-bottom: 8px; }
.set-card { background: var(--card); border: 1.5px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.set-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.set-row + .set-row { border-top: 1px solid var(--border-soft); }
.set-row .set-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: .95rem; flex: none; background: var(--accent-soft); color: var(--accent); }
.set-row .set-info { flex: 1; min-width: 0; }
.set-row .set-info h4 { font-size: .9rem; font-weight: 700; }
.set-row .set-info p { font-size: .74rem; color: var(--muted); }
.set-row button.t-btn { flex: none; }

.sync-status { padding: 12px 16px 14px; background: var(--bg); border-top: 1px solid var(--border-soft); }
.sync-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .78rem; padding: 4px 0; }
.sync-line > span { color: var(--muted); }
.sync-line > b { font-weight: 700; font-size: .82rem; }
.sync-line > b.ok { color: var(--success); }
.sync-line > b.err { color: var(--danger); }
.sync-line .sync-badge { display: inline-block; font-size: .68rem; font-weight: 800; letter-spacing: .04em; color: #8A5A00; background: #FFD98C; border-radius: 99px; padding: 3px 9px; }
[data-theme="dark"] .sync-line .sync-badge { color: #3A2A00; }

.theme-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-opt {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer;
  background: var(--card); border: 2px solid var(--border); border-radius: 14px; font-weight: 700; font-size: .86rem;
  transition: all .2s var(--ease);
}
.theme-opt i { font-size: 1rem; }
.theme-opt.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.theme-opt:active { transform: scale(.96); }

.accent-pick { display: flex; gap: 12px; padding: 6px 4px; }
.accent-dot {
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; position: relative;
  border: 3px solid var(--card); box-shadow: var(--shadow-sm);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.accent-dot:hover { transform: scale(1.12); }
.accent-dot.active { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--text); transform: scale(1.1); }
.accent-dot.active::after { content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: .8rem; }

.t-switch {
  width: 50px; height: 30px; border-radius: 99px; border: none; cursor: pointer; position: relative; flex: none;
  background: var(--border); transition: background .25s var(--ease); padding: 0;
}
.t-switch .knob { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .28s var(--ease); }
.t-switch[aria-checked="true"] { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.t-switch[aria-checked="true"] .knob { transform: translateX(20px); }

.t-notice { display: flex; gap: 12px; align-items: flex-start; background: #FFF7E6; border: 1.5px solid #FFE3AE; border-radius: 16px; padding: 14px 16px; margin-top: 16px; }
[data-theme="dark"] .t-notice { background: rgba(255,185,60,.08); border-color: rgba(255,185,60,.3); }
.t-notice p { font-size: .8rem; color: #7A5C1E; }
[data-theme="dark"] .t-notice p { color: #E8C98A; }
.t-badge-warn { flex: none; font-size: .64rem; font-weight: 800; letter-spacing: .05em; color: #8A5A00; background: #FFD98C; border-radius: 99px; padding: 4px 9px; margin-top: 2px; }
[data-theme="dark"] .t-badge-warn { color: #3A2A00; }
.t-badge-ok { flex: none; font-size: .64rem; font-weight: 800; letter-spacing: .05em; color: #0B6B4F; background: #B8EBD9; border-radius: 99px; padding: 4px 9px; margin-top: 2px; }
[data-theme="dark"] .t-badge-ok { color: #B7EFD9; background: rgba(18,184,134,.22); }

/* ═══════════ BUTTONS ═══════════ */
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: .92rem; font-weight: 700; border: none; border-radius: 14px; cursor: pointer;
  padding: 12px 18px; min-height: 46px; transition: transform .18s var(--ease), box-shadow .25s, filter .2s, background .2s, opacity .2s;
}
.t-btn:active { transform: scale(.96); }
.t-btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: var(--shadow-accent); }
.t-btn-primary:hover { filter: brightness(1.06); box-shadow: 0 16px 34px -12px color-mix(in srgb, var(--accent) 70%, transparent); }
.t-btn-ghost { background: var(--card); border: 1.5px solid var(--border); color: var(--text); }
.t-btn-ghost:hover { border-color: var(--muted); }
.t-btn-danger { background: var(--danger); color: #fff; }
.t-btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.t-btn-block { width: 100%; }
.t-btn:disabled { opacity: .62; cursor: not-allowed; transform: none; }

/* ═══════════ BOTTOM NAV — LIQUID BAR ═══════════
   วงกลมสีสไลด์ตามแท็บ + รอยเว้าที่ขอบบน (disc สีพื้นหลัง) + ป้ายใต้แท็บที่ active */
.app-bottom-nav {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: stretch;
  height: calc(76px + env(safe-area-inset-bottom));
  padding: 0 8px env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1.5px solid var(--border-soft);
  animation: navRise .6s var(--ease) both;
}
@keyframes navRise { from { transform: translateY(26px); opacity: 0; } to { transform: none; opacity: 1; } }

/* รอยเว้า (disc) — สีเดียวกับพื้นหลังแอป เพื่อ "ตัด" ขอบบนของแถบตรงตำแหน่งวงกลม */
.app-bottom-nav::before {
  content: ""; position: absolute; top: -31px; left: 0; z-index: 1;
  width: 62px; height: 62px; border-radius: 50%; background: var(--bg);
  transform: translateX(calc(var(--nav-x, 50px) - 31px));
  transition: transform .6s cubic-bezier(.34, 1.56, .64, 1), scale .3s var(--ease);
  pointer-events: none;
}

/* วงกลมสไลด์ — สี gradient ตามแท็บ */
.nav-slider {
  position: absolute; top: -29px; left: 0; z-index: 3;
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 1.22rem;
  background: linear-gradient(135deg, var(--nav-c1, var(--accent)), var(--nav-c2, var(--accent-2)));
  box-shadow:
    0 14px 28px -8px var(--nav-glow, rgba(255, 122, 51, .55)),
    0 4px 10px -2px rgba(0, 0, 0, .16),
    inset 0 2px 3px rgba(255, 255, 255, .55),
    inset 0 -3px 6px rgba(0, 0, 0, .12);
  transform: translateX(calc(var(--nav-x, 50px) - 29px));
  transition: transform .6s cubic-bezier(.34, 1.56, .64, 1), scale .3s var(--ease);
  pointer-events: none;
}
.nav-slider i { animation: none; }
.nav-slider.pop i { animation: navIcoPop .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes navIcoPop {
  0% { transform: scale(.3) rotate(-30deg); opacity: 0; }
  60% { transform: scale(1.32) rotate(8deg); }
  100% { transform: none; opacity: 1; }
}
/* สั่นจำลอง (haptic) — บีบ-ป็อปบน `scale` (ไม่ชนกับ translateX ที่สไลด์) */
.nav-slider.haptic { animation: navHaptic .34s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes navHaptic {
  0%   { scale: 1; }
  16%  { scale: .78; }
  36%  { scale: 1.09; }
  54%  { scale: .86; }
  72%  { scale: 1.05; }
  100% { scale: 1; }
}
/* แสงวิ่งผ่านวงกลมตอนสไลด์มา */
.nav-slider::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .5) 50%, transparent 70%);
  transform: translateX(-110%); opacity: 0;
}
.nav-slider.pop::after { animation: navShine .65s var(--ease); }
@keyframes navShine { 0% { transform: translateX(-110%); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateX(110%); opacity: 0; } }

/* 🌊 คลื่นน้ำพุ่งออกสองข้างจากวงกลม (--dir: -1 ซ้าย / 1 ขวา) */
.nav-wave {
  position: absolute; top: -11px; left: 0; z-index: 2;
  width: 128px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--nav-c1, var(--accent)), var(--nav-c2, var(--accent-2)));
  pointer-events: none; opacity: 0;
  transform: translateX(calc(var(--nav-x, 50px) - 64px));
  animation: navWave .6s cubic-bezier(.34, 1.56, .64, 1) forwards;
}
@keyframes navWave {
  0%   { opacity: 0; transform: translateX(calc(var(--nav-x, 50px) - 64px)) scaleX(.15); }
  28%  { opacity: .72; }
  100% { opacity: 0; transform: translateX(calc(var(--nav-x, 50px) - 64px + 100px * var(--dir, 1))) scaleX(1); }
}
/* วงแหวนกระจาย (ripple) จากจุดศูนย์กลางวงกลม */
.nav-ring {
  position: absolute; top: 0; left: 0; z-index: 2;
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--nav-c1, var(--accent));
  background: color-mix(in srgb, var(--nav-c1, var(--accent)) 18%, transparent);
  pointer-events: none; opacity: 0;
  transform: translateX(calc(var(--nav-x, 50px) - 18px)) translateY(-18px) scale(.5);
  animation: navRing .65s var(--ease) forwards;
}
@keyframes navRing {
  0%   { opacity: .9; transform: translateX(calc(var(--nav-x, 50px) - 18px)) translateY(-18px) scale(.5); }
  100% { opacity: 0; transform: translateX(calc(var(--nav-x, 50px) - 18px)) translateY(-18px) scale(3); }
}

.bottom-nav-link {
  position: relative; flex: 1; display: grid; place-items: center;
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 0; min-height: 0; border-radius: 13px;
  transition: color .25s;
}
.bottom-nav-link i { font-size: 1.22rem; transition: transform .3s var(--ease); }
.bottom-nav-link:active i { transform: scale(.88); }
.bottom-nav-link.active i { visibility: hidden; } /* ไอคอนเดิมซ่อน — วงกลมถือไอคอนของแท็บแทน */
.nav-label {
  position: absolute; bottom: 8px; left: 50%;
  transform: translateX(-50%) translateY(8px); opacity: 0;
  font-size: .62rem; font-weight: 800; letter-spacing: .02em;
  color: var(--nav-c1, var(--accent)); white-space: nowrap; pointer-events: none;
  transition: opacity .28s var(--ease), transform .34s var(--ease);
}
.bottom-nav-link.active .nav-label { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ไอคอนเด้งทีละตัว (stagger) ตอนสลับแท็บ */
.app-bottom-nav.hop .bottom-nav-link i { animation: navHop .5s var(--ease) both; animation-delay: calc(var(--i) * .045s); }
@keyframes navHop { 0% { transform: none; } 40% { transform: translateY(-6px) scale(1.16); } 100% { transform: none; } }

/* 🔔 ป้ายแจ้งเตือนบนแท็บ (เช่น งานค้างวันนี้) */
.nav-badge {
  position: absolute; top: 2px; right: calc(50% - 26px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px;
  background: linear-gradient(135deg, #FF4D4F, #FF8A3D);
  color: #fff; font-size: .58rem; font-weight: 800; line-height: 1;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
  box-shadow: 0 2px 6px rgba(255, 77, 79, .45);
  z-index: 6; pointer-events: none;
}
.nav-badge[hidden], .nav-badge:empty { display: none; }
.nav-badge.pop { animation: badgePop .45s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes badgePop {
  0% { transform: scale(0) rotate(-18deg); }
  60% { transform: scale(1.28) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
/* วงกลมย่อเล็ก + รอยเว้าลดเมื่อแท็บ active มี badge */
.app-bottom-nav.has-badge .nav-slider { scale: .84; }
.app-bottom-nav.has-badge::before { scale: .92; }

/* ➕ ปุ่มเพิ่ม (FAB) — ฝังในแถบขวาสุด */
.fab-wrap.nav-add { position: relative; flex: none; width: 56px; display: grid; place-items: center; z-index: 3; }
.fab-wrap.nav-add .fab-main {
  width: 46px; height: 46px; border-radius: 15px; font-size: 1.05rem;
  box-shadow: 0 10px 20px -6px color-mix(in srgb, var(--accent) 65%, transparent);
}
.fab-main {
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  display: grid; place-items: center;
  transition: transform .32s var(--ease), box-shadow .3s;
}
.fab-main:hover { filter: brightness(1.06); }
.fab-main.open { transform: rotate(135deg); }
.fab-wrap.nav-add .fab-menu {
  position: absolute; bottom: calc(100% + 14px); right: 0;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
  opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none; visibility: hidden;
  transition: opacity .24s var(--ease), transform .28s var(--ease), visibility 0s linear .28s;
}
.fab-wrap.open .fab-menu { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition: opacity .24s var(--ease), transform .28s var(--ease), visibility 0s; }
.fab-menu .fab-btn {
  display: inline-flex; align-items: center; gap: 9px; min-height: 46px;
  font-size: .88rem; font-weight: 800; color: #fff; border: none; border-radius: 15px; cursor: pointer;
  padding: 10px 16px; box-shadow: var(--shadow-md);
  transition: transform .2s var(--ease);
  animation: fabIn .35s var(--ease) both;
}
.fab-menu .fab-btn:nth-child(1) { animation-delay: .03s; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.fab-menu .fab-btn:nth-child(2) { animation-delay: .09s; background: linear-gradient(135deg, var(--c-study), #B388FF); }
.fab-menu .fab-btn:hover { transform: translateY(-2px); }
@keyframes fabIn { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }

/* ═══════════ SHEETS / MODALS ═══════════ */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 80; display: flex; align-items: flex-end;
  background: rgba(18, 18, 30, .5); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; visibility: hidden;
  transition: opacity .3s ease, visibility 0s linear .3s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; visibility: visible; transition: opacity .3s ease, visibility 0s; }
.sheet {
  width: 100%; max-width: 430px; margin: 0 auto; background: var(--bg-soft);
  border-radius: 26px 26px 0 0; padding: 6px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 92%; overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .42s var(--ease);
}
.sheet-backdrop.open .sheet { transform: translateY(0); }
.sheet-handle { width: 44px; height: 5px; border-radius: 99px; background: var(--border); margin: 8px auto 16px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { font-size: 1.16rem; font-weight: 800; letter-spacing: -.01em; }
.sheet-close { width: 40px; height: 40px; border-radius: 13px; border: 1.5px solid var(--border); background: var(--card); color: var(--muted); cursor: pointer; display: grid; place-items: center; transition: transform .2s var(--ease), color .2s; }
.sheet-close:hover { color: var(--text); transform: rotate(90deg); }

/* ═══════════ VISUAL QA CHECKLIST ═══════════ */
.qa-progress {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  background: var(--card); border: 1.5px solid var(--border-soft); border-radius: 14px; padding: 12px 14px;
}
.qa-progress .qa-pct { font-size: 1.05rem; font-weight: 800; color: var(--accent); flex: none; }
.qa-progress .qa-bar {
  flex: 1; height: 9px; border-radius: 99px; background: var(--border-soft); overflow: hidden;
}
.qa-progress .qa-bar i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--c-study)); transition: width .5s var(--ease); }
.qa-progress .qa-label { flex: none; font-size: .72rem; font-weight: 700; color: var(--muted); }
.qa-group { margin-bottom: 14px; }
.qa-group h3 { font-size: .8rem; font-weight: 800; color: var(--muted); margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.qa-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  background: var(--card); border: 1.5px solid var(--border-soft); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 7px; cursor: pointer;
  transition: border-color .2s, background .2s, transform .15s var(--ease);
}
.qa-item:hover { border-color: var(--border); transform: translateY(-1px); }
.qa-item .qa-check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 7px;
  border: 2px solid var(--border); display: grid; place-items: center; color: #fff;
  transition: all .2s var(--ease);
}
.qa-item.done { border-color: color-mix(in srgb, var(--success) 45%, transparent); background: color-mix(in srgb, var(--success) 7%, var(--card)); }
.qa-item.done .qa-check { background: var(--success); border-color: var(--success); transform: scale(1.05); }
.qa-item.done .qa-check i { animation: qaPop .3s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes qaPop { 0% { transform: scale(0) rotate(-20deg); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.qa-item .qa-txt { flex: 1; min-width: 0; font-size: .84rem; font-weight: 600; line-height: 1.45; }
.qa-item.done .qa-txt { color: var(--muted); text-decoration: line-through; }
.qa-reset { width: 100%; margin-top: 4px; }
.qa-foot { text-align: center; font-size: .72rem; color: var(--muted); margin-top: 10px; line-height: 1.6; }

.f-group { margin-bottom: 16px; }
.f-label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 7px; }
.f-label .req { color: var(--danger); }
.f-field {
  width: 100%; font-size: 1rem; font-weight: 500; color: var(--text);
  background: var(--card); border: 1.5px solid var(--border); border-radius: 14px;
  padding: 13px 15px; transition: border-color .2s, box-shadow .25s; resize: vertical;
}
.f-field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.f-field::placeholder { color: var(--muted); opacity: .7; }
textarea.f-field { min-height: 88px; line-height: 1.55; }
.f-error { display: none; font-size: .76rem; font-weight: 600; color: var(--danger); margin-top: 6px; }
.f-group.invalid .f-field { border-color: var(--danger); animation: shake .4s var(--ease); }
.f-group.invalid .f-error { display: block; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 55% { transform: translateX(5px); } 80% { transform: translateX(-3px); } }

.pick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-btn {
  display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 700;
  color: var(--muted); background: var(--card); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 10px 13px; cursor: pointer; min-height: 42px;
  transition: all .2s var(--ease);
}
.pick-btn:active { transform: scale(.94); }
.pick-btn.active { background: color-mix(in srgb, var(--pc, var(--accent)) 15%, var(--card)); border-color: var(--pc, var(--accent)); color: var(--pc, var(--accent)); }
.pick-btn .cat-dot { width: 10px; height: 10px; }
.pick-btn.active .cat-dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--pc, var(--accent)) 25%, transparent); }

.sheet-footer { display: flex; gap: 10px; margin-top: 20px; }
.sheet-footer .t-btn { flex: 1; }

/* Task detail */
.detail-title { font-size: 1.2rem; font-weight: 800; line-height: 1.4; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.meta-chip { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; font-weight: 700; color: var(--muted); background: var(--card); border: 1.5px solid var(--border); border-radius: 99px; padding: 5px 11px; }
.meta-chip.cat { color: var(--cc, var(--accent)); border-color: color-mix(in srgb, var(--cc, var(--accent)) 40%, transparent); background: color-mix(in srgb, var(--cc, var(--accent)) 10%, var(--card)); }
.detail-note { font-size: .92rem; color: var(--text); margin-top: 16px; white-space: pre-line; background: var(--card); border-radius: 14px; padding: 14px 16px; border: 1.5px solid var(--border-soft); line-height: 1.6; }
.sub-title { font-size: .78rem; font-weight: 800; color: var(--muted); margin: 18px 2px 9px; }
.sub-item { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--border-soft); border-radius: 13px; padding: 11px 13px; margin-bottom: 8px; font-size: .88rem; font-weight: 500; cursor: pointer; transition: all .2s var(--ease); animation: taskIn .4s var(--ease) both; animation-delay: var(--d, 0s); }
.sub-item:focus-visible { outline: 2px solid var(--c-study); outline-offset: 2px; }
.sub-item:hover { border-color: var(--border); }
.sub-item.done { opacity: .6; }
.sub-item.done .sub-txt { text-decoration: line-through; color: var(--muted); }
.sub-check { width: 22px; height: 22px; border-radius: 8px; flex: none; border: 2px solid var(--border); background: var(--card); color: transparent; display: grid; place-items: center; padding: 0; cursor: pointer; transition: all .22s var(--ease); }
.sub-check svg { width: 11px; height: 11px; }
.sub-item.done .sub-check { background: var(--c-study); border-color: transparent; color: #fff; }
.sub-add { display: flex; gap: 8px; margin-top: 4px; }
.sub-add input { flex: 1; font-size: .88rem; font-weight: 500; color: var(--text); background: var(--card); border: 1.5px dashed var(--border); border-radius: 13px; padding: 11px 13px; }
.sub-add input:focus { outline: none; border-color: var(--c-study); }
.sub-add button { width: 46px; min-height: 46px; border-radius: 13px; border: none; background: var(--c-study); color: #fff; font-size: 1rem; cursor: pointer; transition: transform .2s var(--ease); }
.sub-add button:active { transform: scale(.92); }

/* Note detail */
.note-view-title { font-size: 1.35rem; font-weight: 800; line-height: 1.4; padding-right: 30px; }
.note-view-body { font-size: .95rem; line-height: 1.75; white-space: pre-line; margin-top: 16px; color: var(--text); }
.note-view-date { font-size: .74rem; color: var(--muted); margin-top: 16px; }
.edit-note-area { width: 100%; min-height: 210px; font-size: .95rem; line-height: 1.7; color: var(--text); background: var(--card); border: 1.5px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-top: 16px; resize: vertical; }
.edit-note-area:focus { outline: none; border-color: var(--c-study); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-study) 14%, transparent); }

/* ═══════════ TOAST / CONFETTI ═══════════ */
.toast {
  position: absolute; left: 50%; bottom: 106px; z-index: 95;
  transform: translate(-50%, 24px); display: flex; align-items: center; gap: 9px;
  background: var(--text); color: var(--bg); font-size: .85rem; font-weight: 700;
  border-radius: 99px; padding: 12px 18px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .3s ease, transform .35s var(--ease);
  max-width: 88%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast i { color: var(--accent); }
[data-theme="dark"] .toast i { color: var(--warning); }

.confetti-layer { position: absolute; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute; width: 8px; height: 8px; border-radius: 2px;
  animation: confettiFly 1.15s cubic-bezier(.2, .7, .4, 1) forwards;
}
@keyframes confettiFly {
  from { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
  to { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(.6); }
}

/* ═══════════ ONBOARDING (3 จอแนะนำ) ═══════════ */
.onboarding {
  position: absolute; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden; /* ⚠️ จุดตัดจอแนวนอนของสไลด์ต้องอยู่ที่ layer นี้ (ห้ามใส่ที่ .ob-track) */
  padding: 14px 22px calc(26px + env(safe-area-inset-bottom));
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: scale(.985);
  transition: opacity .45s var(--ease), transform .45s var(--ease), visibility 0s linear .45s;
}
.onboarding.open { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity .4s var(--ease), transform .4s var(--ease), visibility 0s; }
.onboarding.leaving { opacity: 0; transform: scale(1.06); }
.ob-skip {
  position: absolute; top: 10px; right: 14px; z-index: 2;
  background: none; border: none; color: var(--muted);
  font-size: .88rem; font-weight: 700; cursor: pointer;
  padding: 10px 14px; border-radius: 12px; transition: color .2s, background .2s;
}
.ob-skip:hover { color: var(--text); background: var(--border-soft); }
.ob-track {
  flex: 1; display: flex; align-items: stretch;
  /* ❌ ไม่ใส่ overflow:hidden ที่นี่ — track ต้องเลื่อนได้อิสระ ขอบเขตตัดอยู่ที่ .onboarding */
  margin-top: 22px; will-change: transform;
  transition: transform .55s var(--ease);
}
.ob-slide {
  flex: 0 0 100%; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 0 6px;
}
.ob-art { position: relative; width: 236px; height: 236px; display: grid; place-items: center; margin-bottom: 20px; }
.ob-halo {
  position: absolute; inset: -34px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--obc, var(--accent)) 20%, transparent), transparent 66%);
  animation: obPulse 4s ease-in-out infinite;
}
@keyframes obPulse { 0%, 100% { transform: scale(1); opacity: .75; } 50% { transform: scale(1.09); opacity: 1; } }
.ob-ico {
  position: relative; width: 96px; height: 96px; border-radius: 30px;
  display: grid; place-items: center; font-size: 2.3rem; color: #fff;
  background: linear-gradient(135deg, var(--obc, var(--accent)), color-mix(in srgb, var(--obc, var(--accent)) 55%, #fff));
  box-shadow: 0 26px 52px -18px color-mix(in srgb, var(--obc, var(--accent)) 70%, transparent);
}
.ob-float {
  position: absolute; display: inline-flex; align-items: center; gap: 7px;
  background: var(--card); border: 1.5px solid var(--border-soft); border-radius: 14px;
  padding: 8px 12px; font-size: .76rem; font-weight: 700; color: var(--text);
  box-shadow: var(--shadow-md); white-space: nowrap;
  animation: obFloat 3.4s ease-in-out infinite;
}
.ob-float i { color: var(--obc, var(--accent)); font-size: .8rem; }
@keyframes obFloat { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-9px) rotate(-3deg); } }
.ob-f1 { top: 6%; left: 0%; animation-delay: .15s; }
.ob-f2 { bottom: 12%; right: -2%; animation-delay: .85s; }
.ob-f3 { top: 18%; right: 0%; animation-delay: 1.5s; }
.ob-line-row { display: flex; align-items: center; gap: 7px; }
.ob-check { width: 13px; height: 13px; border-radius: 4px; border: 1.6px solid var(--obc, var(--accent)); flex: none; }
.ob-line { height: 5px; border-radius: 99px; background: var(--border); }
.ob-mini-note { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.ob-mini-note .ob-bar { width: 24px; height: 4px; border-radius: 99px; }
.ob-mini-bars { display: flex; align-items: flex-end; gap: 4px; height: 34px; }
.ob-mini-bars i {
  width: 8px; border-radius: 4px 4px 2px 2px; transform-origin: bottom;
  background: linear-gradient(180deg, var(--obc, var(--accent)), color-mix(in srgb, var(--obc, var(--accent)) 55%, #fff));
  animation: obGrow 2.6s ease-in-out infinite;
}
.ob-mini-bars i:nth-child(2) { animation-delay: .3s; }
.ob-mini-bars i:nth-child(3) { animation-delay: .6s; }
.ob-mini-bars i:nth-child(4) { animation-delay: .9s; }
@keyframes obGrow { 0%, 100% { transform: scaleY(.55); } 50% { transform: scaleY(1); } }
.ob-tag {
  font-size: .74rem; font-weight: 800; letter-spacing: .05em;
  color: var(--obc, var(--accent));
  background: color-mix(in srgb, var(--obc, var(--accent)) 12%, var(--card));
  border: 1px solid color-mix(in srgb, var(--obc, var(--accent)) 22%, transparent);
  padding: 6px 15px; border-radius: 99px;
}
.ob-slide h2 { font-size: 1.38rem; font-weight: 800; letter-spacing: -.02em; margin-top: 16px; }
.ob-slide p { font-size: .92rem; color: var(--muted); max-width: 300px; margin-top: 8px; line-height: 1.7; }
.ob-slide.enter .ob-art { animation: obRise .6s var(--ease) both; }
.ob-slide.enter .ob-tag { animation: obRise .5s var(--ease) .1s both; }
.ob-slide.enter h2 { animation: obRise .5s var(--ease) .16s both; }
.ob-slide.enter p { animation: obRise .5s var(--ease) .24s both; }
@keyframes obRise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.ob-dots { display: flex; justify-content: center; gap: 9px; margin: 4px 0 20px; }
.ob-dot {
  width: 9px; height: 9px; border-radius: 99px; border: none; cursor: pointer; padding: 0;
  background: var(--border); transition: width .32s var(--ease), background .3s, opacity .2s;
  position: relative;
}
.ob-dot::after { content: ""; position: absolute; inset: -9px; }
.ob-dot.active { width: 28px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
/* ═══════════ แนบรูปถ่าย (เพิ่ม/แก้ไขงาน-โน้ต) ═══════════ */
.photo-add {
  width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--card); border: 2px dashed var(--border); border-radius: 14px;
  color: var(--muted); font-size: .9rem; font-weight: 700; cursor: pointer;
  transition: border-color .22s var(--ease), color .22s, background .22s, transform .18s var(--ease);
}
.photo-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.photo-add:active { transform: scale(.98); }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 11px; }
.photo-thumb {
  position: relative; width: 68px; height: 68px; border-radius: 13px; overflow: hidden;
  border: 1.5px solid var(--border-soft); animation: taskIn .35s var(--ease) both; animation-delay: var(--d, 0s);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
  position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 2.5px solid var(--bg-soft); cursor: pointer;
  font-size: .62rem; display: grid; place-items: center; padding: 0;
  transition: transform .2s var(--ease);
}
.photo-remove:hover { transform: scale(1.15); }
.photo-hint { font-size: .72rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; margin-top: 14px; scrollbar-width: none; }
.photo-strip::-webkit-scrollbar { display: none; }
.photo-strip img {
  width: 150px; height: 112px; object-fit: cover; border-radius: 13px; flex: none;
  border: 1.5px solid var(--border-soft); box-shadow: var(--shadow-sm);
}
.t-task-thumb { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex: none; margin-right: 20px; border: 1px solid var(--border-soft); }
.t-note-img { width: 100%; height: 72px; object-fit: cover; border-radius: 10px; margin-bottom: 3px; }

/* ═══════════ กลุ่มงานเสร็จแล้ว — ปุ่มยุบ/ขยาย ═══════════ */
.done-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
  margin: 18px 2px 9px;
}
.done-toggle .done-chev { margin-left: auto; color: var(--muted); font-size: .74rem; transition: transform .35s var(--ease); }
.done-toggle.collapsed .done-chev { transform: rotate(-90deg); }
.done-list { overflow: hidden; transition: max-height .45s var(--ease); }

/* ═══════════ LIGHTBOX — ดูรูปเต็มจอ ═══════════ */
.lightbox {
  position: absolute; inset: 0; z-index: 120;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 10, 20, .88); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .3s ease, visibility 0s linear .3s;
}
.lightbox.open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .3s ease, visibility 0s; }
.lb-close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.05rem;
  display: grid; place-items: center; transition: background .2s, transform .25s var(--ease);
}
.lb-close:hover { background: rgba(255, 255, 255, .3); transform: rotate(90deg); }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff; font-size: 1rem;
  display: grid; place-items: center; transition: background .2s, transform .2s var(--ease);
}
.lb-nav:hover { background: rgba(255, 255, 255, .26); transform: translateY(-50%) scale(1.08); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-stage { width: 100%; height: 100%; display: grid; place-items: center; padding: 62px 16px 58px; }
.lb-stage img {
  max-width: 100%; max-height: 100%; border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .65);
}
.lb-stage img.lb-pop { animation: lbIn .35s var(--ease) both; }
@keyframes lbIn { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
.lb-count {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: rgba(255, 255, 255, .16); color: #fff; font-size: .8rem; font-weight: 700;
  padding: 6px 15px; border-radius: 99px; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* ═══════════ ฟิลด์เวลาในฟอร์มงาน (เพิ่มตาม blueprint ข้อ 4 — "กำหนด (ชิป + เวลา)") ═══════════ */
.time-field-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.time-field-row .f-label { margin-bottom: 0; flex: none; }
.time-field-row input[type="time"].f-field { flex: 1; max-width: 168px; padding: 10px 14px; }

/* ═══════════ REDUCED MOTION ═══════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .view.active.anim { animation: none; }
}
