/* ==========================================================================
   silspm — base design system  (classic · accessible · light on battery)
   ========================================================================== */
:root {
  --primary: #16324F; --primary-2: #1F4E79; --primary-deep: #0E2438; --on-primary: #fff;
  --accent: #E25B2A; --accent-2: #F4A261; --accent-ink: #7A2E12;
  --crimson: #8c1c2b;
  --bg: #F6F7F9; --bg-2: #EEF1F5; --surface: #fff; --surface-2: #F4F6F9;
  --ink: #1A2332; --ink-2: #516074; --ink-3: #6B7589;
  --line: #E2E6EE; --line-2: #EEF1F6;
  --btn: var(--primary); --btn-ink: #fff;
  --link: #1F4E79;
  --ok: #2b7a4f; --ok-bg: #e3f3ea; --warn: #8a5a00; --warn-bg: #fdf0d2; --danger: #b3261e; --danger-bg: #fbe5e3; --info: #1F4E79; --info-bg: #e6f0fa;
  --gold: #d4a017; --silver: #9aa3b2; --bronze: #b87333;
  --radius: 12px; --radius-s: 8px;
  --shadow: 0 1px 2px rgba(22, 50, 79, .06), 0 8px 24px rgba(22, 50, 79, .08);
  --shadow-l: 0 2px 4px rgba(22, 50, 79, .06), 0 18px 40px rgba(22, 50, 79, .14);
  --serif: 'Noto Serif Thai', 'Prompt', 'Leelawadee UI', serif;
  --sans: 'Prompt', 'Sarabun', 'Leelawadee UI', Tahoma, sans-serif;
  --tabbar-h: 62px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1824; --bg-2: #13202E; --surface: #172636; --surface-2: #1C2E42;
  --ink: #E8EEF5; --ink-2: #B7C2D2; --ink-3: #8E9AAD;
  --line: #2A3C52; --line-2: #223246;
  --btn: #2F6FA3; --btn-ink: #fff; --link: #8EBFEE;
  --ok: #5fc08a; --ok-bg: #16352a; --warn: #f0c36a; --warn-bg: #3a2f12; --danger: #ff8f86; --danger-bg: #3d1d1b; --info: #8EBFEE; --info-bg: #173044;
  --accent-ink: #F6C9A4;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .3);
  --shadow-l: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1824; --bg-2: #13202E; --surface: #172636; --surface-2: #1C2E42;
    --ink: #E8EEF5; --ink-2: #B7C2D2; --ink-3: #8E9AAD;
    --line: #2A3C52; --line-2: #223246;
    --btn: #2F6FA3; --btn-ink: #fff; --link: #8EBFEE;
    --ok: #5fc08a; --ok-bg: #16352a; --warn: #f0c36a; --warn-bg: #3a2f12; --danger: #ff8f86; --danger-bg: #3d1d1b; --info: #8EBFEE; --info-bg: #173044;
    --accent-ink: #F6C9A4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .3);
    --shadow-l: 0 2px 4px rgba(0, 0, 0, .4), 0 18px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 17px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.35; margin: 0 0 .5em; color: var(--ink); font-weight: 700; }
h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); } h2 { font-size: clamp(1.3rem, 3.2vw, 1.7rem); } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--link); text-underline-offset: 2px; }
img, svg { max-width: 100%; }
img { height: auto; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-2); color: #000; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #000; padding: 8px 14px; border-radius: 8px; z-index: 999; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

.ic { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; flex: none; }
.ic-lg { width: 1.6em; height: 1.6em; } .ic-xl { width: 2.2em; height: 2.2em; }

/* ---------- layout helpers ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.stack > * + * { margin-top: 1rem; } .stack-s > * + * { margin-top: .5rem; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-nw { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; } .end { justify-content: flex-end; } .center { text-align: center; }
.grow { flex: 1 1 0; min-width: 0; } .nowrap { white-space: nowrap; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 900px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } .g2-keep { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.muted { color: var(--ink-3); } .small { font-size: .88rem; } .xs { font-size: .78rem; } .mono { font-family: ui-monospace, Consolas, monospace; }
.right { text-align: right; } .bold { font-weight: 700; } .serif { font-family: var(--serif); }
.mt0 { margin-top: 0 !important; } .mb0 { margin-bottom: 0 !important; } .mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.hide-sm { } .show-sm { display: none !important; }
@media (max-width: 720px) { .hide-sm { display: none !important; } .show-sm { display: initial !important; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- ornament divider ---------- */
.orn { display: flex; align-items: center; gap: 12px; color: var(--accent); margin: 14px 0; }
.orn::before, .orn::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); }
.orn i { width: 9px; height: 9px; background: currentColor; transform: rotate(45deg); box-shadow: -14px 0 0 -3px currentColor, 14px 0 0 -3px currentColor; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 18px;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer; border-radius: 10px; border: 2px solid transparent;
  background: var(--btn); color: var(--btn-ink); transition: transform .12s ease, box-shadow .12s ease, background-color .12s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-gold { background: linear-gradient(180deg, #E8783A, #C2410C); color: #fff; border-color: #9A3412; }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--accent); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-2); box-shadow: none; }
.btn-danger { background: var(--danger); color: #fff; } .btn-ok { background: var(--ok); color: #fff; }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: .9rem; border-radius: 8px; } .btn-lg { min-height: 52px; padding: 10px 26px; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }
.btn-icon { width: 44px; padding: 0; } .btn-icon.btn-sm { width: 36px; }
.inline-form { display: inline; margin: 0; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-family: var(--serif); }
.card-body { padding: 16px 18px; }
.card-foot { padding: 10px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-link { display: block; color: inherit; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, border-color .15s; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-l); border-color: var(--accent); }

/* ---------- chips / medals ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .82rem; font-weight: 600; background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip-green { background: var(--ok-bg); color: var(--ok); border-color: transparent; } .chip-amber { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip-red { background: var(--danger-bg); color: var(--danger); border-color: transparent; } .chip-blue { background: var(--info-bg); color: var(--info); border-color: transparent; }
.chip-gray { background: var(--bg-2); color: var(--ink-3); } .chip-gold { background: #f7e7a8; color: #5c4700; border-color: transparent; }
.medal { display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px 2px 8px; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; background: var(--bg-2); color: var(--ink-2); }
.medal i { width: 12px; height: 12px; border-radius: 50%; background: #bbb; box-shadow: inset 0 -2px 2px rgba(0, 0, 0, .25), inset 0 2px 2px rgba(255, 255, 255, .6); }
.medal-gold { background: #fbf0c4; color: #6b5200; } .medal-gold i { background: radial-gradient(circle at 35% 30%, #fff3b0, #d4a017 70%); }
.medal-silver { background: #eceff4; color: #4a5468; } .medal-silver i { background: radial-gradient(circle at 35% 30%, #fff, #9aa3b2 70%); }
.medal-bronze { background: #f6e3d2; color: #7a4310; } .medal-bronze i { background: radial-gradient(circle at 35% 30%, #ffd9b5, #b87333 70%); }
.medal-participant { background: var(--bg-2); color: var(--ink-3); } .medal-participant i { background: var(--line); }
:root[data-theme="dark"] .medal-gold { background: #4a3d0d; color: #f3d77a; } :root[data-theme="dark"] .medal-silver { background: #2b3347; color: #cdd5e5; } :root[data-theme="dark"] .medal-bronze { background: #4a2e18; color: #f0c294; }

/* ---------- alerts / flash ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-s); border: 1px solid transparent; margin-bottom: 14px; }
.alert-info { background: var(--info-bg); color: var(--info); } .alert-ok, .alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-warn, .alert-warning { background: var(--warn-bg); color: var(--warn); } .alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert .ic { margin-top: .25em; }
.empty { text-align: center; padding: 38px 16px; color: var(--ink-3); }
.empty .big { font-size: 2.6rem; display: block; margin-bottom: 6px; opacity: .85; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; min-width: 0; }
.field > label, .lbl { font-weight: 600; font-size: .92rem; color: var(--ink-2); }
.req::after { content: ' *'; color: var(--danger); }
.hint { font-size: .82rem; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; font: inherit; color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: #C5CEDA; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(226, 91, 42, .28); }
.input[type="color"] { padding: 2px; height: 44px; min-width: 60px; }
.input[type="file"] { padding: 8px; }
.input[type="range"] { padding: 0; min-height: 28px; accent-color: var(--accent); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236f7890' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.field-err .input, .field-err .select, .field-err .textarea { border-color: var(--danger); } .field-err .hint { color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 14px; }
.form-grid > .field { grid-column: span 12; } .form-grid > .c6 { grid-column: span 6; } .form-grid > .c4 { grid-column: span 4; } .form-grid > .c3 { grid-column: span 3; } .form-grid > .c8 { grid-column: span 8; }
@media (max-width: 720px) { .form-grid > .c6, .form-grid > .c4, .form-grid > .c3, .form-grid > .c8 { grid-column: span 12; } }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 46px; height: 26px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); } .switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--accent); outline-offset: 2px; }
.searchbox { position: relative; } .searchbox .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; } .searchbox .input { padding-left: 38px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { min-width: 180px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .95rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table th { position: sticky; top: 0; background: var(--surface-2); font-weight: 700; color: var(--ink-2); font-size: .85rem; white-space: nowrap; border-bottom: 2px solid var(--line); z-index: 1; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; } .table .ctr { text-align: center; }
.table .acts { white-space: nowrap; text-align: right; }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
@media (max-width: 640px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .table-stack td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table-stack td::before { content: attr(data-label); font-weight: 600; color: var(--ink-3); text-align: left; flex: none; }
  .table-stack td[data-label=""]::before, .table-stack td:not([data-label])::before { display: none; }
  .table-stack td.acts { justify-content: flex-end; }
  /* เซลล์ที่มีเนื้อหาหลายส่วน (ชื่อ + สังกัด + ป้ายสถานะ ฯลฯ): ใส่ class="rich" ให้เนื้อหาไหลต่อกันเป็นก้อนเดียว ไม่ถูกกระจายเป็นคอลัมน์ */
  .table-stack td.rich { display: block; text-align: left; }
  .table-stack td.rich:not([data-label=""])::before { display: block; font-size: .8rem; margin-bottom: 2px; }
  /* แบบสั้น: ป้ายอยู่หน้าเนื้อหาบรรทัดเดียวกัน (เช่น "สมาชิก  3 นร. · 1 ครู") */
  .table-stack td.rich-in { display: block; text-align: left; }
  .table-stack td.rich-in:not([data-label=""])::before { display: inline; margin-right: 10px; }
}
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 18px 0; }
.pager a, .pager span { min-width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 600; }
.pager a:hover { border-color: var(--accent); } .pager .cur { background: var(--primary); border-color: var(--primary); color: #fff; } .pager .gap { border: 0; background: none; }

/* ---------- tabs / pills ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; margin-bottom: 14px; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 600; text-decoration: none; cursor: pointer; font: inherit; font-weight: 600; min-height: 40px; }
.tab:hover { border-color: var(--accent); } .tab.is-active, .tab[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
:root[data-theme="dark"] .tab.is-active { background: var(--btn); border-color: var(--btn); }

/* ---------- dialog / toast ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; max-width: min(560px, calc(100vw - 24px)); width: 100%; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-l); }
dialog::backdrop { background: rgba(10, 16, 34, .6); }
dialog[open] { animation: dlg .18s ease-out; }
@keyframes dlg { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* กล่องยืนยัน — แทน window.confirm */
dialog.ask {
  width: min(420px, calc(100vw - 28px));
  max-width: 420px;
  border-radius: 22px;
  overflow: visible;
  text-align: center;
  background:
    radial-gradient(130% 70% at 50% -20%, rgba(226, 91, 42, .22), transparent 58%),
    var(--surface);
  box-shadow: 0 28px 70px rgba(14, 36, 56, .38), 0 0 0 1px rgba(226, 91, 42, .35);
}
dialog.ask::backdrop { background: rgba(14, 36, 56, .58); backdrop-filter: blur(7px); }
dialog.ask[open] { animation: ask-in .32s cubic-bezier(.16, 1, .3, 1); }
@keyframes ask-in { from { opacity: 0; transform: translateY(18px) scale(.94); } to { opacity: 1; transform: none; } }
.ask-ribbon { height: 6px; border-radius: 22px 22px 0 0; background: linear-gradient(90deg, var(--primary), var(--accent) 55%, var(--accent-2)); }
.ask-body { padding: 22px 26px 8px; }
.ask-seal {
  width: 78px; height: 78px; margin: 4px auto 14px; border-radius: 50%;
  display: grid; place-items: center; position: relative; color: #fff;
  background: radial-gradient(circle at 32% 28%, #F8C9A4, #E25B2A 46%, #C2410C 78%);
  box-shadow: 0 10px 24px rgba(194, 65, 12, .38), inset 0 0 0 3px rgba(255, 255, 255, .45);
}
.ask-seal .ic { width: 34px; height: 34px; stroke-width: 2.25; }
.ask-seal::before, .ask-seal::after {
  content: ''; position: absolute; border-radius: 50%; pointer-events: none;
}
.ask-seal::before { inset: -8px; border: 1.5px dashed rgba(226, 91, 42, .75); animation: ask-spin 16s linear infinite; }
.ask-seal::after { inset: -16px; border: 1px solid rgba(226, 91, 42, .28); }
@keyframes ask-spin { to { transform: rotate(360deg); } }
.ask-tone-ok .ask-seal { color: #fff; background: radial-gradient(circle at 32% 28%, #b7ebc9, #3d9a68 48%, #1f6b43); box-shadow: 0 10px 24px rgba(31, 107, 67, .32), inset 0 0 0 3px rgba(255, 255, 255, .4); }
.ask-tone-ok .ask-seal::before { border-color: rgba(43, 122, 79, .55); }
.ask-tone-ok .ask-seal::after { border-color: rgba(43, 122, 79, .22); }
.ask-tone-gold .ask-seal { color: #fff; }
.ask-tone-warn .ask-seal { color: #3a2500; background: radial-gradient(circle at 32% 28%, #ffe7b0, #e0a23a 50%, #b47800); box-shadow: 0 10px 24px rgba(180, 120, 0, .32), inset 0 0 0 3px rgba(255, 255, 255, .5); }
.ask-tone-warn .ask-seal::before { border-color: rgba(180, 120, 0, .6); }
.ask-tone-warn .ask-seal::after { border-color: rgba(180, 120, 0, .22); }
.ask-tone-danger .ask-seal { color: #fff; background: radial-gradient(circle at 32% 28%, #ffc7c2, #d6453d 48%, #8c1c2b); box-shadow: 0 10px 24px rgba(156, 32, 24, .34), inset 0 0 0 3px rgba(255, 255, 255, .35); }
.ask-tone-danger .ask-seal::before { border-color: rgba(179, 38, 30, .55); }
.ask-tone-danger .ask-seal::after { border-color: rgba(179, 38, 30, .2); }
.ask-kicker { margin: 0 0 4px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: none; color: var(--accent-ink); }
.ask-title { margin: 0; font-size: 1.38rem; line-height: 1.4; text-wrap: balance; }
.ask-note { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); font-size: .95rem; line-height: 1.5; border: 1px solid var(--line); }
.ask-actions { display: flex; gap: 10px; padding: 18px 26px 8px; }
.ask-actions .btn { flex: 1; min-height: 48px; border-radius: 12px; font-size: 1.02rem; }
.ask-yes.ask-tone-ok { background: linear-gradient(180deg, #49a874, #21724a); color: #fff; border-color: #18603c; box-shadow: 0 8px 18px rgba(31, 107, 67, .28); }
.ask-yes.ask-tone-gold { background: linear-gradient(180deg, #E8783A, #C2410C); color: #fff; border-color: #9A3412; box-shadow: 0 8px 18px rgba(194, 65, 12, .32); }
.ask-yes.ask-tone-warn { background: linear-gradient(180deg, #f0be62, #c4840a); color: #2a2100; border-color: #a06c08; }
.ask-yes.ask-tone-danger { background: linear-gradient(180deg, #e15a52, #a32018); color: #fff; border-color: #8c1c2b; box-shadow: 0 8px 18px rgba(156, 32, 24, .28); }
.ask-hint { margin: 0; padding: 0 26px 18px; color: var(--ink-3); font-size: .8rem; }
@media (max-width: 480px) { .ask-actions { flex-direction: column-reverse; } }
@media print { dialog.ask { display: none !important; } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.dlg-body { padding: 18px; max-height: 70vh; overflow: auto; } .dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
#toasts { position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; padding: 12px 16px; border-radius: 12px; background: var(--primary); color: #fff; box-shadow: var(--shadow-l); animation: toast-in .25s ease-out; display: flex; gap: 10px; align-items: center; }
.toast-ok { background: #1f6b43; } .toast-err { background: #9c2018; } .toast-out { opacity: 0; transform: translateY(10px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (min-width: 861px) { #toasts { bottom: 24px; } }

/* ---------- avatar / misc ---------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; overflow: hidden; font-family: var(--serif); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.5rem; }
.progress { height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; } .progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: .8em; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
.badge-n { display: inline-flex; min-width: 22px; height: 22px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 99px; background: var(--crimson); color: #fff; font-size: .75rem; font-weight: 700; }
details.card > summary { cursor: pointer; padding: 12px 18px; font-weight: 700; font-family: var(--serif); list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.card > summary::-webkit-details-marker { display: none; } details.card > summary::after { content: '▾'; transition: transform .15s; } details[open].card > summary::after { transform: rotate(180deg); }

/* ---------- eco mode & reduced motion: ปิดแอนิเมชันที่ไม่จำเป็น ---------- */
html[data-eco="1"] *, html[data-eco="1"] *::before, html[data-eco="1"] *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; scroll-behavior: auto !important; }
html[data-eco="1"] .fx { display: none !important; }
html[data-eco="1"] .btn:hover, html[data-eco="1"] .card-link:hover { transform: none; }
@media (prefers-reduced-motion: reduce) { html:not([data-eco="0"]) *, html:not([data-eco="0"]) *::before, html:not([data-eco="0"]) *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; scroll-behavior: auto !important; } }
.is-paused, .is-paused * { animation-play-state: paused !important; }
