/* meeting_ai web UI — ธีมเดียวรองรับทั้งสว่างและมืด
   ดีไซน์ระบบสี (2026-09-16): Deep Electric Indigo เป็นสีหลัก, Vibrant Teal = สถานะ
   "กำลังฟัง/สด", เขียว = สำเร็จ, แดงนวล = อัด/ปิดไมค์, ส้มอำพัน = กำลังประมวลผล
   นิวทรัลสองสี (Charcoal / Off-White) สลับหน้าที่กันระหว่างสว่าง/มืดพอดี */

:root {
  /* บอกเบราว์เซอร์ว่าหน้านี้รองรับทั้งสองธีม คอนโทรลของ UA ที่สไตล์เองไม่ได้
     (<audio controls>, ตัวเลือกใน <select> ที่กางออกมา, แถบเลื่อน, ตัวเลือกวันที่)
     จะได้เป็นสีตามธีมด้วย — ไม่งั้นตัวเล่นเสียงเป็นแถบขาวสว่างกลางหน้าจอมืด */
  color-scheme: light dark;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #e5e5ea;
  --border: #d1d1d6;
  --text: #1c1c1e;
  --muted: #6c6c70;
  --accent: #5856d6;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --live: #64d2ff;
  --live-soft: color-mix(in srgb, var(--live) 18%, var(--surface));
  --rec: #ff453a;
  /* white-on-red ปุ่มเต็ม (.btn-rec/.fab-rec/.fab-stop) ต้องเข้มกว่า #ff453a ดิบๆ —
     คอนทราสต์ตัวหนังสือขาวบน #ff453a เหลือแค่ ~3.5:1 (ต่ำกว่า WCAG AA 4.5:1)
     ผสมดำ 20% แล้วได้ ~5:1 โดยยังเป็นสีแดงตระกูลเดียวกัน */
  --rec-strong: color-mix(in srgb, var(--rec) 80%, black);
  --ok: #32d74b;
  --warn: #ff9500;
  --radius: 10px;
  --radius-lg: 16px;
  --font-mono: "SFMono-Regular", Consolas, "Cascadia Code", "SF Mono", monospace;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --surface: #2c2c2e;
    --surface-2: #3a3a3c;
    --border: #48484a;
    --text: #f2f2f7;
    --muted: #98989d;
    /* Apple systemIndigo dark variant — สว่างกว่าตัวสว่างเล็กน้อยให้อ่านง่ายบนพื้นมืด */
    --accent: #5e5ce6;
    --accent-soft: color-mix(in srgb, var(--accent) 20%, var(--surface));
    --live: #64d2ff;
    --live-soft: color-mix(in srgb, var(--live) 20%, var(--surface));
    --rec: #ff453a;
    --rec-strong: color-mix(in srgb, var(--rec) 80%, black);
    --ok: #32d74b;
    --warn: #ff9500;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

/* คลาสของเราที่ตั้ง display (เช่น .field, .chips, .userbox) ชนะ [hidden] ของ UA stylesheet
   ทำให้ hidden=true ไม่ซ่อนจริง — ประกาศทับให้ชนะทุกกรณี */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* Sarabun/Noto Sans Thai มาก่อนเสมอ — UI นี้เป็นภาษาไทยทั้งหมด ฟอนต์ละตินอย่าง
     SF Pro/Inter ไม่มีตัวอักษรไทยจึงอยู่ท้ายแถวเป็นแค่ fallback ให้ตัวเลข/อังกฤษปนอยู่ */
  font-family: "Sarabun", "Noto Sans Thai", "SF Pro Text", "Inter", "Segoe UI",
    system-ui, -apple-system, sans-serif;
  /* body/บทถอดเสียง 15px — เว้นบรรทัด 1.65 (ไม่ใช่ 1.33 ตามสเปกตั้งต้น) เพราะข้อความไทย
     ซ้อนสระบน/สระล่าง/วรรณยุกต์ได้ถึงสามชั้น เว้นแคบไปจะดันอ่านยากที่สุดในบทถอดเสียง
     ที่ต้องกวาดสายตาไว มาตรฐาน 1.5-1.6 ถือว่าแคบสุดที่ยอมรับได้แล้ว */
  font-size: 15px;
  line-height: 1.65;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* "App title" ของดีไซน์ระบบ (24/32 ตัวหนา) เอาไว้กับชื่อแบรนด์เท่านั้น เพราะเป็นข้อความ
   ละตินล้วน ("meeting_ai") ไม่มีวรรณยุกต์ซ้อนให้เว้นบรรทัดแคบแล้วพัง — ห้ามเอาไปใช้กับ
   หัวข้อที่เป็นภาษาไทย (h2 ทั่วไป) เพราะยาวได้และตัดบรรทัดได้เสมอ */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 24px; line-height: 32px; flex: none; }
.logo { font-size: 22px; }
.stats { color: var(--muted); font-size: 13px; margin-left: auto; }
#btn-new { flex: none; white-space: nowrap; }

/* จอมือถือ: บีบ padding เอาที่คืนให้เนื้อหา และให้สถิติย่อด้วย …
   ไม่งั้น "1 การประชุม · รวม 1 นาที 30 วิ" ตัดเป็นสามบรรทัดดัน topbar สูงจนเสียที่
   แบรนด์ก็ย่อจาก 24px ลงมาเป็นสเกล "หัวข้อย่อย" (18px) ไม่งั้นแถบบนสูงเกินไปบนจอแคบ */
@media (max-width: 560px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand { font-size: 18px; line-height: 22px; }
  .stats { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .panel { padding: 16px 12px; }
  .banner { padding: 10px 12px; }
}

.banner {
  padding: 10px 20px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 0;
  align-items: start;
  min-height: calc(100vh - 57px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  min-height: calc(100vh - 57px);
  padding-bottom: 24px;
}

.search-wrap { padding: 14px; border-bottom: 1px solid var(--border); }

.search-wrap input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.panel { padding: 24px; min-width: 0; }
.pane { max-width: 860px; }

/* กันเนื้อหาโดนแถบลอยด้านล่างบัง — ตั้งจาก JS เฉพาะตอนอยู่หน้า "ประชุมใหม่" ที่การ์ดอัดสดใช้ได้ */
body.has-floatbar .panel { padding-bottom: 96px; }

.wk-group {
  padding: 12px 12px 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
}
.wk-group:first-child { padding-top: 4px; }

/* ---------- meeting list ---------- */

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

.list li {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
}

.list li:hover { background: var(--surface-2); }
.list li.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.list .t { font-weight: 600; display: block; }
.list .s { color: var(--muted); font-size: 12.5px; display: block; }
.list .snip { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; font-style: italic; }
.list .empty { color: var(--muted); cursor: default; text-align: center; padding: 24px 12px; }
.list .empty:hover { background: none; }

/* ---------- jobs ---------- */

.jobs { padding: 8px 8px 0; }

.job {
  padding: 10px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
}

.job .jt { font-weight: 600; }
/* ป้ายบนงานที่ไม่ใช่ของผู้ที่กำลังดู — เห็นได้เฉพาะแอดมินที่ดูคิวทั้งระบบ (BACKLOG #41)
   ต้องแยกออกจากงานของตัวเองด้วยตา ไม่งั้นแอดมินนั่งรองานที่ไม่ใช่ของตัวเอง */
.job .job-sys {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  vertical-align: 1px;
}
.job .js { color: var(--muted); }
.job.err { border-color: color-mix(in srgb, var(--rec) 50%, var(--border)); }
.job.err .js { color: var(--rec); }

/* สีความคืบหน้างาน = ส้มอำพัน (processing) แยกจากสีหลัก (indigo) ที่สงวนไว้กับ
   ปุ่มหลัก/สถานะ "AI กำลังทำงานให้ผู้ใช้เห็นผล" (เช่น ป้าย ✨ และตัวชี้ streaming) */
.bar { height: 5px; background: var(--border); border-radius: 999px; margin-top: 7px; overflow: hidden; }
.bar > div { height: 100%; background: var(--warn); border-radius: 999px; transition: width .35s ease; }

/* งานบอทช่วงอยู่ในห้อง: ยังไม่รู้ว่าจะนานเท่าไร แถบเป็นสัดส่วนจึงไม่มีความหมาย
   ใช้แถบวิ่งบอกว่า "กำลังทำงาน" แล้วให้ข้อความบอกเวลาที่อยู่ในห้องแทน */
.bar.rec > div {
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--warn), transparent);
  animation: bar-slide 1.4s ease-in-out infinite;
}

@keyframes bar-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

@media (prefers-reduced-motion: reduce) {
  .bar.rec > div { animation: none; width: 100%; opacity: .5; }
}

/* ---------- forms & cards ---------- */

/* h2 = หัวข้อหน้า/ชื่อการประชุม เป็นข้อความไทยที่ผู้ใช้พิมพ์เอง ยาวไม่จำกัด จึงไม่ใช้ line-height
   แคบแบบ "app title" — ปล่อยให้สืบทอด 1.65 จาก body เพื่อกันสระ/วรรณยุกต์ซ้อนพังตอนตัดบรรทัด */
h2 { font-size: 20px; margin: 0 0 18px; }
/* หัวข้อย่อย (section header) ตามดีไซน์ระบบ: 18px กึ่งหนา เว้นบรรทัด 1.3 — กว้างกว่าที่สเปกให้
   (18/22 ก็คือ 1.22) เพราะหัวข้อพวกนี้เป็นภาษาไทยและบางอันยาว ("🎙️ ไมค์เดียว — ไม่ต้องแชร์หน้าจอ") */
h3 { font-size: 18px; line-height: 1.3; font-weight: 600; margin: 0 0 6px; }

.field-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
/* min-width:0 สำคัญ — flex item ตั้งต้นเป็น min-width:auto ซึ่งยุบต่ำกว่าความกว้าง
   min-content ของลูกไม่ได้ ชื่ออุปกรณ์เสียงบน Windows ยาวมาก
   ("Microphone Array (Intel Smart Sound Technology for Digital Microphones)")
   select จะกว้างตาม option ที่ยาวที่สุดแล้วดันหน้าเว็บล้นออกไปทั้งหน้า */
.field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 260px; min-width: 0; }
.field-sm { flex: 0 1 180px; }
.field > span { font-size: 13px; color: var(--muted); }
/* ป้ายช่องบังคับ — เดิมชื่อการประชุมว่างได้แล้วระบบตั้งชื่อให้เอง ผู้ใช้จึงได้คลัง
   ที่เต็มไปด้วย "อัดสด 19/9/2569 23:46" ซึ่งค้นไม่เจอภายหลัง (BACKLOG #78) */
.req { font-weight: 600; font-size: 11px; color: var(--warn); }

.field input, .field select {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  /* ตัดชื่อยาวด้วย … แทนที่จะดันกล่องให้กว้างตามข้อความ */
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
}

/* min(300px, 100%) — ไม่ใส่ min() ช่องจะกว้าง 300px ตายตัวแม้จอแคบกว่านั้น
   แล้วดันให้เลื่อนซ้ายขวาบนจอ 320px (iPhone SE / Android เครื่องเล็ก) */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card > p { margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13.5px; }

.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
}

.drop p { margin: 0 0 8px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

.checks { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 14px; }
.checks label { display: flex; align-items: center; gap: 7px; cursor: pointer; }

/* ตัวเลือกแหล่งเสียงตอนอัด — การ์ดเรียงลงมา กดที่ไหนก็เลือกได้ */
.modes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.mode {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}

.mode:hover { background: var(--surface-2); }
/* .on ตั้งจาก JS ด้วย เผื่อเบราว์เซอร์เก่าที่ยังไม่รู้จัก :has() */
.mode.on, .mode:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode.off, .mode:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.mode input { margin-top: 3px; flex: none; }
.mode-body { display: flex; flex-direction: column; gap: 2px; }
.mode-body strong { font-size: 14px; font-weight: 600; }
.mode-body small { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.dev-wrap { margin-bottom: 0; }

.hint { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.warn { font-size: 13px; color: var(--warn); margin: 10px 0 0; }

/* ---------- buttons ---------- */

.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.btn:hover { background: var(--border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--rec); }

/* ---------- แถบควบคุมลอยด้านล่าง (floating bottom control bar) ----------
   pill เดียวลอยกลางจอเหนือขอบล่าง — โชว์ปุ่ม "เริ่มอัด" ตอนยังไม่อัด สลับเป็น
   "ปิดไมค์ชั่วคราว / หยุดอัดแล้วสรุป" ตอนอัดอยู่ ต้องใช้ได้มือเดียวบนมือถือ
   จึงลอยไว้ในโซนนิ้วโป้งเอื้อมถึง ไม่ต้องเลื่อนขึ้นไปหาปุ่มบนสุดของการ์ด */
.floatbar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 6px;
  max-width: calc(100vw - 24px);
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(16, 24, 40, .18);
}

/* ปุ่มลอยแบบ pill ตัวหนังสือ+ไอคอน — สูงอย่างน้อย 44px ตามเกณฑ์พื้นที่แตะขั้นต่ำ */
.fab-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.fab-pill:hover { filter: brightness(0.96); }
.fab-pill:active { filter: brightness(0.9); }
.fab-rec, .fab-stop { background: var(--rec-strong); color: #fff; }
/* ปิดไมค์อยู่ = สีเดียวกับปุ่มอัด/หยุด ให้รู้ทันทีว่าอยู่ในสถานะ "เตือน" */
.fab-pill.on { background: var(--rec-strong); color: #fff; }

/* จอแคบสุด (เช่น 320px) — "ปิดไมค์" + "หยุดอัดแล้วสรุป" สองปุ่มรวมกันอาจเกิน
   max-width ของแถบลอย ต้องบีบ padding/ตัวอักษรลงอีกนิดกันล้นแนวนอน */
@media (max-width: 360px) {
  .fab-pill { padding: 0 12px; font-size: 13px; min-height: 44px; }
}

/* ---------- recording ---------- */

.rec-status { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }

.dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--rec);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.rec-time { font-variant-numeric: tabular-nums; font-family: var(--font-mono); font-size: 22px; font-weight: 600; }

/* คลื่นเสียงสด (waveform) — ค่าเริ่มต้นเมื่อเบราว์เซอร์เคลื่อนไหวได้ตามปกติ
   ขับด้วย AnalyserNode ใน app.js สีทีล = "กำลังฟัง/สด" ตามระบบสี */
.wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 40px;
  margin-bottom: 4px;
}

.wave-bar {
  flex: 1 1 0;
  min-width: 2px;
  height: 8%;
  background: var(--live);
  border-radius: 2px 2px 0 0;
  transition: height .05s linear;
}

/* มิเตอร์แท่งเดียวแบบเดิม — ใช้เป็น fallback ตอน prefers-reduced-motion เท่านั้น
   (คลื่นหลายแท่งขยับทุกเฟรมนับเป็นความเคลื่อนไหวที่ควรงดให้ผู้ใช้กลุ่มนี้) */
.meter { display: none; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 4px; }
.meter-bar { height: 100%; width: 0; background: var(--live); border-radius: 999px; }

@media (prefers-reduced-motion: reduce) {
  .wave { display: none; }
  .meter { display: block; }
}

/* ---------- detail ---------- */

.detail-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.detail-head h2 { flex: 1 1 320px; margin-bottom: 6px; }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.title-edit { outline: none; border-radius: 6px; padding: 2px 4px; margin-left: -4px; }
.title-edit:focus { background: var(--surface-2); box-shadow: 0 0 0 2px var(--accent); }

.meta { margin: 0 0 16px; }

audio { width: 100%; margin-bottom: 20px; }

/* ต้อง wrap ทั้งสองชั้น — แถวปุ่ม "แปล / สรุปใหม่ด้วย AI / แก้ไข" กว้าง ~337px
   บนจอ 360-414px จึงล้นออกไปทำให้เลื่อนซ้ายขวาได้ทั้งหน้า */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; padding-top: 4px; flex-wrap: wrap;
}
.section-head h3 { margin: 0; }
.section-head > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ตัวชี้ "กำลังสตรีมข้อความ" — โผล่ข้าง h3 ตอนมีงาน summarize/translate ของการประชุมที่
   เปิดอยู่กำลังวิ่งจริง (ผูกกับ pollJobs() เดิม ไม่มี transport ใหม่) สีม่วง = "AI กำลังทำงาน" */
.ai-live {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}

.ai-live .cursor { animation: blink 1s steps(1) infinite; }
@media (prefers-reduced-motion: reduce) { .ai-live .cursor { animation: none; } }
@keyframes blink { 50% { opacity: 0; } }

.editor {
  width: 100%;
  min-height: 420px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: "Cascadia Code", Consolas, "SF Mono", monospace;
  font-size: 13.5px;
  line-height: 1.7;
  resize: vertical;
}

/* ---------- rendered markdown (การ์ดสรุปอัจฉริยะ) ---------- */

.md {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 20px 16px;
  box-shadow: var(--shadow);
}

/* ป้าย ✨ บอกว่าเนื้อหาในการ์ดนี้ AI เขียนให้ (ทั้งสรุปต้นฉบับและฉบับแปล) —
   ต่อท้าย .md h2/h3 (สร้างจาก JS วาง <span> ไว้บรรทัดแรกก่อนเรนเดอร์ markdown) */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 14px 0 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

/* หัวข้อในสรุปเป็นภาษาไทยที่ AI สร้าง ยาวไม่แน่นอนและตัดบรรทัดได้บนจอแคบ —
   เว้นบรรทัด 1.3 กันสระ/วรรณยุกต์ซ้อนพัง (เทียบกับ 15/17px เดิมที่ไม่ได้กำหนด line-height เลย) */
.md h2 { font-size: 18px; line-height: 1.3; margin: 20px 0 8px; }
.md h3 { font-size: 16px; line-height: 1.3; margin: 16px 0 6px; }
.md ul { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md p { margin: 8px 0; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.md .table-wrap { overflow-x: auto; margin: 10px 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 600; }

.notice {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  font-size: 13.5px;
}

/* ---------- ผู้พูด ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
}

.chip:hover { filter: brightness(0.96); }

/* จานสีผู้พูด — เจือกับ surface เพื่อให้อ่านออกทั้งธีมสว่างและมืด */
.spk-1 { background: color-mix(in srgb, #2563eb 20%, var(--surface)); }
.spk-2 { background: color-mix(in srgb, #059669 20%, var(--surface)); }
.spk-3 { background: color-mix(in srgb, #d97706 22%, var(--surface)); }
.spk-4 { background: color-mix(in srgb, #7c3aed 20%, var(--surface)); }
.spk-5 { background: color-mix(in srgb, #db2777 20%, var(--surface)); }
.spk-6 { background: color-mix(in srgb, #0891b2 20%, var(--surface)); }

/* ---------- บทถอดเสียงแบบคลิกได้ ---------- */

.transcript-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 62vh;
  overflow-y: auto;
  padding: 6px;
}

.tseg {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
}

.tseg:hover { background: var(--surface-2); }

.tseg.playing {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* timestamp = ตัวเลข/โคลอนล้วน ไม่มีอักษรไทย จึงใช้ฟอนต์ monospace ตามสเปก metadata
   (12/16) ได้เต็มที่โดยไม่เสี่ยงเรนเดอร์ไทยผิดฟอนต์เหมือนถ้าไปบังคับ monospace กับ
   ข้อความไทยปนตัวเลขที่อื่น (เช่น .meta, .list .s) ซึ่งจงใจไม่แตะ */
.tstart {
  flex: 0 0 auto;
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.tspk {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.ttext { flex: 1 1 auto; min-width: 0; }
.ttext[contenteditable="true"], .tspk[contenteditable="true"] {
  outline: 1px dashed var(--border);
  outline-offset: 2px;
  border-radius: 4px;
}
.ttext:focus, .tspk:focus { outline: 2px solid var(--accent); }

/* ---------- ข้อความสด ---------- */

.live-wrap { margin-top: 24px; }

/* ป้าย "กำลังฟัง/สด" ระหว่างพรีวิวข้อความสด — สีทีลตามระบบสี (live/listening) เปลี่ยน
   เป็นสีเทาเมื่อพรีวิวหยุดทำงานไปแล้ว (ตั้งจาก JS ใน sendLive() ตอน error) */
.live-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--live-soft);
  color: color-mix(in srgb, var(--live) 60%, var(--text));
  font-size: 12.5px;
  font-weight: 600;
}
.live-badge.stopped { background: var(--surface-2); color: var(--muted); font-weight: 400; }

.live-text {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 16px;
  max-height: 320px;
  overflow-y: auto;
}

.live-text p { margin: 0 0 8px; }

.mini-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.diarize-row { align-items: flex-end; gap: 18px; }
/* 0 1 = ยุบได้เมื่อจอแคบ (0 0 จะไม่ยอมยุบแล้วดันแถวล้น) */
.field-xs { flex: 0 1 140px; }
.check-inline { display: flex; align-items: center; gap: 8px; cursor: pointer; padding-bottom: 8px; }

.notice {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  font-size: 13.5px;
}

/* ---------- เครื่องประมวลผล ---------- */

.workers {
  margin: 4px 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.wk-head { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .04em; }

.wk { display: flex; gap: 9px; align-items: flex-start; padding: 5px 0; }
.wk-body { display: flex; flex-direction: column; min-width: 0; }
.wk-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-sub { font-size: 11.5px; color: var(--muted); }

.wk-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.wk.idle .wk-dot { background: var(--ok); }
.wk.busy .wk-dot { background: var(--warn); animation: pulse 1.4s ease-in-out infinite; }
.wk.gone .wk-dot { background: var(--muted); }
.wk.gone .wk-name { color: var(--muted); text-decoration: line-through; }

.wk-warn { margin: 8px 0 0; font-size: 12px; color: var(--warn); }

/* ---------- ผู้ใช้บน topbar ---------- */

.userbox { display: flex; align-items: center; gap: 8px; }
.userbox .who { font-size: 13px; color: var(--muted); max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- หน้าเข้าสู่ระบบ ---------- */

/* ตอนยังไม่ล็อกอินไม่ต้องมีแถบข้าง จะเหลือแต่ฟอร์มกลางจอ */
body.auth-only .sidebar { display: none; }
body.auth-only .layout { grid-template-columns: 1fr; }
body.auth-only #btn-new,
body.auth-only #stats { display: none; }

.auth-wrap { display: flex; justify-content: center; padding: 40px 16px; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 24px;
  box-shadow: var(--shadow);
}

.auth-card h2 { margin-bottom: 6px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card > .muted { margin: 0 0 18px; }
.btn-wide { width: 100%; padding: 10px; }

.auth-switch { margin: 14px 0 0; text-align: center; font-size: 13.5px; color: var(--muted); }

.linkbtn {
  border: none;
  background: none;
  padding: 0 0 0 4px;
  color: var(--accent);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- กล่องแชร์ ---------- */

.share-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px;
  margin: 0 0 18px;
}

.share-row { display: flex; gap: 8px; margin-bottom: 10px; }

.share-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.share-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.share-actions .muted { font-size: 12.5px; }

.center { text-align: center; color: var(--muted); padding: 60px 20px; }


/* ---------- ตัวเล่นเสียง (waveform) ---------- */

.player {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}

.p-play {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

/* กล่อง waveform เป็นเป้าลากด้วย ไม่ใช่แค่ภาพ — ต้องสูงพอให้นิ้วโดน */
.p-wave {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 44px;
  min-width: 0;
  cursor: pointer;
  touch-action: none;   /* ไม่งั้นการลากแนวนอนกลายเป็นการเลื่อนหน้าจอ */
}
.p-wave:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.p-bar {
  flex: 1 1 0;
  min-width: 2px;
  border-radius: 2px;
  background: var(--surface-2);
  transition: background .12s linear;
}
.p-bar.on { background: var(--accent); }

.p-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) { .p-bar { transition: none; } }

/* =======================================================================
   กฎของจอแคบต้องอยู่ท้ายสุดของไฟล์เสมอ — หลายกฎที่นี่ทับกฎเดิมที่ specificity เท่ากัน
   ถ้าย้ายขึ้นไปอยู่กลางไฟล์ กฎเดิมที่เขียนทีหลังจะชนะเงียบ ๆ (เจอมาแล้ว)
   ======================================================================= */
/* ---------- จอแคบ: โชว์ทีละหน้า ----------
   ของเดิมแค่ยุบสองคอลัมน์เป็นหนึ่ง = เอา sidebar (ค้นหา + คิวงาน + เครื่องประมวลผล + รายการ)
   ไปกองทับฟอร์ม "ประชุมใหม่" ทั้งก้อน หน้าเดียวยาวเกิน 3000px และไม่มีลำดับความสำคัญอะไรเลย
   ตอนนี้ body[data-view] เป็นตัวเลือกว่าจะโชว์ region ไหน (ดู setView() ใน app.js) */
.mobilebar, .m-cta, .m-chip, .acct, .m-section, .field-label { display: none; }

/* ---- แท็บ "เอาเสียงเข้ามายังไง" — ใช้ทั้งสองจอ (BACKLOG #79) ----
   เดิมจอกว้างกางการ์ดทั้งสามใบพร้อมกัน ซึ่งกลายเป็นกริดสองคอลัมน์ที่ใบที่สามตกไปแถวล่าง
   เหลือที่ว่างข้าง ๆ หนึ่งช่อง และหน้ายาวขึ้นโดยไม่ได้อะไรกลับมา — คนเลือกทางเดียวอยู่ดี
   `.seg` ยังถูกซ่อนด้วย attribute `hidden` ตอนเหลือทางเดียว
   แท็บของหน้ารายละเอียด (`#d-seg`) ใช้กฎชุดเดียวกันนี้ ตั้งแต่ BACKLOG #80 */
#cap-label:not([hidden]) {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.seg:not([hidden]) {
  display: flex;
  gap: 2px;
  margin: 0 0 16px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}
.seg-btn {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.seg-btn.is-on { background: var(--surface); color: var(--text); font-weight: 600; }
.seg-btn[hidden] { display: none; }

.seg:not([hidden]) ~ .cards { gap: 0; }
.card.cap-off { display: none; }
/* เมื่อมีปุ่มแท็บแล้ว การ์ดไม่ต้องมีกรอบหรือหัวข้อของตัวเอง — ชื่ออยู่บนปุ่มที่กดมาแล้ว
   ไม่งั้นจะเป็นกล่องในกล่องพร้อมหัวข้อซ้ำสองที่ */
.seg:not([hidden]) ~ .cards .card {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
}
.seg:not([hidden]) ~ .cards .card > h3 { display: none; }
/* แถบอัดลอยด้านล่างมีความหมายเฉพาะตอนอยู่แท็บ "อัดสด" */
body:not(.cap-rec) .floatbar { display: none; }
body:not(.cap-rec).has-floatbar .panel { padding-bottom: 16px; }

/* หน้ารายละเอียดก็แบ่งเป็นแท็บทั้งสองจอ (BACKLOG #80) — สรุปกับบทถอดเสียงยาวมากทั้งคู่
   วางต่อกันแล้วต้องเลื่อนผ่านสรุปทั้งอันกว่าจะถึงบทถอดเสียง ซึ่งจริงบนจอกว้างพอ ๆ กัน */
.dtab.tab-off { display: none; }

/* ---- ถาม-ตอบ (BACKLOG #54) ---- */
.ask-box { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 8px; }
.ask-box textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
  font: inherit;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.ask-box .btn { flex: none; min-height: 38px; }
.qa-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.qa-item:last-child { border-bottom: 0; }
.qa-q { font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }
.qa-q > span { flex: 1; min-width: 0; }
.qa-a { margin-top: 6px; }
/* คำตอบที่โมเดลบอกเองว่าข้อมูลไม่พอ ต้องดูออกตั้งแต่แรกเห็น ไม่ใช่ต้องอ่านจนจบ */
.qa-thin { color: var(--warn); font-size: 12px; margin-top: 4px; }
.qa-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }

/* ---- เช็กลิสต์ Action Items (BACKLOG #53) ---- */
.ai-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.ai-row:last-child { border-bottom: 0; }
/* กล่องติ๊กต้องใหญ่พอให้นิ้วโดน — ค่าเริ่มต้นของเบราว์เซอร์เล็กเกินไปบนมือถือ */
.ai-row input[type="checkbox"] { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.ai-body { flex: 1; min-width: 0; }
.ai-text { line-height: 1.5; }
.ai-row.is-done .ai-text { text-decoration: line-through; color: var(--muted); }
.ai-sub { margin-top: 2px; font-size: 12.5px; color: var(--muted); }
/* ปุ่มแก้ผู้รับผิดชอบดูเหมือนข้อความ แต่ต้องเป็น <button> จริงเพื่อให้แท็บ/สกรีนรีดเดอร์ถึงได้ */
.ai-who {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}
.ai-del { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }
/* กลุ่มเด็กกำพร้า — ระบบไม่ยอมลบงานที่คนติ๊กว่าทำแล้วเอง จึงต้องบอกว่าทำไมมันยังอยู่ */
.ai-orphans { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--border); }
.ai-orphans > p { margin: 0 0 6px; font-size: 12.5px; color: var(--warn); }
/* ชื่อส่วนอยู่บนปุ่มแท็บที่เพิ่งกดมาแล้ว ไม่ต้องเขียนซ้ำใต้ปุ่ม */
.dtab > .section-head > h3,
.dtab > .section-head > div > h3 { display: none; }

/* กล่องตัวเลือกเพิ่มเติม — ใช้ทั้งสองจอ ต่างกันแค่เปิด/ปิดตั้งต้น (ตั้งจาก JS) */
.adv { margin: 0 0 16px; }
.adv > summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  list-style: none;
}
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::after {
  content: '›';
  position: absolute;
  right: 26px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transform: rotate(90deg);
}
.adv[open] > summary::after { transform: rotate(-90deg); }
.adv > summary { position: relative; }
.adv-sum { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.adv[open] .adv-sum { display: none; }
.adv[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.adv[open] > .field-row:first-of-type { margin-top: 12px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { min-height: 0; border-right: none; border-bottom: none; background: var(--bg); }
  .panel { padding: 16px; }

  .mobilebar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
  }
  .mb-icon {
    border: 0;
    background: none;
    color: var(--text);
    font-size: 26px;
    line-height: 1;
    /* 44px = เป้าแตะขั้นต่ำที่นิ้วโป้งกดพลาดยาก */
    min-width: 44px;
    height: 44px;
    cursor: pointer;
  }
  .mb-title {
    flex: 1;
    min-width: 0;
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mb-icon[hidden] { display: none; }
  /* ไม่มีปุ่มย้อนกลับ = หัวข้อต้องไม่ชิดขอบจอ */
  .mb-back-hidden .mb-title { padding-left: 10px; }

  /* topbar บนมือถือเหลือแค่แบรนด์กับปุ่มบัญชีกลม ๆ ปุ่มเดียว
     ของเดิมมีอีเมล + ปุ่มแอดมิน 3 ปุ่มเรียงกัน บนจอ 390px ข้อความในปุ่มตัดเป็นสองบรรทัด
     ("อัด สด: เปิด" / "เชิญ สมาชิก" / "ออก จาก ระบบ") ดัน topbar สูงเกือบ 80px */
  .topbar { gap: 10px; }
  .topbar #btn-new,
  .topbar #stats { display: none; }
  .acct:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
  }

  .userbox { display: none; }
  body.account-open .userbox {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    position: fixed;
    z-index: 60;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .35);
  }
  body.account-open .userbox > * {
    width: 100%;
    min-height: 48px;
    text-align: left;
    font-size: 16px;
  }
  /* บรรทัดชื่อ/อีเมลเป็นหัวข้อของแผ่น ไม่ใช่ปุ่ม */
  body.account-open .userbox .who {
    min-height: 0;
    padding: 2px 4px 10px;
    color: var(--muted);
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    /* อีเมลยาวกว่าจอได้ ต้องตัดบรรทัดไม่ใช่ดันแผ่นให้กว้างเกิน */
    overflow-wrap: anywhere;
  }

  .m-cta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: calc(100% - 28px);
    margin: 14px;
    padding: 16px 18px;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--accent);
    color: #fff;
    text-align: left;
    font: inherit;
    cursor: pointer;
  }
  .m-cta-t { font-size: 17px; font-weight: 600; }
  .m-cta-s { font-size: 13px; opacity: .78; }

  .m-chip {
    display: inline-flex;
    align-items: center;
    /* .sidebar เป็น flex column ลูกจึงถูกยืดเต็มความกว้างตาม align-items: stretch
       ค่าเริ่มต้น — inline-flex ไม่ช่วย ต้อง align-self ให้หดเท่าเนื้อหาเหมือนในดีไซน์ */
    align-self: flex-start;
    gap: 7px;
    margin: 0 14px 12px;
    padding: 7px 13px 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
  }
  .m-chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
  .m-chip[data-state="down"] .m-chip-dot,
  /* ออนไลน์อยู่ แต่ไม่มีเครื่องรับงานที่ค้างคิว (BACKLOG #83) */
  .m-chip[data-state="stuck"] .m-chip-dot { background: var(--warn); }
  .m-cta[hidden], .m-chip[hidden] { display: none; }

  /* หนึ่งหน้าจอ = หนึ่งแถบหัว: หน้าแรกใช้ topbar (มีแบรนด์กับบัญชี) หน้าอื่นใช้ mobilebar
     (มีปุ่มย้อนกลับกับชื่อหน้า) ถ้าโชว์ทั้งคู่จะกินความสูงไปเกือบ 110px ตั้งแต่ยังไม่เห็นเนื้อหา */
  body[data-view="home"] .mobilebar { display: none; }
  body:not([data-view="home"]) .topbar { display: none; }

  /* ลำดับบนมือถือ: ปุ่มหลัก → สถานะเครื่อง → ค้นหา → คิวงาน → รายการ
     (DOM เรียงตามเดสก์ท็อปที่ค้นหาอยู่บนสุด จึงสลับด้วย order แทนการย้าย markup) */
  .sidebar { display: flex; flex-direction: column; }
  .search-wrap { order: 3; border-bottom: 0; padding: 0 14px 12px; }
  .m-cta { order: 1; }
  .m-chip { order: 2; }
  .jobs { order: 4; }
  #workers { order: 5; }
  .m-section { order: 5; }
  .list { order: 6; }

  .m-section:not([hidden]) {
    display: block;
    padding: 4px 16px 2px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
  }

  /* รายการประชุมเป็นการ์ดเหมือนในดีไซน์ — ของเดิมเป็นแถวเปล่าที่แตะยาก */
  .list { padding: 0 14px 24px; display: flex; flex-direction: column; gap: 10px; }
  .list li {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 14px 40px 14px 16px;
    position: relative;
  }
  .list li::after {
    content: '›';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
  }
  .list li.active { border-color: transparent; }
  .list .empty { background: none; }
  .list .empty::after { content: none; }

  /* ชื่อหน้าอยู่บน mobilebar แล้ว ไม่ต้องมีหัวข้อซ้ำในเนื้อหา */
  .pane-title { display: none; }

  /* หัวข้อเหนือแถบเลือกวิธีนำเสียงเข้า — มีเฉพาะจอแคบ (จอกว้างการ์ดมีหัวข้อของตัวเองอยู่แล้ว) */
  /* กล่องลากไฟล์: ไอคอน + บอกนามสกุลในกล่องเลย ย่อหน้าอธิบายเหนือกล่องจึงซ้ำซ้อน */
  .seg:not([hidden]) ~ .cards .card > p.muted { display: none; }
  .drop-icon { color: var(--accent); }
  .drop-formats { margin: 4px 0 0; font-size: 12.5px; }
  #drop { cursor: pointer; }

  /* --- หน้ารายละเอียด (เฉพาะของจอแคบ — ตัวแท็บย้ายไปอยู่ระดับบนสุดแล้ว #80) --- */
  /* ปุ่มชุดบนหัวข้อ ("แก้ไข/แปล/สรุปใหม่" ฯลฯ) ตกบรรทัดได้ ไม่ต้องอัดให้อยู่แถวเดียว */
  .section-head { flex-wrap: wrap; gap: 8px; }
  .detail-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  /* #d-title มี flex: 1 1 320px ไว้สำหรับแถวแนวนอน — พอสลับเป็นคอลัมน์ flex-basis
     กลายเป็น "ความสูง" 320px ทันที (ช่องว่างใต้ชื่อการประชุมยาวครึ่งจอ) */
  .detail-head #d-title { flex: 0 0 auto; width: 100%; }

  /* ชุดปุ่มของการประชุมย้ายลงเป็นแผ่นล่างจอ (เปิดด้วยปุ่ม ⋯ บน mobilebar) */
  .detail-actions { display: none; }
  .sheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, .55);
  }
  .sheet-scrim[hidden] { display: none; }
  body.sheet-open .detail-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    position: fixed;
    z-index: 60;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, .35);
  }
  body.sheet-open .detail-actions > * {
    width: 100%;
    min-height: 48px;
    text-align: left;
    font-size: 16px;
  }

  /* --- หน้าไหนโชว์อะไร --- */
  body[data-view="home"] .panel { display: none; }
  body[data-view="home"] #workers { display: none; }

  body[data-view="new"] .sidebar,
  body[data-view="meeting"] .sidebar { display: none; }

  /* หน้าเครื่องประมวลผล: เหลือเฉพาะกล่อง #workers ในคอลัมน์เดียวกัน */
  body[data-view="devices"] .panel,
  body[data-view="devices"] .search-wrap,
  body[data-view="devices"] .jobs,
  body[data-view="devices"] .list,
  body[data-view="devices"] .m-cta,
  body[data-view="devices"] .m-section,
  body[data-view="devices"] .m-chip { display: none; }

  /* แถวเครื่องเป็นการ์ดเหมือนในดีไซน์ ของเดิมเป็นบล็อกเทาก้อนเดียวทุกเครื่องติดกัน */
  /* หน้าเต็มจอไม่ต้องมีกรอบครอบอีกชั้น การ์ดแต่ละใบวางบนพื้นหลังหน้าไปเลย */
  body[data-view="devices"] #workers {
    margin: 0;
    padding: 0 14px 24px;
    border: 0;
    background: none;
  }
  body[data-view="devices"] .wk-name { font-size: 15px; white-space: normal; }
  body[data-view="devices"] .wk-sub { font-size: 13px; }
  body[data-view="devices"] .wk {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
  }
  body[data-view="devices"] .wk-group { padding: 14px 2px 6px; }
  body[data-view="devices"] #workers { display: block; }
  body[data-view="devices"] .wk-head { display: none; }   /* ชื่อหน้าอยู่บน mobilebar แล้ว */
}

/* BACKLOG #83 — เหตุผลที่งานค้างคิว ต่อท้ายบรรทัดสถานะ ไม่ใช่แถวใหม่ */
.job .job-stuck { color: var(--warn); }
.job .job-stuck::before { content: ' · '; color: var(--muted); }

/* BACKLOG #84 — เครื่องที่รันโค้ดคนละรุ่นกับเซิร์ฟเวอร์ */
.wk .wk-old { color: var(--warn); }
