/* ===== Design tokens ===== */
:root {
  --bg: #f3faf6;
  --bg-glow-1: rgba(52, 211, 153, 0.18);
  --bg-glow-2: rgba(56, 189, 248, 0.14);
  --surface: #ffffff;
  --surface-2: #f1f7f4;
  --glass: rgba(255, 255, 255, 0.78);
  --glass-solid: rgba(255, 255, 255, 0.94);
  --text: #0f2419;
  --muted: #5b6f65;
  --border: #e2ece7;

  --brand: #10b981;
  --brand-strong: #059669;
  --brand-deep: #047857;
  --brand-soft: #d1fae5;
  --on-brand: #ffffff;
  /* สีที่ใช้กับตัวอักษรและปุ่ม ต้องมีคอนทราสต์ ≥ 4.5 (tests/test_a11y.py ตรวจให้) */
  --link: #047857;
  --btn-bg: #047857;
  --btn-shadow: #064e3b;
  --hero-1: #047857;
  --hero-2: #0f766e;
  --hero-3: #0e7490;

  --again: #f43f5e;
  --again-deep: #be123c;
  --hard: #f59e0b;
  --hard-deep: #b45309;
  --good: #10b981;
  --good-deep: #047857;
  --again-bg: #be123c;
  --again-shadow: #881337;
  --hard-bg: #b45309;
  --hard-shadow: #78350f;
  --good-bg: #047857;
  --good-shadow: #064e3b;

  --seed: #e5e7eb;
  --sprout: #a7f3d0;
  --growing: #34d399;
  --tree: #047857;

  --warning-bg: #fef3c7;
  --shadow-sm: 0 1px 2px rgba(15, 36, 25, 0.06), 0 2px 8px rgba(15, 36, 25, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 36, 25, 0.08), 0 2px 6px rgba(15, 36, 25, 0.05);
  --shadow-lg: 0 20px 48px rgba(4, 120, 87, 0.18);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 28px;

  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Sukhumvit Set", "Noto Sans Thai", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07110d;
    --bg-glow-1: rgba(16, 185, 129, 0.16);
    --bg-glow-2: rgba(14, 165, 233, 0.1);
    --surface: #101c17;
    --surface-2: #16251f;
    --glass: rgba(16, 28, 23, 0.78);
    --glass-solid: rgba(16, 28, 23, 0.95);
    --text: #e8f5ee;
    --muted: #92a89c;
    --border: #213129;
    --brand-soft: #0f3a2b;
    --link: #6ee7b7;
    --hero-1: #047857;
    --hero-2: #0f766e;
    --hero-3: #155e75;
    --seed: #2a3a33;
    --sprout: #1f6f52;
    --growing: #22b07d;
    --tree: #6ee7b7;
    --warning-bg: #3b2f12;
    --shadow-sm: none;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
  }
}

/* ธีมมืดที่ผู้ใช้เลือกเอง (ตั้งค่า → ธีม) */
:root[data-theme="dark"] {
  --bg: #07110d;
  --bg-glow-1: rgba(16, 185, 129, 0.16);
  --bg-glow-2: rgba(14, 165, 233, 0.1);
  --surface: #101c17;
  --surface-2: #16251f;
  --glass: rgba(16, 28, 23, 0.78);
  --glass-solid: rgba(16, 28, 23, 0.95);
  --text: #e8f5ee;
  --muted: #92a89c;
  --border: #213129;
  --brand-soft: #0f3a2b;
  --link: #6ee7b7;
  --hero-1: #047857;
  --hero-2: #0f766e;
  --hero-3: #155e75;
  --seed: #2a3a33;
  --sprout: #1f6f52;
  --growing: #22b07d;
  --tree: #6ee7b7;
  --warning-bg: #3b2f12;
  --shadow-sm: none;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.45);
}

/* ===== Base ===== */
* {
  box-sizing: border-box;
}

/* ให้ hidden ชนะ display ที่กำหนดในคลาสอื่น */
[hidden] {
  display: none !important;
}

html {
  -webkit-tap-highlight-color: transparent;
  /* ปิดการแตะสองครั้งแล้วซูมของ iOS (ปุ่มดูคำแปลกับปุ่มให้คะแนนอยู่ตำแหน่งเดียวกัน แตะเร็ว ๆ จอจะซูม) ยังซูมด้วยสองนิ้วได้ */
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  background:
    radial-gradient(60vw 50vh at 0% 0%, var(--bg-glow-1), transparent 70%),
    radial-gradient(60vw 50vh at 100% 10%, var(--bg-glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  /* การ์ดที่ปัดออกนอกจอต้องไม่ทำให้หน้าเลื่อนซ้ายขวาได้ */
  overflow-x: clip;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 0.5rem 0 1rem;
}

/* หัวข้อหน้า + ปุ่มไอคอนชิดขวาในบรรทัดเดียวกัน */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0.5rem 0 1rem;
}

.page-head h1 {
  margin: 0;
}

.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
}

.center-text > .icon-btn {
  margin-inline: auto;
}

h2 {
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 1.75rem 0 0.5rem;
}

a {
  color: var(--link);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.center {
  text-align: center;
  padding-top: 12vh;
}

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

/* ===== แถบด้านบน + เมนู ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  /* ห้ามใส่ backdrop-filter ที่นี่: จะทำให้เมนูด้านล่าง (position: fixed) ไปยึดกับแถบนี้แทนหน้าจอ */
  background: var(--glass-solid);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.version {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--link);
  background: var(--brand-soft);
  padding: 1px 8px;
  border-radius: 999px;
}

.brand {
  margin-right: auto;
}

.tabbar {
  display: flex;
  gap: 4px;
}

/* ปุ่ม ⓘ เกี่ยวกับแอป อยู่ชิดขวาของแถบบน (ใช้ไม่บ่อยเลยไม่ต้องอยู่ในเมนูหลัก) */
.about-link {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  margin-left: 8px;
  border-radius: 50%;
  color: var(--muted);
  text-decoration: none;
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}

.about-link[aria-current="page"] {
  color: var(--link);
  background: var(--brand-soft);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .about-link[aria-current="page"] {
    color: var(--tree);
  }
}

:root[data-theme="dark"] .about-link[aria-current="page"] {
  color: var(--tree);
}

.tabbar a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.tabbar a[aria-current="page"] {
  color: var(--link);
  background: var(--brand-soft);
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tabbar a[aria-current="page"] {
    color: var(--tree);
  }
}

/* ธีมมืดที่ผู้ใช้เลือกเอง (ตั้งค่า → ธีม) */
:root[data-theme="dark"] .tabbar a[aria-current="page"] {
  color: var(--tree);
}

/* มือถือและแท็บเล็ตที่ใช้สัมผัส (iPad): เมนูลอยอยู่ด้านล่างจอ หน้าตาเหมือน iPhone */
@media (max-width: 767px), (pointer: coarse) and (max-width: 1400px) {
  :root:not([data-menu="top"]) .tabbar {
    position: fixed;
    left: max(12px, calc(50% - 360px));
    right: max(12px, calc(50% - 360px));
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 3;
    justify-content: space-around;
    padding: 6px;
    background: var(--glass);
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
  }

  :root:not([data-menu="top"]) .tabbar a {
    flex: 1;
    flex-direction: column;
    gap: 0;
    padding: 6px 4px;
    border-radius: 18px;
    font-size: 0.72rem;
  }

  :root:not([data-menu="top"]) .tab-icon {
    font-size: 1.3rem;
    line-height: 1.3;
  }

  :root:not([data-menu="top"]) main {
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
  }

  :root:not([data-menu="top"]) .toast {
    bottom: calc(96px + env(safe-area-inset-bottom));
  }
}

/* iPad: คงหน้าตาแบบ iPhone แต่ขยายตัวหนังสือและเนื้อหาให้เต็มตาขึ้น */
@media (min-width: 768px) and (pointer: coarse) and (max-width: 1400px) {
  html {
    font-size: 112.5%;
  }

  main {
    max-width: 720px;
  }
}

/* ===== ปุ่ม ===== */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 18px;
  min-height: 48px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 3px 0 var(--border);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s;
}

button:active,
.button:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--border);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.primary {
  color: var(--on-brand);
  background: var(--btn-bg);
  border-color: transparent;
  box-shadow: 0 4px 0 var(--btn-shadow);
}

.primary:active {
  box-shadow: 0 0 0 var(--btn-shadow);
  transform: translateY(4px);
}

.danger {
  color: var(--again);
  border-color: color-mix(in srgb, var(--again) 40%, transparent);
  box-shadow: 0 3px 0 color-mix(in srgb, var(--again) 30%, transparent);
}

.wide {
  display: flex;
  width: 100%;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

select {
  font: inherit;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

/* ===== กล่องเนื้อหา ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.panel > :first-child {
  margin-top: 0;
}

.panel > :last-child {
  margin-bottom: 0;
}

.panel label[for] {
  font-weight: 600;
  margin-right: 8px;
}

/* แถว "หัวข้อ + ตัวเลือก": หัวข้อชิดซ้าย ตัวเลือกชิดขวาและกว้างเท่ากันทุกแถว */
.panel p:has(> label[for] + select) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel p:has(> label[for] + select) label[for] {
  margin-right: 0;
  flex: 1 1 auto;
}

.panel p:has(> label[for] + select) select {
  flex: 0 0 10.5em;
  width: 10.5em;
  max-width: 55%;
}

.warning {
  background: var(--warning-bg);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.tip {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.credit {
  font-style: italic;
  background: var(--surface-2);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 10px 12px;
}

/* ===== หน้าหลัก ===== */
.hero {
  position: relative;
  overflow: hidden;
  color: #ffffff;
  background: linear-gradient(135deg, var(--hero-1) 0%, var(--hero-2) 55%, var(--hero-3) 100%);
  border-radius: var(--radius-lg);
  padding: 22px 20px 20px;
  box-shadow: var(--shadow-lg);
}

.hero::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -70px;
  bottom: -110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.hero-greeting {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.9;
}

.hero-title {
  margin: 2px 0 0;
  font-size: 1.45rem;
  font-weight: 800;
}

.ring {
  --p: 0;
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#ffffff calc(var(--p) * 1%), rgba(255, 255, 255, 0.25) 0);
}

.ring-inner {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  text-align: center;
  background: color-mix(in srgb, var(--hero-2) 80%, #000000);
  line-height: 1.1;
}

.ring-inner strong {
  font-size: 1.35rem;
}

.ring-inner span {
  font-size: 0.65rem;
  opacity: 0.9;
}

.hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0 16px;
}

.stat {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 16px;
  padding: 10px 14px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.stat strong {
  display: block;
  font-size: 1.9rem;
  line-height: 1.1;
  font-weight: 800;
}

.stat span {
  font-size: 0.85rem;
  opacity: 0.92;
}

.hero-cta {
  display: flex;
  width: 100%;
  color: var(--brand-deep);
  background: #ffffff;
  border: none;
  font-size: 1.05rem;
  font-weight: 800;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.hero-cta:active {
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.15);
}

.hero-done {
  margin: 0;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  padding: 12px 14px;
  text-align: center;
  font-weight: 600;
}

.cal-wrap {
  display: grid;
  gap: 4px;
}

.cal-months {
  display: grid;
  grid-template-columns: repeat(var(--weeks), 1fr);
  font-size: 0.65rem;
  color: var(--muted);
}

.cal-months span {
  overflow: visible;
  white-space: nowrap;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(var(--weeks), 1fr);
  grid-template-rows: repeat(7, auto);
  grid-auto-flow: column;
  gap: 3px;
}

.cal-cell {
  display: inline-block;
  aspect-ratio: 1;
  min-width: 8px;
  background: var(--surface-2);
  border-radius: 3px;
}

.cal-grid .cal-cell.future {
  background: transparent;
}

.cal-cell.l1 {
  background: color-mix(in srgb, var(--tree) 28%, var(--surface-2));
}

.cal-cell.l2 {
  background: color-mix(in srgb, var(--tree) 52%, var(--surface-2));
}

.cal-cell.l3 {
  background: color-mix(in srgb, var(--tree) 76%, var(--surface-2));
}

.cal-cell.l4 {
  background: var(--tree);
}

.cal-cell.rest {
  background: color-mix(in srgb, #38bdf8 35%, var(--surface-2));
}

.cal-cell.today {
  outline: 2px solid var(--link);
  outline-offset: 1px;
}

.cal-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}

.cal-legend .cal-cell {
  width: 12px;
  min-width: 12px;
}

.weekly {
  margin-top: 14px;
  padding: 14px 16px;
  background: var(--brand-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.weekly h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.weekly-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 4px;
}

.wotd {
  position: relative;
  margin-top: 14px;
}

.wotd-main {
  display: grid;
  justify-content: stretch;
  justify-items: start;
  gap: 2px;
  width: 100%;
  padding: 14px 56px 14px 16px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.wotd-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--link);
}

.wotd-word {
  font-size: 1.5rem;
  line-height: 1.3;
}

.wotd-meaning {
  font-weight: 600;
}

.wotd-speak {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.2rem;
  border-radius: 999px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 1.75rem;
}

.section-head h2 {
  margin: 0;
}

.legend {
  margin: 4px 0 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

.levels {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.level {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.level-rest {
  grid-column: 1 / -1;
}

/* แปลงที่ปลูกแล้ว: เป็นแปลงเล็ก ๆ เรียง 4 แปลงต่อแถว เลขแปลงอยู่ในป้ายด้านบน */
.level:not(.level-rest) {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 2px;
  padding: 10px 6px;
  text-align: center;
}

.level:not(.level-rest) .level-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.level:not(.level-rest) .level-sub {
  font-size: 0.72rem;
  white-space: nowrap;
}

.level:not(.level-rest) .level-pct {
  font-size: 1.05rem;
}

.level:not(.level-rest) .stagebar {
  width: 100%;
  height: 8px;
  margin-top: 4px;
}

.level-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand), var(--hero-3));
}

.level-info p {
  margin: 0;
}

.level-title {
  font-weight: 700;
}

.level-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.level-stages {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.level-pct {
  font-weight: 800;
  color: var(--link);
}

.stagebar {
  grid-column: 1 / -1;
  display: flex;
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--seed);
}

.seg {
  height: 100%;
}

.seg-sprout {
  background: var(--sprout);
}

.seg-growing {
  background: var(--growing);
}

.seg-tree {
  background: var(--tree);
}

.level.locked {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}

.level.locked .level-badge {
  background: var(--surface-2);
  font-size: 1.1rem;
}

.level.locked .level-title {
  color: var(--muted);
}

/* ===== หน้าท่องศัพท์ (เต็มจอ) ===== */
body.studying .topbar {
  display: none;
}

body.studying main {
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

#view-study:not([hidden]) {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.study-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1rem;
  color: var(--muted);
  text-decoration: none;
}

.progress {
  flex: 1;
  height: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--brand), var(--hero-3));
  border-radius: 999px;
  transition: width 0.35s ease-out;
}

#study-progress {
  font-weight: 600;
  white-space: nowrap;
}

.goal {
  margin: 14px 0 12px;
}

.goal-text {
  margin: 0 0 6px;
  font-weight: 700;
}

.goal-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.goal-bar > div {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: #fde68a;
  transition: width 0.35s ease-out;
}

.notice {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--text);
  font-size: 0.95rem;
}

.combo {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warning-bg);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.combo.pop {
  animation: combo-pop 0.35s ease-out;
}

@keyframes combo-pop {
  0% {
    transform: scale(0.7);
  }
  60% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}

.flashcard {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 32px;
  box-shadow: var(--shadow-md);
  padding: 28px 22px;
  min-height: 320px;
  cursor: pointer;
  text-align: center;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  overflow-wrap: anywhere;
  overflow: hidden;
}

.flashcard::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--hero-3));
}

.flashcard.dragging {
  transition: none;
}

.flashcard.fly-left,
.flashcard.fly-right,
.flashcard.snap-back {
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
}

.flashcard.fly-left {
  transform: translateX(-120vw) rotate(-20deg) !important;
  opacity: 0;
}

.flashcard.fly-right {
  transform: translateX(120vw) rotate(20deg) !important;
  opacity: 0;
}

.flashcard[data-swipe="good"] {
  border-color: var(--good);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 25%, transparent), var(--shadow-md);
}

.flashcard[data-swipe="again"] {
  border-color: var(--again);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--again) 25%, transparent), var(--shadow-md);
}

.stamp {
  position: absolute;
  top: 24px;
  padding: 6px 14px;
  border: 3px solid;
  border-radius: 12px;
  font-weight: 800;
  background: var(--surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

.stamp-again {
  right: 20px;
  color: var(--again);
  transform: rotate(12deg);
}

.stamp-good {
  left: 20px;
  color: var(--good);
  transform: rotate(-12deg);
}

.flashcard[data-swipe="again"] .stamp-again,
.flashcard[data-swipe="good"] .stamp-good {
  opacity: 1;
}

#card-level {
  display: inline-block;
  align-self: center;
  margin: 0 0 4px;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
}

.word {
  font-size: clamp(2.6rem, 13vw, 4.25rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 12px 0 14px;
}

/* อีโมจิช่วยจำ: ภาพเดียวด้านหลังการ์ด ใช้อีโมจิของเครื่อง จึงไม่ต้องมีไฟล์รูป */
.card-emoji {
  display: block;
  margin: 0 0 8px;
  font-size: 2.6rem;
  line-height: 1.1;
  text-align: center;
}

.speak {
  align-self: center;
  width: 52px;
  height: 52px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 1.25rem;
  background: var(--brand-soft);
  border: none;
  box-shadow: none;
}

.speak.small {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  vertical-align: middle;
  margin-left: 4px;
}

#card-hint {
  margin-top: 16px;
}

.card-back {
  text-align: left;
  border-top: 2px dashed var(--border);
  margin-top: 20px;
  padding-top: 18px;
}

.senses {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  font-size: 1.2rem;
  font-weight: 600;
}

.senses li + li {
  margin-top: 8px;
}

.pos {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 10px;
  margin-right: 8px;
  vertical-align: middle;
  color: #4338ca;
  background: #e0e7ff;
}

.pos-n {
  color: #0369a1;
  background: #e0f2fe;
}

.pos-v {
  color: #047857;
  background: #d1fae5;
}

.pos-adj {
  color: #a21caf;
  background: #fae8ff;
}

.pos-adv {
  color: #b45309;
  background: #fef3c7;
}

.pos-pron,
.pos-det {
  color: #be123c;
  background: #ffe4e6;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pos {
    background: rgba(255, 255, 255, 0.08);
    color: #c7d2fe;
  }

  :root:not([data-theme="light"]) .pos-n {
    color: #7dd3fc;
  }

  :root:not([data-theme="light"]) .pos-v {
    color: #6ee7b7;
  }

  :root:not([data-theme="light"]) .pos-adj {
    color: #f0abfc;
  }

  :root:not([data-theme="light"]) .pos-adv {
    color: #fcd34d;
  }

  :root:not([data-theme="light"]) .pos-pron,
  :root:not([data-theme="light"]) .pos-det {
    color: #fda4af;
  }
}

/* ธีมมืดที่ผู้ใช้เลือกเอง (ตั้งค่า → ธีม) */
:root[data-theme="dark"] .pos {
  background: rgba(255, 255, 255, 0.08);
  color: #c7d2fe;
}

:root[data-theme="dark"] .pos-n {
  color: #7dd3fc;
}

:root[data-theme="dark"] .pos-v {
  color: #6ee7b7;
}

:root[data-theme="dark"] .pos-adj {
  color: #f0abfc;
}

:root[data-theme="dark"] .pos-adv {
  color: #fcd34d;
}

:root[data-theme="dark"] .pos-pron,
:root[data-theme="dark"] .pos-det {
  color: #fda4af;
}

.forms {
  color: var(--muted);
}

.example {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 12px 14px;
}

.example p {
  margin: 0.2rem 0;
}

.note {
  margin-bottom: 0;
  background: color-mix(in srgb, var(--hard) 12%, transparent);
  border-radius: 12px;
  padding: 10px 12px;
}

.swipe-hint {
  text-align: center;
  margin: 12px 0;
}

.study-actions {
  min-height: 56px;
  /* หลังพลิกการ์ดหน้าอาจยาวกว่าจอ ปุ่มจึงลอยติดขอบล่างให้กดได้เสมอ */
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 10px 0 calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 28%);
}

.grades {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.grade {
  flex-direction: column;
  gap: 0;
  color: #ffffff;
  border: none;
  padding: 10px 6px;
  font-size: 0.9rem;
  line-height: 1.2;
}

.grade-emoji {
  font-size: 1.5rem;
  line-height: 1.2;
}

.grade.again {
  background: var(--again-bg);
  box-shadow: 0 4px 0 var(--again-shadow);
}

.grade.hard {
  background: var(--hard-bg);
  box-shadow: 0 4px 0 var(--hard-shadow);
}

.grade.good {
  background: var(--good-bg);
  box-shadow: 0 4px 0 var(--good-shadow);
}

.grade:active {
  transform: translateY(4px);
  box-shadow: none;
}

kbd {
  display: none;
  margin-top: 2px;
  font: inherit;
  font-size: 0.7rem;
  opacity: 0.8;
}

@media (hover: hover) and (pointer: fine) {
  kbd {
    display: inline;
  }
}

/* ===== ทวนแบบผสม (เลือกคำแปล / เติมคำ) ===== */
.word.sentence {
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.45;
}

.blank {
  display: inline-block;
  min-width: 3.2em;
  padding: 0 6px;
  border-bottom: 3px solid var(--brand);
  text-align: center;
  color: var(--muted);
}

.blank.filled {
  color: var(--link);
  border-bottom-color: var(--good-deep);
}

.quiz-options {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  text-align: left;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 var(--border);
}

.quiz-option kbd {
  margin: 0;
  opacity: 0.6;
}

.quiz-option:disabled {
  opacity: 1;
  cursor: default;
}

.quiz-option.correct {
  background: var(--brand-soft);
  border-color: var(--good-deep);
  box-shadow: 0 3px 0 var(--good-deep);
}

.quiz-option.wrong {
  background: var(--warning-bg);
  border-color: var(--again-deep);
  box-shadow: 0 3px 0 var(--again-deep);
}

.quiz-type {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.quiz-type .row {
  margin: 0;
}

.quiz-type .row button {
  flex: 1;
}

#quiz-input {
  width: 100%;
  min-height: 56px;
  padding: 10px 14px;
  font: inherit;
  font-size: 1.25rem; /* ไม่ต่ำกว่า 16px ไม่งั้น iPhone ซูมหน้าตอนแตะช่องพิมพ์ */
  font-weight: 600;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
}

#quiz-input:disabled {
  opacity: 0.7;
}

.placement-levels {
  list-style: none;
  margin: 16px 0;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
}

.placement-levels li {
  display: grid;
  grid-template-columns: 4.5rem 1fr 3rem;
  align-items: center;
  gap: 10px;
}

.placement-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--seed);
  overflow: hidden;
}

.placement-bar > span {
  display: block;
  height: 100%;
  background: var(--tree);
}

.placement-pct {
  text-align: right;
  font-weight: 700;
  color: var(--link);
}

.dictation-blanks {
  margin: 8px 0 16px;
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  font-weight: 700;
  word-break: break-all;
}

.dictation-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.dictation-form input {
  flex: 1;
  min-width: 0;
  font-size: 1.2rem;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.listen-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  font-size: 2.6rem;
  line-height: 1;
  padding: 0;
}

.quiz-feedback {
  margin: 0 0 12px;
  text-align: center;
  font-weight: 700;
  color: var(--text);
}

.quiz-feedback.is-correct {
  color: var(--link);
}

/* ===== จบรอบ ===== */
.done-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px 24px;
  box-shadow: var(--shadow-md);
}

/* ปุ่มในการ์ดจบรอบของเกม (เรียงลงมา เว้นช่องไฟให้ไม่ติดกัน) */
.done-card > button.wide,
.done-card > a.button.wide {
  margin-top: 12px;
}

.done-card > p.muted + button.wide,
.done-card > p.muted + a.button.wide {
  margin-top: 24px;
}

.done-growth {
  list-style: none;
  margin: 12px 0 4px;
  padding: 0;
  display: grid;
  gap: 6px;
  text-align: left;
}

.done-growth li {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-weight: 600;
}

/* ===== คอนเฟตตี ===== */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 8;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -16px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall 2.4s ease-in forwards;
}

.confetti-piece.c0 {
  background: #10b981;
}

.confetti-piece.c1 {
  background: #f59e0b;
}

.confetti-piece.c2 {
  background: #f43f5e;
}

.confetti-piece.c3 {
  background: #38bdf8;
}

.confetti-piece.c4 {
  background: #a78bfa;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx, 0), 105vh) rotate(var(--spin, 540deg));
  }
}

.big-emoji {
  font-size: 4.5rem;
  line-height: 1.1;
  margin: 0;
}

/* ===== แจ้งเตือน ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 5;
  max-width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  border-radius: 24px;
  padding: 10px 20px;
  font-weight: 600;
  text-align: center;
  text-wrap: balance; /* ขึ้นสองบรรทัดก็ยาวพอ ๆ กัน */
  box-shadow: var(--shadow-md);
  pointer-events: none; /* แตะผ่านป้ายไปกดปุ่มข้างใต้ได้ */
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4, 20, 14, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-box {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px 24px;
  text-align: center;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow-lg);
}

.modal-box h2,
.modal-box p {
  margin: 0;
}

/* ===== แอนิเมชัน ===== */
@media (prefers-reduced-motion: no-preference) {
  #view-home:not([hidden]) .hero,
  #view-home:not([hidden]) .level,
  .done-card,
  .modal-box {
    animation: rise 0.35s ease-out both;
  }

  #view-home:not([hidden]) .level:nth-child(2) {
    animation-delay: 0.04s;
  }

  #view-home:not([hidden]) .level:nth-child(3) {
    animation-delay: 0.08s;
  }

  #view-home:not([hidden]) .level:nth-child(n + 4) {
    animation-delay: 0.12s;
  }

  .card-back:not([hidden]) {
    animation: reveal 0.25s ease-out;
  }

  .celebrate {
    animation: bounce 0.8s ease-out;
  }

  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
  }

  @keyframes reveal {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
  }

  @keyframes bounce {
    0% {
      transform: scale(0.3) rotate(-15deg);
    }
    60% {
      transform: scale(1.15) rotate(8deg);
    }
    100% {
      transform: scale(1) rotate(0);
    }
  }
}

/* ===== รู้อยู่แล้ว / เลือกด่าน ===== */
.know {
  display: flex;
  margin: 10px auto 0;
  min-height: 44px;
  padding: 8px 16px;
  font-size: 0.95rem;
  color: var(--muted);
  background: transparent;
  border: none;
  box-shadow: none;
}

.know:active {
  transform: none;
  background: var(--surface-2);
}

.level.clickable {
  cursor: pointer;
}

.level.clickable:active {
  transform: scale(0.99);
}

.level.clickable:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

.level-hint {
  margin: -4px 0 10px;
}

/* ===== สวนของฉัน ===== */
.hero-streak {
  margin: 4px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.95;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 6px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-card strong {
  font-size: 1.9rem;
  line-height: 1.1;
  color: var(--link);
}

.stat-card span {
  font-size: 0.8rem;
  color: var(--muted);
}

.stage-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.stage-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 2.5rem;
  align-items: center;
  gap: 10px;
}

.stage-bar {
  height: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.stage-bar .seg {
  display: block;
  height: 100%;
}

.stage-bar .seg-seed {
  background: var(--muted);
  opacity: 0.45;
}

.stage-count {
  text-align: right;
}

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  height: 150px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.week-col {
  display: grid;
  grid-template-rows: 1rem 1fr 1.2rem;
  align-items: end;
  justify-items: center;
  min-width: 0;
}

.week-bar {
  width: 100%;
  max-width: 28px;
  background: linear-gradient(180deg, var(--brand), var(--brand-strong));
  border-radius: 8px 8px 4px 4px;
}

.week-count,
.week-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.week-col.today .week-label {
  color: var(--link);
  font-weight: 700;
}

/* ===== แจ้งคำแปลผิด / มีอะไรใหม่ ===== */
.report {
  justify-self: center;
  display: inline-block;
  margin-top: 6px;
  padding: 8px 12px;
  color: var(--muted);
  text-decoration: none;
  border-radius: 999px;
}

.report:hover,
.report:focus-visible {
  background: var(--surface-2);
}

.whatsnew-body {
  max-height: 46vh;
  overflow-y: auto;
  text-align: left;
  padding-right: 4px;
}

.cl-entry {
  margin: 0 0 18px;
}

.cl-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.cl-version {
  color: var(--link);
  font-weight: 800;
}

.cl-date {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.cl-intro {
  margin: 0 0 6px;
  color: var(--muted);
}

.cl-section {
  display: inline-block;
  margin: 8px 0 2px;
  padding: 1px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--link);
  background: var(--brand-soft);
  border-radius: 999px;
}

.cl-section.cl-data {
  color: var(--text);
  background: var(--surface-2);
}

.cl-items {
  margin: 2px 0 0;
  padding-left: 1.2rem;
}

.cl-items li {
  margin: 4px 0;
}

.cl-items code {
  font-size: 0.85em;
  padding: 1px 5px;
  background: var(--surface-2);
  border-radius: 6px;
}

/* ===== การเข้าถึง ===== */
html[data-text-size="large"] {
  font-size: 118%;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 600;
}

.check input {
  width: 22px;
  height: 22px;
  accent-color: var(--btn-bg);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}

/* ===== แปลงสวน ===== */
.water-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.water-note {
  flex: 1;
  font-weight: 600;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

#garden-search {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 8px 14px;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
}

.plots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* แปลงในหน้าสวน: แผ่นเล็ก ๆ เรียง 4 แปลงต่อแถว แตะแล้วไปหน้าของแปลงนั้น */
.plot {
  display: block;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.plot:active {
  transform: scale(0.97);
}

.plot-head {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  text-align: center;
}

.plot .level-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.plot .level-sub {
  font-size: 0.72rem;
}

.plot .level-stages {
  font-size: 0.62rem;
}

.plot .stagebar {
  width: 100%;
  height: 8px;
  margin-top: 4px;
}

.plot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
  padding: 0 12px 12px;
}

/* หน้าของแต่ละแปลง */
.plot-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0.5rem 0 0.25rem;
}

.plot-nav h1 {
  flex: 1;
  margin: 0;
  min-width: 0;
}

.plot-nav .icon-btn,
.plot-arrows .icon-btn {
  width: 44px;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 1.4rem;
}

.plot-arrows {
  display: flex;
  gap: 6px;
}

.plot-page .stagebar {
  margin: 0 0 12px;
}

/* มือถือเลื่อนแถวตัวกรองไปด้านข้างได้ แทนที่จะตกบรรทัดหลายแถว */
.plot-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.plot-filters::-webkit-scrollbar {
  display: none;
}

.plot-filter {
  flex: none;
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 999px;
  box-shadow: none;
}

.plot-filter[aria-pressed="true"] {
  color: var(--link);
  background: var(--brand-soft);
  border-color: var(--link);
  font-weight: 700;
}

.plot-page .plot-grid {
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.plot-page .plant {
  min-height: 48px;
}

.plot-page .exam-box {
  padding: 0;
}

.plant {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
  transition: opacity 0.2s, transform 0.2s;
}

.plant:active {
  transform: scale(0.92);
}

.plant.seed {
  opacity: 0.55;
}

.plant.wilted {
  filter: grayscale(0.7) saturate(0.6);
  transform: rotate(-14deg);
}

.plant.wilted::after {
  content: "💧";
  position: absolute;
  top: -4px;
  right: -2px;
  font-size: 0.75rem;
}

.plant.dim {
  opacity: 0.18;
}

.word-box {
  max-height: 90dvh;
  overflow-y: auto;
}

.word-box .senses {
  margin: 0;
  font-size: 1.1rem;
}

/* ===== โน้ตช่วยจำ / คำที่ลืมบ่อย ===== */
.mynote {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.linklike {
  display: inline-flex;
  min-height: 44px;
  padding: 8px 4px;
  color: var(--link);
  background: transparent;
  border: none;
  box-shadow: none;
  font-weight: 600;
}

.linklike:active {
  transform: none;
  background: var(--surface-2);
}

#note-text {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 1.05rem; /* ไม่ต่ำกว่า 16px ไม่งั้น iPhone ซูมหน้าตอนแตะช่องพิมพ์ */
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
}

.leech-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.leech-item {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.leech-item .muted {
  flex: 1;
  min-width: 0;
}

.leech-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

/* ===== เล่น (เกม) ===== */
.game-list {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.game-card:active {
  transform: scale(0.98);
}

.game-emoji {
  font-size: 2.4rem;
  line-height: 1;
}

.game-info {
  display: grid;
  gap: 2px;
}

.game-title {
  flex: 1;
}

.center-text {
  text-align: center;
}

.flash-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.flash-quick {
  display: flex;
  gap: 12px;
}

.flash-levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 4px 12px;
  margin-top: 8px;
}

.flash-statuses {
  display: grid;
  gap: 4px;
  margin: 8px 0;
}

.flash-play:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* ให้การ์ดสูงเกือบเต็มจอ (หัวแอป + แถบบน + เมนูล่าง) ปุ่มตอบอยู่ใต้การ์ดพอดี */
  min-height: calc(100dvh - 290px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.flash-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.flash-progress .progress {
  flex: 1;
}

.fc {
  position: relative;
  flex: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  min-height: 320px;
  padding: 44px 18px 40px;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.fc.flipped {
  align-content: start;
  padding-top: 52px;
}

.fc-meta {
  position: absolute;
  top: 14px;
  left: 16px;
}

.fc-speak {
  position: absolute;
  top: 6px;
  right: 8px;
}

.fc-tip {
  position: absolute;
  bottom: 14px;
  left: 0;
  right: 0;
}

.fc-front,
.fc-back {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
}

.fc-back {
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.fc-word {
  font-size: 3rem;
  line-height: 1.2;
}

.fc-meaning {
  font-size: 1.8rem;
  line-height: 1.35;
  font-weight: 700;
}

.fc-example {
  font-weight: 600;
}

.fc .senses {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.flash-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.flash-actions button {
  min-height: 56px;
  font-size: 1.05rem;
}

.flash-actions button:disabled {
  opacity: 0.45;
}

.match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.match-column {
  display: grid;
  grid-auto-rows: 1fr;
  align-content: start;
  gap: 10px;
}

.tile {
  min-height: 64px;
  padding: 8px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 3px 0 var(--border);
  overflow-wrap: anywhere;
}

.tile-en {
  font-size: 1.15rem;
}

.tile.picked {
  background: var(--brand-soft);
  border-color: var(--brand-strong);
}

.tile.wrong {
  background: var(--warning-bg);
  border-color: var(--again-deep);
}

.tile.matched {
  opacity: 0.55;
  background: var(--brand-soft);
  border-color: var(--good-deep);
  box-shadow: none;
}

.tile:disabled {
  color: var(--text);
}

/* ===== ทายคำปริศนา ===== */
.wordle-message {
  min-height: 1.6em;
  margin: 8px 0;
  text-align: center;
  font-weight: 600;
}

.wordle-board {
  display: grid;
  gap: 6px;
  width: min(100%, 320px);
  margin: 8px auto 14px;
}

.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.wordle-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  font-size: 1.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
}

.wordle-cell.typed {
  border-color: var(--muted);
}

.wordle-cell.correct,
.wordle-key.correct {
  color: var(--on-brand);
  background: var(--good-bg);
  border-color: var(--good-bg);
}

.wordle-cell.present,
.wordle-key.present {
  color: var(--on-brand);
  background: var(--hard-bg);
  border-color: var(--hard-bg);
}

.wordle-cell.absent,
.wordle-key.absent {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--surface-2);
}

/* ไม่ใช้สีอย่างเดียว: ถูกที่มีเครื่องหมายถูก มีแต่ผิดที่มีจุดที่มุม */
.wordle-cell.correct {
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, 0.45);
}

.wordle-cell.present {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.7);
}

.wordle-keys {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.wordle-key-row {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.wordle-key {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  box-shadow: none;
}

.wordle-key.wide-key {
  flex: 1.6;
  font-size: 0.85rem;
  text-transform: none;
}

.wordle-key:disabled {
  opacity: 0.6;
}

@media (prefers-reduced-motion: no-preference) {
  .wordle-row.shake {
    animation: wordle-shake 0.35s;
  }

  @keyframes wordle-shake {
    20%,
    60% {
      transform: translateX(-6px);
    }
    40%,
    80% {
      transform: translateX(6px);
    }
  }
}

/* ===== เรียงตัวอักษร ===== */
.scramble-meaning {
  margin: 14px 0;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.3;
}

.scramble-slots,
.scramble-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 16px;
}

.scramble-slot {
  display: grid;
  place-items: center;
  width: 44px;
  height: 52px;
  font-size: 1.6rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: 10px;
}

.scramble-slot.filled {
  background: var(--brand-soft);
  border-style: solid;
  border-color: var(--brand-strong);
}

.scramble-tile {
  width: 52px;
  height: 56px;
  padding: 0;
  font-size: 1.6rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--border);
}

.scramble-tile:disabled {
  opacity: 0.3;
  box-shadow: none;
}

.scramble-actions {
  justify-content: center;
  margin-bottom: 12px;
}

.big-marks {
  margin: 4px 0 12px;
  font-size: 1.6rem;
  letter-spacing: 0.15em;
}

@media (prefers-reduced-motion: no-preference) {
  .scramble-slots.shake {
    animation: wordle-shake 0.35s;
  }
}


/* ===== รายการที่ค้นเจอ / พับเก็บ / เหรียญ ===== */
.match-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.match-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.match-item .muted {
  flex: 1;
  min-width: 0;
}

.fold {
  margin: 12px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.fold > summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 12px 14px;
  cursor: pointer;
}

.fold > :not(summary) {
  margin-left: 14px;
  margin-right: 14px;
}

.fold-preview {
  flex: 1 1 100%;
  font-size: 1.15rem;
  letter-spacing: 0.1em;
}

.medal-list {
  list-style: none;
  margin-bottom: 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.medal {
  display: flex;
  align-items: center;
  gap: 12px;
}

.medal-text {
  display: grid;
}

.medal-emoji {
  flex: none;
  width: 2rem;
  font-size: 1.6rem;
  text-align: center;
}

.exam-prompt {
  margin: 16px 0 4px;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.3;
}

.exam-prompt .blank {
  color: var(--link);
}

.exam-box {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 0 12px 12px;
}

.done-card .fold-sub {
  margin-inline: 0;
}

.exam-missed-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 4px;
  text-align: left;
}

.fold-sub {
  margin: 12px 14px 6px;
  font-size: 0.95rem;
}

.season-note {
  margin-top: 8px;
  padding: 8px 12px;
  font-weight: 700;
  text-align: center;
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
}

.chips {
  list-style: none;
  margin-bottom: 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 6px;
}

.chip {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 4px;
  text-align: center;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.chip-emoji {
  font-size: 1.6rem;
  line-height: 1.2;
}

.chip-title {
  font-size: 0.72rem;
  line-height: 1.25;
}

.chip.locked {
  opacity: 0.55;
}

.chip.locked .chip-emoji {
  filter: grayscale(1);
}

.medal.locked {
  opacity: 0.6;
}

.medal.locked .medal-emoji {
  filter: grayscale(1);
}

/* iPad แนวนอน: ขยายเนื้อหาให้เต็มจอขึ้น รายการด่าน เกม และเหรียญเรียงสองคอลัมน์ ส่วนหน้าท่อง เกม และตั้งค่ายังอยู่กลางจอแคบ ๆ ให้อ่านง่าย */
@media (min-width: 1000px) and (pointer: coarse) and (max-width: 1400px) {
  main {
    max-width: 1040px;
  }

  .tabbar {
    left: max(12px, calc(50% - 440px));
    right: max(12px, calc(50% - 440px));
  }

  .game-list,
  .medal-list {
    grid-template-columns: 1fr 1fr;
  }

  .levels,
  .plots {
    grid-template-columns: repeat(6, 1fr);
  }

  #view-study,
  #view-done,
  #view-wordle,
  #view-scramble,
  #view-match,
  #view-settings,
  #view-about,
  #view-changelog {
    max-width: 720px;
    margin-inline: auto;
  }
}

.backup-reminder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
}

.backup-reminder-actions {
  display: flex;
  gap: 8px;
}

.snapshots {
  margin-top: 12px;
}

.snapshots summary {
  cursor: pointer;
  font-weight: 600;
}

.snapshot-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

.snapshot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

/* ===== จอคอมที่ใช้เมาส์ และ iPad แนวนอน (กว้างตั้งแต่ 960px) =====
   มือถือและ iPad แนวตั้งไม่เปลี่ยน: กล่องห่อด้านล่างเป็น display: contents จึงเหมือนไม่มีอยู่
   iPad แนวนอนยังใช้เมนูลอยด้านล่างเหมือนเดิม แต่จัดหน้าเหมือนจอคอม
   จอกว้างใช้พื้นที่ซ้ายขวาให้คุ้มขึ้น: หน้าหลัก สวน เกม ตั้งค่า แบ่งเป็นสองคอลัมน์ ส่วนหน้าท่อง เกม และข้อความยาวอยู่กลางจอแคบ ๆ ให้อ่านง่าย */
.home-side,
.home-main,
.garden-top,
.garden-plots,
.garden-rest {
  display: contents;
}

@media (min-width: 960px) and (hover: hover) and (pointer: fine), (min-width: 960px) and (orientation: landscape) and (pointer: coarse) {
  .topbar {
    padding-inline: max(16px, calc((100% - 1200px) / 2 + 32px));
  }

  /* ไม่กำหนดระยะล่าง: iPad ต้องเว้นที่ให้เมนูลอยด้านล่าง */
  main {
    max-width: 1200px;
    padding-top: 28px;
    padding-inline: 32px;
  }

  /* หน้าที่ต้องอ่านทีละอย่าง ไม่ต้องขยายเต็มจอ */
  #view-study,
  #view-done,
  #view-wordle,
  #view-scramble,
  #view-match,
  #view-listen,
  #view-dictation,
  #view-placement,
  #view-exam,
  #view-flash,
  #view-changelog,
  #view-loading,
  #view-error {
    max-width: 760px;
    margin-inline: auto;
  }

  #view-about {
    max-width: 820px;
    margin-inline: auto;
  }

  /* หน้าหลัก: ซ้ายคือสรุปวันนี้ (ติดอยู่ตอนเลื่อน) ขวาคือแปลง */
  #view-home {
    display: grid;
    grid-template-columns: minmax(340px, 400px) minmax(0, 1fr);
    gap: 0 36px;
    align-items: start;
  }

  .home-side,
  .home-main,
  .garden-top,
  .garden-plots,
  .garden-rest {
    display: block;
  }

  .home-side {
    position: sticky;
    top: 80px;
  }

  .home-main .section-head:first-child h2 {
    margin-top: 0;
  }

  .home-main > .section-head {
    margin-top: 0.5rem;
  }

  .levels,
  .plots {
    grid-template-columns: repeat(4, 1fr);
  }

  /* สวน: ซ้ายคือสถิติ ต้นไม้ ปฏิทิน ขวาคือแปลงสวน */
  #view-garden {
    display: grid;
    grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: 0 36px;
    align-items: start;
  }

  .garden-top {
    grid-column: 1;
    grid-row: 1;
  }

  .garden-rest {
    grid-column: 1;
    grid-row: 2;
  }

  .garden-plots {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .garden-plots > h2:first-child {
    margin-top: 0.5rem;
  }

  /* เกม: การ์ดเกมเรียงหลายคอลัมน์ */
  .game-list,
  .medal-list {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }

  .game-list > li {
    display: flex;
  }

  .game-list .game-card {
    flex: 1;
  }

  /* ตั้งค่า: แบ่งสองคอลัมน์ กล่องแต่ละใบไม่ถูกตัดกลาง */
  #view-settings {
    max-width: none;
    margin-inline: 0;
    column-count: 2;
    column-gap: 36px;
  }

  #view-settings h1 {
    column-span: all;
  }

  #view-settings h2 {
    break-after: avoid;
  }

  #view-settings .panel {
    break-inside: avoid;
  }
}

/* ===== เมนูอยู่ด้านบน (ตั้งค่า → หน้าตา → ตำแหน่งเมนู) =====
   จอกว้างแสดงแบบจอคอม จอแคบ (มือถือแนวตั้ง) ย่อโลโก้เหลือ 🌱 และเรียงไอคอนกับป้ายเล็ก ๆ ให้พอดีแถบเดียว */
@media (max-width: 639px) {
  :root[data-menu="top"] .brand {
    font-size: 0;
    gap: 0;
  }

  :root[data-menu="top"] .brand::before {
    content: "🌱";
    font-size: 1.4rem;
  }

  :root[data-menu="top"] .version {
    display: none;
  }

  :root[data-menu="top"] .tabbar {
    gap: 0;
  }

  :root[data-menu="top"] .tabbar a {
    flex-direction: column;
    gap: 0;
    padding: 4px 8px;
    border-radius: 14px;
    font-size: 0.65rem;
  }

  :root[data-menu="top"] .tab-icon {
    font-size: 1.15rem;
    line-height: 1.2;
  }

  :root[data-menu="top"] .about-link {
    margin-left: 0;
  }
}

/* จอที่เมนูอยู่ด้านบนอยู่แล้ว (คอมที่ใช้เมาส์) ไม่ต้องมีตัวเลือกนี้ */
@media (min-width: 768px) and (pointer: fine), (min-width: 1401px) {
  #menu-setting,
  #menu-setting-note {
    display: none;
  }
}

/* ===== หน้าต่างรายละเอียดคำ: ใช้พื้นที่ให้เต็มขึ้น ===== */
.word-head {
  display: grid;
  gap: 10px;
  align-content: start;
}

/* จัดกลางแนวตั้งแบบไม่ตัดหัวเมื่อเนื้อหายาวกว่าพื้นที่ (ตัวเว้นว่างหน้า/หลังแบ่งที่เหลือเท่า ๆ กัน และเป็น 0 เมื่อล้น) */
.word-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.word-body::before,
.word-body::after {
  content: "";
  flex: 1 0 0;
}

.word-head h2 {
  font-size: 2.2rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.word-head .big-emoji {
  font-size: 5.5rem;
}

.word-head #word-due {
  font-weight: 600;
}

.word-body {
  font-size: 1.1rem;
}

.word-box .word-body .senses {
  font-size: 1.35rem;
}

.word-example {
  font-size: 1.15rem;
}

.word-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.word-actions .primary {
  grid-column: 1 / -1;
}

/* มือถือ: แผ่นล่างสูงเกือบเต็มจอ ปุ่มอยู่ติดล่างใกล้นิ้วโป้ง */
@media (max-width: 599px) {
  #word-dialog {
    align-items: flex-end;
    padding: 0;
  }

  #word-dialog .word-box {
    max-width: none;
    min-height: 82dvh;
    max-height: 94dvh;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 16px;
    padding: 28px 22px calc(20px + env(safe-area-inset-bottom));
    border-radius: 28px 28px 0 0;
    overflow: hidden;
  }

  /* ถ้าเนื้อหายาว ให้เลื่อนเฉพาะส่วนกลาง ปุ่มด้านล่างอยู่กับที่เสมอ */
  .word-body {
    overflow-y: auto;
  }

  .word-head .big-emoji {
    font-size: 4.5rem;
  }

  .word-head h2 {
    font-size: 2rem;
  }

  .word-box .word-body .senses {
    font-size: 1.3rem;
  }

  .word-body,
  .word-example {
    font-size: 1.05rem;
  }
}

/* แท็บเล็ตแนวตั้งและจอกลาง: กล่องกว้างขึ้น ตัวหนังสือโตขึ้น */
@media (min-width: 600px) {
  #word-dialog .word-box {
    max-width: 680px;
    padding: 40px 44px 32px;
    gap: 22px;
  }

  .word-head h2 {
    font-size: 2.6rem;
  }

  .word-box .word-body .senses {
    font-size: 1.5rem;
  }

  .word-body,
  .word-example {
    font-size: 1.25rem;
  }
}

/* จอกว้าง (คอม iPad แนวนอน): สองคอลัมน์ ซ้ายคือตัวคำ ขวาคือความหมายและประโยค */
@media (min-width: 900px) {
  #word-dialog .word-box {
    max-width: 940px;
    grid-template-columns: minmax(240px, 300px) 1fr;
    column-gap: 48px;
    row-gap: 28px;
    padding: 48px 52px 40px;
  }

  .word-head {
    align-content: center;
    padding-right: 48px;
    border-right: 1px solid var(--border);
  }

  .word-body {
    text-align: left;
  }

  .word-actions {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr 2fr;
  }

  .word-actions .primary {
    grid-column: auto;
  }
}

/* ===== มุมมองรายการคำในหน้าของแปลง ===== */
.plot-view-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.select-bar {
  position: sticky;
  top: 64px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--link);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.select-bar #plot-select-count {
  flex: 1 1 auto;
  font-weight: 600;
}

.select-bar .primary {
  min-height: 44px;
  padding: 8px 16px;
}

.word-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.word-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}

.word-row:last-child {
  border-bottom: 0;
}

.word-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  cursor: pointer;
}

.word-check input {
  width: 22px;
  height: 22px;
  accent-color: var(--link);
}

.word-check.done {
  color: var(--tree);
  font-weight: 800;
  cursor: default;
}

.word-row-main {
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
  gap: 10px;
  min-height: 52px;
  padding: 8px 14px 8px 0;
  font-weight: 400;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.word-row-main strong {
  flex: none;
  font-size: 1.05rem;
}

.word-row-emoji {
  flex: none;
  min-width: 2.7em;
  font-size: 1.3rem;
  line-height: 1;
}

.word-row-meaning {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.word-row.wilted .word-row-emoji {
  filter: grayscale(0.6);
}

.word-actions #word-know {
  grid-column: 1 / -1;
}

@media (min-width: 900px) {
  .word-actions {
    grid-template-columns: 1fr 1fr 1.2fr 1fr;
  }

  .word-actions #word-know {
    grid-column: auto;
  }
}

/* ===== หน้าของแปลงบนจอกว้าง: ข้อมูลและตัวกรองอยู่ซ้าย ต้นไม้หรือรายการคำอยู่ขวา =====
   ทั้งสองมุมมองใช้เลย์เอาต์เดียวกัน สลับแล้วหน้าไม่กระโดด แถบซ้ายติดอยู่ตอนเลื่อนรายการยาว */
.plot-side,
.plot-main,
.plot-foot {
  display: contents;
}

@media (min-width: 960px) and (hover: hover) and (pointer: fine), (min-width: 960px) and (orientation: landscape) and (pointer: coarse) {
  #view-plot:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: 0 32px;
    align-items: start;
  }

  #view-plot .plot-side,
  #view-plot .plot-main,
  #view-plot .plot-foot {
    display: block;
  }

  #view-plot .plot-side {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 80px;
  }

  #view-plot .plot-foot {
    grid-column: 1;
    grid-row: 2;
  }

  #view-plot .plot-main {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  #view-plot .plot-main .plot-grid {
    margin-bottom: 0;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  }

  /* แถบด้านซ้ายติดอยู่แล้ว ไม่ต้องติดซ้อนอีกชั้น */
  #view-plot .select-bar {
    position: static;
  }

  #view-plot .plot-filters {
    flex-wrap: wrap;
    overflow: visible;
  }
}
