/* AIFF — CSS ธรรมดา ไม่มี framework ไม่มี build step
 *
 * ชื่อ class บอกบทบาท ไม่ใช่หน้าตา (.list-item ไม่ใช่ .grey-row)
 * ดีไซน์ทั้งหมดอยู่ในไฟล์นี้ไฟล์เดียว เปลี่ยนหน้าตาได้โดยไม่ต้องแตะ template
 *
 * คำศัพท์ทั้งหมดและวิธีใช้: docs/recipes/ui-patterns.md
 * เพิ่ม class ใหม่ = อัปเดตเอกสารนั้นด้วยใน MR เดียวกัน
 *
 * ตอน DEBUG ไม่มี cache busting — แก้ไฟล์นี้แล้วไม่เห็นผลให้กด Ctrl+Shift+R
 */

/* ---------- design tokens ----------
 * ธีมมืดตามดีไซน์ที่สตูดิโอเลือก
 * เปลี่ยนสีทั้งระบบได้จากบล็อกนี้บล็อกเดียว
 */

:root {
  --ground: #0b0c0e;
  --panel: #0e1013;
  --surface: #15171a;
  --surface-2: #1c1f23;
  --line: #262a2f;
  --line-strong: #353a41;
  --line-soft: #1e2126;

  --ink: #eef1f4;
  --ink-2: #a3abb4;
  --ink-3: #6d757e;

  /* โทนเหลืองตาม CI บริษัท
   * ⚠️ ค่าที่ใส่ไว้เป็นค่าประมาณ รอเลข hex จริงจากฝ่ายแบรนด์แล้วแก้สามบรรทัดนี้
   * เหลืองสว่างพอที่ตัวหนังสือขาวบนพื้นเหลืองจะอ่านไม่ออก ปุ่มจึงใช้ตัวหนังสือสีเข้ม
   * (--accent-ink) ไม่ใช่สีขาว
   */
  --accent: #f0b429;
  --accent-hover: #d99e1a;
  --accent-ink: #1a1405;
  --accent-soft: rgba(240, 180, 41, 0.14);
  --accent-line: rgba(240, 180, 41, 0.38);

  --danger: #e0484b;
  --danger-hover: #c23a3d;
  --danger-soft: rgba(224, 72, 75, 0.12);
  --danger-line: rgba(224, 72, 75, 0.28);
  --danger-ink: #f2a1a3;

  /* ใช้กับสถานะที่ "กำลังดำเนินการอยู่ ยังไม่ตัดสิน" เช่น Review ของช็อต
     โทนที่มีอยู่เดิมไม่มีสีกลาง ๆ แบบนี้ — เขียวแปลว่าผ่านแล้ว เหลืองแปลว่ากำลังทำ */
  --info: #4a9fd8;

  --ok: #34d17f;
  --ok-soft: rgba(52, 209, 127, 0.12);
  --ok-line: rgba(52, 209, 127, 0.25);

  --radius: 8px;
  --radius-sm: 6px;
  --gap: 16px;
  --sidebar-w: 224px;

  --font: system-ui, -apple-system, Segoe UI, IBM Plex Sans Thai, Leelawadee UI, sans-serif;
  --font-mono: ui-monospace, Cascadia Mono, IBM Plex Mono, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---------- sidebar ---------- */

.sidebar {
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 14px;
  color: var(--ink);
  text-decoration: none;
}

.sidebar-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--radius-sm);
}

.sidebar-brand-text { font-size: 16px; font-weight: 600; }

.sidebar-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sidebar-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  height: 28px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.sidebar-card-body { display: flex; flex-direction: column; min-width: 0; }

.sidebar-card-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-card-sub { font-size: 11px; color: var(--ink-3); line-height: 1.3; }

.sidebar-section {
  margin: 18px 6px 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-item {
  padding: 8px 10px;
  font-size: 14px;
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.sidebar-item:hover { color: var(--ink); background: var(--surface); }

.sidebar-item.is-active {
  color: var(--ink);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 10px 6px 0;
  border-top: 1px solid var(--line-soft);
}

/* จุดบอกสถานะ — เดิมใช้แค่ท้าย sidebar ซึ่งเป็น flex จึงพึ่ง flex-basis อย่างเดียว
   ตอนนี้ใช้ในตารางด้วย ซึ่งไม่ใช่ flex จึงต้องมี display กับ width ของตัวเอง
   ไม่งั้นมันยุบหายไปเลยโดยไม่ฟ้องอะไร */
.status-dot {
  display: inline-block;
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  vertical-align: middle;
  background: var(--ok);
  border-radius: 50%;
}

/* สีของแต่ละสถานะ — ชื่อ modifier มาจาก Shot.status_class ใน shots/models.py
   เทียบกับ ShotGrid: เทาคือยังไม่เริ่ม เหลืองกำลังทำ ฟ้ากำลังตรวจ เขียวผ่าน แดงตัดออก */
.status-dot.is-not-started { background: var(--ink-3); }
.status-dot.is-in-progress { background: var(--accent); }
.status-dot.is-review { background: var(--info); }
.status-dot.is-approved { background: var(--ok); }
.status-dot.is-omitted { background: var(--danger); }

.sidebar-foot-body { display: flex; flex-direction: column; line-height: 1.35; }
.sidebar-foot-body b { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.sidebar-foot-body span { font-size: 11px; color: var(--ink-3); }

/* ---------- shell + topbar ---------- */

.shell { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ติดอยู่บนสุดตอนเลื่อนหน้า — ชื่อผู้ใช้ ยอด credit และ Sign out ต้องเห็นตลอด
   z-index ต่ำกว่า popover ของตัวกรอง (30) และ composer (40) ที่ลอยทับมันได้ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(8px);
}

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--gap);
  margin-left: auto;
  font-size: 14px;
}

.topbar-actions a { color: var(--ink-2); text-decoration: none; }
.topbar-actions a:hover { color: var(--accent); }

.brand { font-size: 17px; font-weight: 700; color: var(--ink); text-decoration: none; }
.brand-sub { font-size: 13px; color: var(--ink-3); }
.who { font-size: 13px; color: var(--ink-3); }

.wrap { width: 100%; max-width: 760px; padding: 36px 28px 80px; }

/* หน้าที่เป็นตารางหลายคอลัมน์ ปลดเพดาน 760px เพราะเป้าหมายของมันคือ
   เห็นหลายช่องพร้อมกัน ไม่ใช่บรรทัดข้อความที่อ่านสบาย */
.wrap.is-wide { max-width: none; }

/* หน้าที่ยังไม่ล็อกอินไม่มี sidebar จึงจัดกลางแทนการชิดซ้าย */
.is-anon .wrap { margin: 0 auto; }

/* ---------- หัวหน้าเพจ (partials/page_header.html) ---------- */

.page-header { margin-bottom: 24px; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 13px;
}

.breadcrumb-link { color: var(--ink-3); text-decoration: none; }
.breadcrumb-link:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--ink-3); }
.breadcrumb-current { color: var(--ink-2); }

.page-eyebrow {
  margin: 0 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-title {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.page-intro { margin: 12px 0 0; font-size: 16px; color: var(--ink-2); }
.page-note { margin: 24px 0 0; font-size: 14px; color: var(--ink-3); }

.page-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }

.section-title { margin: 32px 0 12px; font-size: 17px; font-weight: 600; }

/* ---------- รายการ ---------- */

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

.list-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 15px;
}

.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--surface-2); }

.list-item-main { font-weight: 500; color: var(--ink); text-decoration: none; }
a.list-item-main:hover { color: var(--accent); }

.list-item-meta { font-size: 13.5px; color: var(--ink-3); }

.list-empty { color: var(--ink-3); }
.list-empty:hover { background: none; }

/* รูปย่อหน้าแถวในรายการ
   align-self ต้องเป็น center เพราะ .list-item จัดตาม baseline ของตัวอักษร
   ส่วนรูปไม่มี baseline มันจะถูกดันหลุดแถวลงไปถ้าไม่บอก */
.list-item-thumb {
  align-self: center;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* รูป preview ขนาดเต็มในหน้า detail */
.entity-preview {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-bottom: 18px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

/* ---------- badge ---------- */

.badge {
  margin-left: auto;
  padding: 2px 9px;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  /* บางที่ badge เป็น <a> ที่ลิงก์ไปหาของจริง (เช่น shot ที่ asset ผูกอยู่) —
     กันขีดเส้นใต้ของลิงก์ปกติไว้เผื่อ ไม่กระทบ <span> ที่ไม่มีขีดเส้นใต้อยู่แล้ว */
  text-decoration: none;
}

.badge:hover { color: var(--ink); }

.badge + .badge { margin-left: 6px; }

.badge-strong { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge-self { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ---------- ฟอร์ม ---------- */

.form-card {
  max-width: 440px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-field { margin-bottom: 16px; }
.form-field:last-of-type { margin-bottom: 0; }

.form-label { display: block; margin-bottom: 5px; font-size: 13px; color: var(--ink-2); }

.form-card input[type="text"],
.form-card input[type="email"],
.form-card input[type="password"],
.form-card input[type="number"],
.form-card textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.form-card textarea { resize: vertical; min-height: 92px; }

.form-card input::placeholder,
.form-card textarea::placeholder { color: var(--ink-3); }

.form-card :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.form-error {
  margin: 7px 0 0;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--danger-ink);
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: var(--radius-sm);
}

/* คำใบ้ใต้ช่องกรอก เช่น คำที่คนอื่นเคยใช้มาแล้ว — ไม่ใช่ error จึงไม่ใช่สีแดง */
.form-hint {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

/* input[type=file] ไม่มีสไตล์ของตัวเองเลย ตัวหนังสือจึงเป็นสีดำของเบราว์เซอร์
   ซึ่งอ่านแทบไม่ออกบนพื้นมืดของธีมนี้ */
.form-card input[type="file"],
.modal input[type="file"] {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
}

.form-buttons { display: flex; align-items: center; gap: var(--gap); margin-top: 22px; }

/* ---------- ปุ่ม ---------- */

.btn {
  display: inline-block;
  padding: 9px 16px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--accent-hover); }

/* ปุ่มรองที่ไม่ควรเด่นเท่า action หลักของหน้า */
.btn-quiet { color: var(--ink-2); background: var(--surface); border-color: var(--line); }
.btn-quiet:hover { color: var(--ink); background: var(--surface-2); }

/* ปุ่มที่ลบของถาวรต้องไม่หน้าตาเหมือนปุ่มบันทึก */
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }

/* ใช้ได้ทั้งกับ <a> และ <button> — ต้องล้าง chrome ดีฟอลต์ของปุ่มด้วย
 * ไม่งั้นใน popup ที่ Cancel เป็น <button> จะโผล่กรอบเทาของเบราว์เซอร์ออกมา
 */
.btn-cancel {
  padding: 0;
  font: inherit;
  font-size: 14px;
  color: var(--ink-3);
  background: none;
  border: 0;
  text-decoration: none;
  cursor: pointer;
}

.btn-cancel:hover { color: var(--ink-2); }

.inline-form { display: inline; margin: 0; }

.linkish {
  padding: 0;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
  background: none;
  border: 0;
  cursor: pointer;
}

.linkish:hover { color: var(--accent); }

/* ---------- ข้อความแจ้งเตือน ---------- */

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

.message {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid var(--ok-line);
  border-radius: var(--radius-sm);
}

/* ---------- เฉพาะหน้า ---------- */

.token-box {
  margin: 0;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
}

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

.steps li {
  padding: 11px 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 14.5px;
  color: var(--ink-3);
}

.steps li:first-child { border-top: 0; }

.steps li b {
  display: inline-block;
  min-width: 34px;
  font-weight: 600;
  color: var(--ink-3);
}

.step-done { color: var(--ink-2); }
.step-done b { color: var(--ok); }

.step-next { color: var(--ink); background: var(--accent-soft); }
.step-next b { color: var(--accent); }

/* ---------- จอแคบ ---------- */

@media (max-width: 720px) {
  body { flex-direction: column; }
  .sidebar { flex: none; width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 12px; }
  .wrap { padding: 24px 18px 60px; }
}

/* ---------- popup (dialog) ----------
 * ฟอร์ม Create ทุกอันเปิดเป็น popup · ดู static/js/modal.js และ ui-patterns.md
 */

.modal {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.modal::backdrop { background: rgba(0, 0, 0, 0.62); }

/* ---------- หน้าต่างรายละเอียดของงาน ---------- */

/* กว้างกว่า popup ฟอร์มปกติ เพราะครึ่งซ้ายคือภาพที่ต้องดูออกว่าทำอะไรไป */
.modal-wide {
  width: min(1180px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100vh - 48px);
}

.detail { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); }

@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }

.detail-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: 14px;
  background: var(--ground);
}

.detail-media { max-width: 100%; max-height: calc(100vh - 90px); border-radius: var(--radius-sm); }
.detail-blank { padding: 40px 16px; text-align: center; }

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
}

@media (max-width: 900px) { .detail-side { border-top: 1px solid var(--line); border-left: 0; } }

.detail-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.detail-title { margin: 0; font-size: 16px; font-weight: 600; }

.detail-facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0; }
.detail-facts dt { font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.detail-facts dd { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }

.detail-label {
  margin: 0;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.detail-refs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }

.detail-refs li {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 3px 8px 3px 3px;
  font-size: 11px;
  color: var(--ink-3);
  background: var(--surface-2);
  border-radius: 999px;
}

.detail-refs img,
.detail-refs video { width: 26px; height: 26px; object-fit: cover; border-radius: 50%; }

/* บทบาทต้องเขียนกำกับ เพราะ reference กับเฟรมแรก/สุดท้ายดูไม่ต่างกันจากรูปย่อ
   แต่เป็นคนละกลไกในโมเดล */
.detail-refs b {
  padding: 1px 6px;
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}

.detail-form { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }

.detail-form textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  resize: vertical;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.detail-go { justify-content: center; }
.detail-go svg { width: 15px; height: 15px; }
.detail-loading { padding: 60px 20px; font-size: 13px; color: var(--ink-3); text-align: center; }

.modal-body { padding: 22px; }

.modal-title {
  margin: 0 0 18px;
  font-size: 19px;
  font-weight: 600;
}

.modal input[type="text"],
.modal input[type="email"],
.modal input[type="password"],
.modal input[type="number"],
.modal textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.modal textarea { resize: vertical; min-height: 84px; }
.modal :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- เมนูที่ยังกดไม่ได้ ----------
 * ของที่ยังไม่ได้สร้าง แสดงให้เห็นโครงว่าจะมีอะไร แต่ไม่ใช่ลิงก์ที่กดแล้ว 404
 */

.sidebar-item.is-soon {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
  cursor: default;
}

.sidebar-item.is-soon em {
  margin-left: auto;
  padding: 1px 6px;
  font-size: 9.5px;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-2);
  border-radius: 999px;
}

/* ---------- ฟอร์มเล็กในแถวรายการ ----------
 * เปลี่ยน role หรือถอดสมาชิกได้จากในแถวเลย ไม่ต้องเปิดหน้าใหม่
 */

.row-form { display: inline; margin: 0; }

/* ควบคุมเล็ก ๆ ที่อยู่ในแถวของรายการหรือตาราง — แก้ค่าได้โดยไม่ต้องเปิดหน้าใหม่
   สองชื่อเพราะชนิด element ต่างกัน แต่บทบาทเดียวกันเป๊ะ */
.row-select,
.row-input {
  padding: 3px 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.row-select:focus-visible,
.row-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ช่องตัวเลขในแถว — ล็อกความกว้างไว้ ไม่งั้นสามคอลัมน์เฟรมกินที่จนคำบรรยายเหลือนิดเดียว
   ปุ่มลูกศรขึ้นลงของ number input กินที่ไปอีก ~16px และไม่มีประโยชน์กับเลขเฟรม
   ที่คนพิมพ์เป็นหลักพัน จึงซ่อนทิ้ง (ยังกดลูกศรบนคีย์บอร์ดได้เหมือนเดิม) */
.row-input.is-frame {
  width: 72px;
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}

.row-input.is-frame::-webkit-outer-spin-button,
.row-input.is-frame::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
  appearance: none;
}

/* select ในฟอร์มปกติ (เช่น popup เพิ่มสมาชิก) ให้หน้าตาเท่ากับ input อื่น */
.form-card select,
.modal select {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* เลือกได้หลายค่า (เช่น Shots ของ asset) ต้องสูงพอเห็นตัวเลือกมากกว่าหนึ่งแถว
   ไม่งั้นเบราว์เซอร์จะย่อเหลือ ~4 แถวแบบสุ่มตามค่าเริ่มต้น */
.form-card select[multiple],
.modal select[multiple] {
  min-height: 90px;
}

/* ---------- แถบค้นหา/กรอง ----------
 * เหนือ .list หรือ .table ที่กรองได้ — GET form ธรรมดา ผลลัพธ์จึง bookmark/แชร์
 * ลิงก์ได้ตรง ๆ เสมอ · ช่องค้นหาอัปเดตแบบ live ด้วย HTMX ส่วน filter อื่นอยู่หลัง
 * ปุ่ม "Filters" เป็น popover ลอย ไม่ดันเนื้อหาข้างล่างลง ดู ui-patterns.md
 * หัวข้อ "แถบค้นหา/กรอง"
 */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--gap);
  margin-bottom: 20px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.filter-field { display: flex; flex-direction: column; gap: 5px; min-width: 140px; }
.filter-field-wide { flex: 1 1 220px; position: relative; }

.filter-field label { font-size: 12px; color: var(--ink-2); }

.filter-field input[type="text"],
.filter-field input[type="search"],
.filter-field input[type="date"],
.filter-field select {
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* หลายบรรทัดพอให้เห็นว่าเลือกได้มากกว่าหนึ่งแท็ก ไม่ใช่ dropdown ปกติ */
.filter-field select[multiple] { min-height: 74px; }

.filter-field :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-actions { display: flex; align-items: center; gap: 8px; }

/* filter ที่ไม่ค่อยได้ใช้บ่อยเท่าค้นหา — อยู่หลังปุ่มนี้เป็น popover ลอย ไม่ดัน
   ตารางข้างล่างลง เปิดเองถ้ามีอันไหนถูกเลือกอยู่แล้ว (ดู has_more_filters ใน view)
   ปิดเองเมื่อคลิกข้างนอกหรือกด Escape ผ่าน static/js/popover-toggle.js

   **เป็น <button> + <div hidden> ธรรมดา ไม่ใช่ <details>** — ลองมาก่อนแล้วพบว่า
   บาง engine (เจอใน Edge แม้เป็น Chromium เหมือน Chrome) ครอบเนื้อหาที่ไม่ใช่
   summary ด้วยกล่องที่ overflow: hidden เอง ตัด position: absolute ไม่ให้ลอย
   ออกมาได้ ต่างกันไปตามเวอร์ชัน/engine ไม่ชัวร์ข้ามเบราว์เซอร์ */
.filter-more { position: relative; align-self: flex-start; }

.filter-more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.filter-more-toggle:hover { color: var(--ink); background: var(--surface-2); }
.filter-more-toggle[aria-expanded="true"] { color: var(--ink); border-color: var(--accent-line); }
.filter-more-toggle :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-icon { flex: 0 0 auto; color: var(--ink-3); }
.filter-more-toggle[aria-expanded="true"] .filter-icon { color: var(--accent); }

/* จำนวน filter ที่เลือกอยู่ ขึ้นเป็นวงกลมเล็ก ๆ ต่อท้ายคำว่า Filter — ตามแบบ
   ShotGrid ที่ทีมคุ้น ไม่ใช้ .badge เดิมเพราะต้องกลมและเล็กกว่านั้น */
.filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}

.filter-chevron { flex: 0 0 auto; color: var(--ink-3); transition: transform 120ms ease; }
.filter-more-toggle[aria-expanded="true"] .filter-chevron { transform: rotate(180deg); }

/* popover ลอยใต้ปุ่ม ชิดขวา (ไม่ใช่ซ้าย) เพราะปุ่ม Filter อยู่ท้ายแถบค้นหา ชิดขวา
   แล้วลอยชนขอบขวาจะดูเป็นธรรมชาติกว่า · จัดเรียงเป็นคอลัมน์เดียวเพราะกว้างจำกัด
   ต่างจาก .filter-bar เองที่วางแนวนอน · เงาเข้มเพราะลอยทับเนื้อหาอื่นบนพื้นมืด
   ต้องแยกชั้นให้เห็นชัด */
.filter-more-fields {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(300px, calc(100vw - 32px));
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

/* [hidden] ของเบราว์เซอร์เป็นแค่ UA stylesheet เจอ display: flex ของเราซึ่งเป็น
   author stylesheet แล้วแพ้ ต้องสั่ง display: none ทับเองตรง ๆ ไม่งั้น panel
   จะค้างโชว์อยู่ตลอดแม้ JS จะเซ็ต hidden ให้แล้วก็ตาม */
.filter-more-fields[hidden] { display: none; }

.filter-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.filter-popover-header a {
  font-size: 12.5px;
  font-weight: 400;
  color: var(--ink-3);
  text-decoration: none;
}

.filter-popover-header a:hover { color: var(--accent); }

.filter-more-fields .filter-field { min-width: 0; }
.filter-more-fields .filter-field select[multiple] { min-height: 90px; }

.filter-more-fields .filter-actions {
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

/* ตัวบอกว่ากำลังค้นหาอยู่ ข้าง ๆ ช่อง search — ซ่อนไว้เป็นค่าเริ่มต้น htmx
   จะเติม class .htmx-request ให้เองระหว่างรอผลจาก server (ดู hx-indicator) */
.search-spinner {
  position: absolute;
  right: 10px;
  bottom: 9px;
  font-size: 12px;
  color: var(--ink-3);
}

.htmx-indicator { opacity: 0; transition: opacity 150ms ease; }
.htmx-indicator.htmx-request { opacity: 1; }

/* ---------- ตาราง ---------- */
/* ใช้ตอนที่แถวหนึ่งมีข้อมูลหลายช่องที่คนต้องเทียบกันในสายตาเดียว
   ถ้าแถวมีแค่ชื่อกับสถานะ ให้ใช้ .list ต่อไป มันอ่านง่ายกว่าและไม่ต้องเลื่อนข้าง */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}

.table th {
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-align: left;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 8px 12px;
  color: var(--ink);
  border-top: 1px solid var(--line-soft);
  vertical-align: middle;
}

/* หัวคอลัมน์อยู่กลางช่อง — **เป็น modifier ไม่ได้แก้ .table th ตรง ๆ** เพราะ
   `.table` ใช้ร่วมกับตาราง Asset แก้ที่นั่นจะเปลี่ยนหน้าที่คนอื่นดูแลอยู่ไปด้วย
   โดยที่เขาไม่ได้ขอ · ถ้าวันหนึ่งทีมตกลงว่าเอาแบบนี้ทั้งระบบ ให้ย้ายขึ้นไปรวมกับ
   `.table th` แล้วลบ modifier นี้ทิ้ง อย่าปล่อยให้มีสองทางค้างไว้

   ไม่แตะ `.table td` — ตัวเลขเฟรมชิดขวา ชื่อช็อตชิดซ้าย ถ้าจับมาไว้กลางหมด
   จะเทียบเลขกันทีละหลักไม่ได้ ซึ่งเป็นเหตุผลทั้งหมดที่ใช้ตารางแทนรายการ */
.table.head-center th { text-align: center; }

/* ข้อมูลในช่องอยู่กลางด้วย — **แยกเป็น modifier ที่สอง ไม่ได้รวมกับ head-center**
   เพราะหัวกับข้อมูลเป็นคนละเรื่องกัน ตารางที่อยากได้หัวอยู่กลางแต่ข้อมูลชิดซ้าย
   ยังทำได้เหมือนเดิม และชื่อ head-center ก็ยังตรงกับสิ่งที่มันทำ */
.table.cells-center td { text-align: center; }

/* ช่องกรอกในตารางไม่รับ text-align ต่อจาก <td> เอง ต้องสั่งตรง ๆ
   ตัวนี้ทับ .row-input.is-frame ที่ตั้งชิดขวาไว้ด้วย */
.table.cells-center .row-input,
.table.cells-center .row-select { text-align: center; }

/* **คำอธิบายเป็นข้อยกเว้น** มันเป็นประโยค ไม่ใช่ค่าเดี่ยว ๆ จัดกลางแล้วขอบซ้าย
   ของทุกแถวจะเยื้องกันคนละที่ ตาต้องไล่หาจุดเริ่มใหม่ทุกบรรทัด */
.table.cells-center td.table-col-wide,
.table.cells-center td.table-col-wide .row-input { text-align: left; }

.table tbody tr:hover td { background: var(--surface-2); }

/* หัวกลุ่ม เช่น Character (18) */
.table-group td {
  padding: 7px 12px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface-2);
}

/* คอลัมน์ชื่อค้างไว้ตอนเลื่อนดูคอลัมน์ขวา ไม่งั้นเลื่อนไปไกลแล้วไม่รู้ว่าแถวไหน
   ต้องมีพื้นทึบ ไม่งั้นเนื้อหาที่เลื่อนผ่านจะทะลุขึ้นมา */
.table-col-name {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--ground);
  border-right: 1px solid var(--line-soft);
}

.table th.table-col-name { background: var(--surface-2); }
.table-group .table-col-name { background: var(--surface-2); }
.table tbody tr:hover .table-col-name { background: var(--surface-2); }

/* คอลัมน์รูปย่อที่อยู่หน้าคอลัมน์ชื่อ — ต้องค้างไปด้วยกันทั้งคู่ ไม่งั้นพอเลื่อนข้าง
   คอลัมน์ชื่อที่ sticky อยู่ left:0 จะเลื่อนมาทับรูปเงียบ ๆ

   **ขอบเขตอยู่ที่ .table.has-thumb เท่านั้น** ตารางที่ไม่มีรูปยังทำงานเหมือนเดิมทุกอย่าง
   เพราะ .table-col-name เป็นคำศัพท์ที่ทุกหน้าใช้ร่วมกัน */
/* **ต้องล็อกความกว้างทั้งสามค่า** — `table-layout: auto` ถือว่า `width` เป็นแค่
   ข้อเสนอ ถ้าเนื้อหาหรือข้อความหัวคอลัมน์กว้างกว่า มันจะขยายให้เอง แล้วตัวเลข
   `left` ของคอลัมน์ถัดไปจะไม่ตรงอีกต่อไป คอลัมน์ชื่อจะเลื่อนมาทับรูปตอนเลื่อนข้าง
   (เจอมาแล้วตอนหัวคอลัมน์เขียนว่า "Thumb" ซึ่งดันให้กว้าง 62px แทนที่จะเป็น 56px)
   padding แคบกว่าช่องอื่นเพื่อให้เนื้อที่ในกรอบพอกับหัวคอลัมน์ */
.table-col-thumb {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 144px;
  min-width: 144px;
  max-width: 144px;
  overflow: hidden;
  background: var(--ground);
}

.table.has-thumb .table-col-name { left: 144px; }

/* รูปย่อในตาราง — **16:9 ไม่ใช่จัตุรัส** ต่างจาก .list-item-thumb ของหน้ารายการ
   เพราะช็อตคือเฟรมหนัง ถ้าครอบเป็นจัตุรัสจะตัดด้านข้างทิ้งซึ่งมักเป็นส่วนที่บอกว่า
   ช็อตนี้คือช็อตไหน · object-fit: cover กันภาพยืดตอนที่ต้นฉบับไม่ใช่ 16:9 พอดี */
/* ตัวเปิดของรูปย่อในตาราง — display: block เพื่อไม่ให้มีช่องว่างใต้รูปจาก
   baseline ของ inline element ซึ่งจะทำให้แถวสูงเกินไปทีละนิดโดยไม่มีสาเหตุที่มองเห็น */
.thumb-link { display: block; position: relative; }

/* สามเหลี่ยมบอกว่านี่คือวิดีโอ ไม่ใช่ภาพนิ่ง — **จำเป็น ไม่ใช่ของประดับ**
   <video> ที่ไม่มี controls หน้าตาเหมือนภาพนิ่งทุกอย่าง ถ้าไม่มีอะไรบอก
   คนจะไม่รู้ว่ากดแล้วจะได้คลิปหรือได้รูป

   วาดด้วย border ไม่ใช่ตัวอักษรหรือไฟล์รูป — ตัวอักษร ▶ วาดไม่เหมือนกันทุกเครื่อง
   และไฟล์รูปคืออีกหนึ่ง request ต่อแถว
   pointer-events: none เพื่อให้คลิกทะลุไปโดนลิงก์ที่ครอบอยู่ */
.thumb-link.is-video::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  margin: -8px 0 0 -5px;
  pointer-events: none;
  content: "";
  border-color: transparent transparent transparent rgba(255, 255, 255, 0.92);
  border-style: solid;
  border-width: 8px 0 8px 14px;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.75));
}
.thumb-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.thumb-link:hover .table-thumb { outline: 1px solid var(--ink-3); }

.table-thumb {
  display: block;
  width: 128px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface-2);
}

/* ⚠️ **ต้องเขียนเป็น `td.table-col-thumb` ไม่ใช่ `.table-col-thumb` เฉย ๆ**
   `.table td { padding: 8px 12px }` มีน้ำหนัก (0,1,1) ส่วน `.table-col-thumb`
   มี (0,1,0) ซึ่งแพ้ · ตอนแรกเขียนไว้แบบหลังแล้ว padding ไม่เคยมีผลเลย รูปกว้าง
   128px ในช่อง 144px จึงเหลือขอบซ้าย 12px ขวา 4px — ไม่ฟ้องอะไร เห็นตอนที่
   จับทุกอย่างมาไว้กลางแล้วรูปเป็นอันเดียวที่เยื้อง

   8px x 2 + รูป 128px = 144px พอดีกับความกว้างที่ล็อกไว้ */
.table td.table-col-thumb,
.table th.table-col-thumb { padding-left: 8px; padding-right: 8px; }

.table th.table-col-thumb { background: var(--surface-2); }
.table tbody tr:hover .table-col-thumb { background: var(--surface-2); }

.table-col-name a { color: var(--ink); font-weight: 500; text-decoration: none; }
.table-col-name a:hover { color: var(--accent); }

/* ชื่อเต็มใต้รหัส */
.table-sub { display: block; font-size: 12.5px; color: var(--ink-3); }

/* ช่องที่ยังไม่มีค่า — จางกว่าข้อความจริงเพื่อให้กวาดตาผ่านได้เร็ว */
.table-blank { color: var(--ink-3); }

/* ปุ่มขยาย/ย่อทรี Variant ใต้ Main ในตาราง — ดู static/js/tree-toggle.js และ
   docs/recipes/ui-patterns.md หัวข้อ "ทรีในตาราง" ลูกศรหมุนแบบเดียวกับ
   .filter-chevron ของแผง filter เพื่อให้เป็นภาษาภาพเดียวกันทั้งแอป */
.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 2px;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  vertical-align: middle;
}
.tree-toggle:hover { color: var(--ink); }
.tree-chevron { transition: transform 120ms ease; }
.tree-toggle[aria-expanded="true"] .tree-chevron { transform: rotate(180deg); }

/* แถว Variant — เยื้องเข้าไปใต้ Main ด้วยเส้นนำสายตาสั้น ๆ แทน padding เฉย ๆ
   เพื่อให้เห็นชัดว่าเป็นลูกของแถวข้างบน ตัวหนังสือจางกว่า Main เล็กน้อย */
.table-row-variant .table-col-name { padding-left: 26px; }
.table-row-variant .table-col-name::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 1px;
  margin-right: 6px;
  background: var(--ink-3);
  vertical-align: middle;
}
.table-row-variant td { color: var(--ink-2); }

/* คอลัมน์ที่ยอมให้ข้อความตัดบรรทัด เช่นคำอธิบาย */
.table-col-wide {
  max-width: 320px;
  white-space: normal;
}

/* คอลัมน์ที่มี **ช่องกรอก** อยู่ข้างใน ไม่ใช่ข้อความเฉย ๆ — ใส่คู่กับ .table-col-wide
   เพราะยังต้องการให้ตัดบรรทัดได้และยังเป็นตัวเกี่ยวของข้อยกเว้น cells-center

   เพดานกว้างกว่า 320px ของ .table-col-wide เพราะช่องที่พิมพ์ได้ต่างจากข้อความ
   ที่อ่านอย่างเดียว — ข้อความยาวเกินตัดบรรทัดลงมาได้ แต่ช่องกรอกจะเลื่อนข้าง
   ในตัวเอง คนพิมพ์จะเห็นแค่ท้ายประโยคและมองไม่เห็นว่าต้นประโยคเขียนว่าอะไร

   **เขียนเป็น td/th ไม่ใช่ .table-col-note เฉย ๆ** ไม่งั้นจะมีน้ำหนักเท่ากับ
   .table-col-wide (0,1,0) แล้วต้องไปพึ่งลำดับในไฟล์ว่าใครอยู่ทีหลัง */
.table td.table-col-note,
.table th.table-col-note { max-width: 520px; }

/* ช่องกรอกเต็มความกว้างของคอลัมน์ — ไม่ใส่ก็จะได้ขนาดปริยายของ <input>
   ซึ่งประมาณ 20 ตัวอักษร ไม่ว่าคอลัมน์จะกว้างแค่ไหน

   ⚠️ **`min-width` จำเป็น ไม่ใช่ใส่เผื่อ** — `width: 100%` เดี่ยว ๆ ทำให้คอลัมน์
   **แคบลง** ไม่ใช่กว้างขึ้น เพราะ `table-layout: auto` คิดความกว้างคอลัมน์จาก
   ความกว้างที่เนื้อหาต้องการ พอช่องกรอกบอกว่า "เอาเท่าคอลัมน์" มันก็ไม่เหลือ
   อะไรให้ตารางคิด แล้วบีบคอลัมน์ลงจนเหลือขั้นต่ำ (วัดได้ 86px จากเดิม ~200px)
   `min-width` คือตัวเลขที่ตารางเอาไปคิด ส่วน `max-width` ของ cell เป็นเพดาน */
.table td.table-col-note .row-input {
  width: 100%;
  min-width: 320px;
}

/* ---------- ส่วนขยายเล็ก ๆ ---------- */

.section-title { display: flex; align-items: baseline; gap: 12px; }

.section-link {
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-3);
  text-decoration: none;
}

.section-link:hover { color: var(--accent); }

.note-tight { margin-top: 0; margin-bottom: 12px; }

/* ชื่อโปรเจ็คที่ยังเข้าไม่ได้ — เห็นว่ามี แต่กดไม่ได้จนกว่าจะ join */
.list-item-main.is-muted { color: var(--ink-3); font-weight: 400; }

/* ---------- หน้าของคนคนหนึ่ง ---------- */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--ink-2);
}

.check-row input { margin-top: 5px; accent-color: var(--accent); }
.check-row b { color: var(--ink); font-weight: 600; }

.form-inline { max-width: none; margin-top: 16px; }

/* ---------- เนื้อหาหลักกับแผงเครื่องมือข้าง ๆ ---------- */
/* ใช้ตอนที่ของสองอย่างต้องอยู่ *ระดับเดียวกัน* ไม่ใช่ซ้อนบนล่าง
   เช่นตารางกับตัวกรองของมัน — ตัวกรองที่ลอยอยู่เหนือตารางกินที่แนวตั้งฟรี ๆ
   และดันตารางหลุดจอไปเรื่อย ๆ เมื่อฟอร์มมีช่องเยอะขึ้น */

.split { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 20px; }

/* **`min-width: 0` จำเป็นจริง ไม่ใช่ใส่เผื่อ** — flex item ที่มีตารางกว้างอยู่ข้างใน
   จะไม่ยอมหดต่ำกว่าความกว้างเนื้อหาของมัน แล้วแผงข้างจะถูกดันตกบรรทัดตลอด
   ทั้งที่ .table-scroll เลื่อนข้างเองได้อยู่แล้ว */
.split-main { flex: 1 1 420px; min-width: 0; }

/* จอแคบจะตกลงไปอยู่ใต้เนื้อหาเอง ไม่ต้องมี media query */
.split-aside { flex: 0 1 280px; }

/* --- แผงข้างที่ย่อได้ --------------------------------------------------------
   **ย่อแล้วเหลือแถบแนวตั้ง ไม่ใช่หายไปเลย** แบบแผงกรองของ ShotGrid
   ถ้าซ่อนทั้งแผง คนที่ไม่ได้เป็นคนย่อจะหาไม่เจอว่าตัวกรองอยู่ไหน
   แถบที่ยังอยู่บอกทั้งว่ามันมีอยู่ และกดตรงไหนถึงจะได้คืน */

.split-aside.is-collapsed { flex: 0 0 34px; }
.split-aside.is-collapsed .panel-body { display: none; }

/* ทั้งแถบคือปุ่ม ไม่ใช่ปุ่มเล็ก ๆ ที่มุม — ตอนย่อแล้วมันกว้าง 34px
   ถ้าต้องเล็งลูกศรจะกดยาก */
.panel-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* **จำเป็น** — [hidden] ของเบราว์เซอร์เป็น type selector ส่วน .panel-toggle
   เป็น class ซึ่งชนะ ถ้าไม่เขียนบรรทัดนี้ ปุ่มจะโผล่ทั้งที่ยังมี hidden อยู่
   แล้วคนที่ JS ไม่ทำงานจะเจอปุ่มที่กดแล้วเงียบ */
.panel-toggle[hidden] { display: none; }

.panel-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.panel-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.panel-chevron { font-size: 15px; line-height: 1; }

/* ลูกศรชี้ขวา = กดแล้วย่อไปทางขวา · ย่อแล้วกลับด้านเป็นชี้ซ้าย = กดแล้วกางออกมา
   หมุนด้วย CSS ไม่ต้องให้ JS ไปเปลี่ยนตัวอักษร */
.split-aside.is-collapsed .panel-chevron { transform: rotate(180deg); }

.split-aside.is-collapsed .panel-toggle {
  flex-direction: column;
  justify-content: flex-start;
  min-height: 132px;
  padding: 10px 6px;
  margin-bottom: 0;
}

/* ป้ายตะแคงตอนย่อ — mixed ทำให้ตัวเลขกับอักษรละตินยังตั้งตรงอ่านง่าย */
.split-aside.is-collapsed .panel-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* จุดบอกว่ากรองค้างอยู่ — ตอนย่อแล้วนี่คือสิ่งเดียวที่บอกว่ารายการไม่ครบ */
.panel-dot {
  flex: 0 0 7px;
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}

/* .filter-bar ออกแบบมาให้วางเหนือรายการ จึงมีกรอบกับระยะห่างล่างของตัวเอง
   พอย้ายมาอยู่ในแผงข้าง มันคือกรอบเดียวของแผงอยู่แล้ว ไม่ต้องเว้นล่างอีก
   และบังคับให้เรียงลงเพราะแผงกว้าง 280px ไม่ใช่เต็มหน้า */
.split-aside .filter-bar {
  flex-direction: column;
  /* stretch ไม่ใช่ flex-start — ในแผงแคบ ๆ ช่องที่กว้างไม่เท่ากันอ่านยากกว่า
     เดิม .filter-bar ตั้ง flex-start ไว้เพราะมันวางแนวนอน คนละสถานการณ์กัน */
  align-items: stretch;
  margin-bottom: 0;
}

/* ⚠️ **ในคอลัมน์ flex `flex-basis` คือความ*สูง* ไม่ใช่ความกว้าง**
   `.filter-field-wide { flex: 1 1 220px }` ถูกเขียนไว้สำหรับแถบกรองแนวนอน
   ที่อยู่เหนือรายการ พอเอามาวางเป็นคอลัมน์ มันกลายเป็นช่องสูง 220px ที่ยืดได้
   แล้วดันช่องที่เหลือตกไปอยู่ก้นแผง โดยไม่มีอะไรฟ้องว่าผิด */
.split-aside .filter-field-wide { flex: 0 0 auto; }

/* ---------- My Ideas — แคนวาสกับแถบสั่งงาน ---------- */

/* เว้นที่ล่างหน้าให้มากกว่าความสูงของแถบสั่งงาน ไม่งั้นการ์ดแถวสุดท้ายจะโดนบัง
   แม้เลื่อนจนสุดแล้ว — ค่านี้ต้องมากกว่า (ความสูงแถบ + ระยะห่างจากขอบล่าง) เสมอ */
/* 760px คือความกว้างของหน้าที่มีไว้อ่านข้อความ ไม่ใช่ของแกลเลอรี —
   หน้า canvas กินเต็มพื้นที่ที่เหลือจาก sidebar */
.wrap:has(.canvas) { max-width: none; }

.shell:has(.canvas) {
  background:
    radial-gradient(circle at 82% 4%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 24rem),
    linear-gradient(180deg, color-mix(in srgb, var(--ink) 1.2%, transparent), transparent 18rem);
}

.canvas { padding-bottom: 232px; }

.canvas-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding: 4px 0 22px;
  border-bottom: 1px solid var(--line-soft);
}

.canvas-lead { max-width: 660px; }

.canvas-eyebrow {
  margin: 0 0 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.canvas-title {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
  font-weight: 680;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.canvas-hint { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-2); }

.canvas-toolbar {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.canvas-count { font-size: 11.5px; color: var(--ink-3); }
.canvas-count strong { font-weight: 650; color: var(--ink-2); }

.event-shot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -8px 0 16px;
  align-items: center;
}

.event-shot-tabs .chip { text-decoration: none; }
.event-shot-tabs .chip.is-set {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.card-grid.event-overview-grid {
  /* !important also shields this page from an older cached gallery.js which
     wrote the My Ideas thumbnail preference onto the first grid inline. */
  --card-min: 340px !important;

  /* Event cards contain a working composer. When there are fewer events than
     available columns, collapse the unused tracks so the live cards can use
     the whole row instead of stopping halfway across the page. */
  grid-template-columns: repeat(auto-fit, minmax(min(var(--card-min), 100%), 1fr));
}

.event-overview-link,
.event-preview-link {
  display: flex;
  flex: 1;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}

.event-overview-link:focus-visible,
.event-preview-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.event-overview-card .card-media { object-fit: cover; }

/* Asset reference ต้องเห็น silhouette/composition ครบทั้งภาพ โดยเฉพาะ character
   sheet; cover แบบ Event จะตัดหัว/เท้าของภาพแนวตั้งหรือภาพที่วาง subject ชิดขอบ */
.asset-overview-card .card-media { object-fit: contain; }
.asset-overview-card .event-overview-visual { background: var(--ground); }
.asset-overview-card .card-body { cursor: pointer; }
.asset-card-description {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}
.asset-overview-card.is-expanded .asset-card-description {
  display: block;
  overflow: visible;
}
.asset-card-expand {
  align-self: flex-start;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  background: transparent;
  border: 0;
}
.asset-card-expand:hover { color: var(--accent); }
.asset-list-description {
  display: -webkit-box;
  min-width: 220px;
  max-width: 440px;
  overflow: hidden;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
tr.is-expanded .asset-list-description {
  display: block;
  overflow: visible;
}
.asset-list-expand {
  padding: 3px 0 0;
  font: inherit;
  font-size: 11px;
  color: var(--ink-3);
  cursor: pointer;
  background: transparent;
  border: 0;
}
.asset-list-expand:hover { color: var(--accent); }
tr[data-expandable-row] { cursor: pointer; }
.asset-preview-link {
  display: flex;
  width: 100%;
  height: 100%;
}

.event-title-link { color: inherit; text-decoration: none; }
.event-title-link:hover { color: var(--accent); }

.event-hero-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent);
  border-radius: 999px;
  pointer-events: none;
}

.event-open-label {
  flex: none;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
}

.event-overview-brief {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.event-quick-status { min-height: 24px; }

.event-status-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.event-status-pill .dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
}

.event-status-pill.is-waiting,
.event-status-pill.is-running { color: var(--accent); border-color: var(--accent-line); }
.event-status-pill.is-running .dot { animation: pulse 1.4s ease-in-out infinite; }
.event-status-pill.is-ready { color: var(--success); }
.event-status-pill.is-stopped { color: var(--danger-ink); }
.event-status-pill small { color: var(--ink-3); }

.canvas-empty {
  grid-column: 1 / -1;
  padding: 72px 20px;
  text-align: center;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 5.5%, transparent), var(--surface) 58%);
  border: 1px dashed var(--accent-line);
  border-radius: 16px;
}

.canvas-empty-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 12px;
}

.canvas-empty-mark svg { width: 22px; height: 22px; }
.canvas-empty-title { margin: 0 0 6px; font-size: 16px; font-weight: 650; color: var(--ink); }
.canvas-empty-note { margin: 0; font-size: 13px; color: var(--ink-3); }

/* ---------- การ์ดผลงาน ---------- */

/* ความกว้างขั้นต่ำของช่องหนึ่งช่อง — แถบ S/M/L เปลี่ยนค่านี้ค่าเดียว
   แล้ว auto-fill เป็นคนตัดสินว่าแถวหนึ่งใส่ได้กี่ใบ ไม่ต้องเขียน media query
   สามชุดให้ค้างไว้ไม่ตรงกันทีหลัง */
.card-grid {
  --card-min: 300px;

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--card-min), 100%), 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- แถบเลือกขนาดรูปย่อ ---------- */

.size-strip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.size-label {
  padding: 0 8px 0 7px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.size-btn {
  min-width: 28px;
  padding: 5px 0;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 999px;
}

.size-btn:hover { color: var(--ink); background: var(--surface-2); }
.size-btn.is-active {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 20%, transparent);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--ground) 58%, transparent);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 14px 32px color-mix(in srgb, var(--ground) 72%, transparent);
  transform: translateY(-2px);
}

.card.is-working {
  /* ทุก animation ด้านในหารลงตัวกับ 4s เพื่อให้ทั้ง card กลับมาที่เฟรมเดิมพร้อมกัน */
  --generation-loop: 4s;
  border-color: var(--accent-line);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 6%, transparent),
    0 12px 30px color-mix(in srgb, var(--ground) 68%, transparent);
}

.card.is-working .card-visual::before,
.card.is-working .card-visual::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.card.is-working .card-visual::before {
  inset: -55%;
  background: conic-gradient(
    from 90deg,
    transparent 0 35%,
    color-mix(in srgb, var(--accent) 9%, transparent) 43%,
    color-mix(in srgb, var(--ink) 5%, transparent) 50%,
    transparent 58% 100%
  );
  animation: generation-sweep var(--generation-loop) linear infinite;
}

.card.is-working .card-visual::after {
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    color-mix(in srgb, var(--ink) 6%, transparent) 47%,
    transparent 64%
  );
  transform: translateX(-100%);
  animation: generation-shimmer 2s linear infinite;
}

/* ภาพนิ่งกดเพื่อเปิดดูใหญ่ และลากลงไปวางในแถบสั่งงานได้ */
.card-visual[data-drag-media] { cursor: grab; }
.card-visual[data-drag-media]:active { cursor: grabbing; }

.card-top {
  position: absolute;
  top: 10px;
  right: 10px;
  left: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  background: color-mix(in srgb, var(--ground) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.card-tag-live { color: var(--accent); }
.card-tag-failed { color: var(--danger-ink); }

.card-tag .dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}

.card-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.card-action { display: inline-flex; margin: 0; }
.icon-btn.is-hero { color: var(--accent); opacity: 1; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  font-size: 17px;
  line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
  background: color-mix(in srgb, var(--ground) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  border-radius: 999px;
  backdrop-filter: blur(10px);
}

.icon-btn svg { width: 13px; height: 13px; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent-line); }
.icon-btn-danger:hover { color: var(--danger-ink); border-color: var(--danger-line); }

.pill-btn {
  padding: 4px 11px;
  font: inherit;
  font-size: 11.5px;
  color: var(--ink);
  cursor: pointer;
  background: rgba(8, 9, 11, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.pill-btn:hover { border-color: var(--accent-line); }

/* ไม่ครอบตัดผลงาน — สัดส่วนที่ศิลปินเลือกต้องเห็นครบ */
.card-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--accent) 4%, transparent), transparent 48%),
    var(--ground);
}

.card-media { width: 100%; height: 100%; object-fit: contain; }

.card-empty {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  padding: 16px;
  text-align: center;
}

.card-empty-title { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.card-empty-note { margin: 0; font-size: 12px; color: var(--ink-3); }
.card-empty-note strong { font-weight: 650; color: var(--accent); }

.generation-orbit {
  position: relative;
  width: 58px;
  height: 58px;
  margin-bottom: 5px;
  border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  border-radius: 50%;
  box-shadow:
    0 0 32px color-mix(in srgb, var(--accent) 8%, transparent),
    inset 0 0 22px color-mix(in srgb, var(--ground) 62%, transparent);
}

.generation-orbit::before {
  position: absolute;
  inset: 8px;
  content: "";
  border: 1px solid color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 50%;
}

.generation-orbit i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  margin: -3px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
  animation: generation-orbit 2s linear infinite;
}

.generation-orbit i:nth-child(2) {
  width: 4px;
  height: 4px;
  margin: -2px;
  background: color-mix(in srgb, var(--accent) 62%, var(--ink));
  animation-duration: var(--generation-loop);
  animation-delay: -1.333s;
  animation-direction: reverse;
}

.generation-orbit i:nth-child(3) {
  width: 3px;
  height: 3px;
  margin: -1.5px;
  background: var(--ink);
  animation-duration: 1s;
  animation-delay: -0.667s;
}

.generation-track {
  width: 112px;
  height: 3px;
  margin-top: 9px;
  overflow: hidden;
  background: var(--line);
  border-radius: 999px;
}

.generation-track i {
  display: block;
  width: 42%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: generation-track 2s linear infinite;
}

.generation-track.is-determinate i {
  width: 0;
  background: var(--accent);
  transition: width 300ms ease;
  animation: none;
}

@keyframes generation-sweep { to { transform: rotate(360deg); } }
@keyframes generation-shimmer {
  0%, 12% { opacity: 0; transform: translateX(-100%); }
  22% { opacity: 1; }
  78% { opacity: 1; }
  88%, 100% { opacity: 0; transform: translateX(100%); }
}
@keyframes generation-orbit {
  from { transform: rotate(0deg) translateX(24px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(24px) rotate(-360deg); }
}
@keyframes generation-track {
  0% { opacity: 0; transform: translateX(-110%); }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { opacity: 0; transform: translateX(250%); }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

@media (prefers-reduced-motion: reduce) {
  .card.is-working .card-visual::before,
  .card.is-working .card-visual::after,
  .generation-orbit i,
  .generation-track i { animation: none; }
  .card-tag .dot { animation: none; }
  .enhance-spinner-ring { animation: none; }
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line-soft);
}

.card-title {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
  margin: 0;
  font-size: 13.5px;
  font-weight: 520;
  line-height: 1.45;
  color: var(--ink);
}

.card-time { flex: none; font-size: 11.5px; color: var(--accent); }

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-3);
}

.card-meta span { display: inline-flex; align-items: center; gap: 10px; }
.card-meta span:not(:last-child)::after {
  width: 3px;
  height: 3px;
  content: "";
  background: var(--line);
  border-radius: 50%;
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card:hover { transform: none; }
}

/* ---------- แถบสั่งงานที่ลอยอยู่ล่างหน้า ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.composer {
  position: fixed;
  right: 28px;
  bottom: 18px;
  left: calc(var(--sidebar-w) + 28px);
  z-index: 40;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  max-width: 1100px;
  margin: 0 auto;
}

.composer-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  background: linear-gradient(
    160deg,
    color-mix(in srgb, var(--surface-2) 84%, transparent),
    color-mix(in srgb, var(--panel) 80%, transparent)
  );
  border: 1px solid var(--line-strong);
  border-top-color: var(--accent-line);
  border-radius: 15px;
  box-shadow:
    0 20px 54px color-mix(in srgb, var(--ground) 86%, transparent),
    0 0 0 1px color-mix(in srgb, var(--accent) 3.5%, transparent);
  backdrop-filter: blur(22px) saturate(1.08);
}

.composer :focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* `hidden` ต้องชนะ display ของ .chip / .pill
 *
 * `[hidden]` ของเบราว์เซอร์เป็นแค่ UA stylesheet ซึ่งแพ้ class ของเราทุกครั้ง แปลว่า
 * `<label class="pill" hidden>` ยังโชว์อยู่เฉย ๆ — นี่คือเหตุผลที่ช่องความยาวคลิปกับ
 * frame rate โผล่อยู่ในโหมดภาพนิ่งมาตลอด ทั้งที่ JavaScript สั่งซ่อนไปแล้ว
 */
.composer [hidden] { display: none; }

/* ---------- โหมด Image / Video ---------- */

.mode-strip {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: 3px;
  width: 66px;
  padding: 5px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 20px 54px color-mix(in srgb, var(--ground) 84%, transparent);
  backdrop-filter: blur(22px) saturate(1.08);
}

.mode-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
  width: 54px;
  min-height: 53px;
  padding: 7px 4px;
  font-size: 10px;
  color: var(--ink-3);
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 9px;
}

.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option:hover { color: var(--ink-2); background: var(--surface); }
.mode-icon svg { display: block; width: 17px; height: 17px; }

.mode-option:has(input:checked) {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-line);
  box-shadow: inset 0 0 18px color-mix(in srgb, var(--accent) 5.5%, transparent);
}

.mode-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- แถว References ---------- */

.composer-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 28px; }

.chip,
.round-btn,
.pill,
.stepper,
.ghost-btn {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font: inherit;
  font-size: 11px;
  color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chip { min-height: 28px; padding: 4px 9px; cursor: pointer; }
.chip-plus { font-size: 14px; line-height: 1; }
.chip-count { color: var(--ink-3); }

.soon-tag {
  padding: 1px 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  background: var(--surface-2);
  border-radius: 999px;
}

/* ปุ่มที่ยังไม่มีของอยู่ข้างหลัง — จางแต่ยังอ่านออก และเคอร์เซอร์บอกว่ากดไม่ได้ */
.composer [disabled] { cursor: not-allowed; opacity: 0.55; }
.composer [disabled]:hover { background: var(--surface); border-color: var(--line); }

.chip:hover:not([disabled]) { color: var(--ink); border-color: var(--accent-line); }
.chip[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }

/* เกินเพดานของโมเดลแล้ว — บอกตรงตัวเลข ไม่ต้องรอให้กด Generate ถึงจะรู้ */
.chip.is-over { color: var(--danger); border-color: var(--danger); }
.chip.is-over .chip-count { color: var(--danger); }

.chip-clear {
  padding: 0 2px;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  background: none;
  border: 0;
}

.chip-clear:hover { color: var(--ink); }

/* ---------- chip ของภาพที่ถูกอ้างถึง ---------- */

.ref-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.ref-chip {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 3px 7px 3px 4px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: rgb(117 90 184 / 13%);
  border: 1px solid rgb(185 164 238 / 30%);
  border-radius: 7px;
}

.ref-chip img {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 4px;
}

/* เลขลำดับ = เลขใน token ที่โมเดลจะเห็น (`image 1`, `<Picture 2>`) ไม่ใช่เลขประดับ */
.ref-chip b {
  min-width: 15px;
  padding: 1px 0;
  font-size: 10px;
  text-align: center;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
}

.reference-slot-number {
  min-width: 24px;
  padding: 2px 7px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  background: rgb(238 241 244 / 18%);
  border: 1px solid rgb(238 241 244 / 62%);
  border-radius: 5px;
}

.reference-slot-number:hover,
.reference-slot-number:focus-visible {
  color: #fff;
  background: rgb(238 241 244 / 28%);
  border-color: var(--ink);
  outline: 0;
}

.reference-prompt-insert {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: transparent;
  border: 0;
}

.reference-prompt-insert:hover,
.reference-prompt-insert:focus-visible {
  color: #eee9ff;
  outline: 0;
}

/* ---------- ช่องเฟรมแรก / เฟรมสุดท้าย ---------- */

.frame-slot.is-set { color: var(--ink); border-color: var(--accent-line); }

.frame-slot-thumb {
  width: 20px;
  height: 20px;
  background-position: center;
  background-size: cover;
  border-radius: var(--radius-sm);
}

.source-video-slot {
  min-width: 22px;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  text-align: center;
  background: rgb(238 241 244 / 18%);
  border: 1px solid rgb(238 241 244 / 62%);
  border-radius: 5px;
}

/* ---------- แผงเลือกภาพ ---------- */

/* ลอยขึ้นเหนือแถบสั่งงาน ไม่ได้ดันแถบให้สูงขึ้น — ไม่งั้นแกลเลอรีจะกระตุกทุกครั้ง
   ที่เปิดปิด และปุ่ม Generate จะขยับหนีมือคนที่กำลังจะกด */
.ref-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 2;
  max-height: 46vh;
  padding: 10px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
}

.composer-body { position: relative; }

.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ref-option {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.ref-option img,
.ref-option video { display: block; width: 100%; height: 76px; object-fit: cover; }
.ref-option:hover { border-color: var(--accent); }

.ref-option-tag {
  display: block;
  padding: 4px 6px;
  overflow: hidden;
  font-size: 10.5px;
  color: var(--ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-empty { margin: 0; padding: 14px 4px; font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* ---------- ช่อง prompt ---------- */

.composer-prompt { position: relative; }

.prompt-syntax-tag {
  display: inline;
  padding: 0 2px;
  color: #d8cfff;
  background: rgb(117 90 184 / 34%);
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgb(185 164 238 / 42%);
}

.prompt-slot-menu {
  position: absolute;
  z-index: 4;
  top: calc(100% - 4px);
  left: 10px;
  display: grid;
  min-width: 230px;
  padding: 6px;
  font-size: 12px;
  color: var(--ink-3);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: var(--shadow);
}

.prompt-asset-menu {
  position: absolute;
  z-index: 5;
  right: auto;
  bottom: calc(100% + 6px);
  left: 10px;
  display: grid;
  min-width: 280px;
  width: min(420px, 100%);
  max-width: 100%;
  max-height: 260px;
  padding: 6px;
  margin-top: 0;
  overflow-y: auto;
  font-size: 12px;
  color: var(--ink-3);
  background: #15171a;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  box-shadow: var(--shadow);
}

/* Event card เปิดลงล่าง ส่วน composer หลักเปิดขึ้นบนโดยไม่ดัน layout */
.event-quick-composer .prompt-asset-menu {
  top: calc(100% + 6px);
  bottom: auto;
}

.prompt-asset-menu[hidden] { display: none; }
.prompt-asset-menu button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 6px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 6px;
}
.prompt-asset-menu button:hover { background: var(--accent-soft); }
.prompt-asset-menu button:disabled { color: var(--ink-3); cursor: not-allowed; opacity: 0.65; }
.prompt-asset-menu img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: var(--ground);
  border-radius: 5px;
}
.prompt-asset-menu strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt-asset-menu small { color: var(--ink-3); white-space: nowrap; }

.prompt-slot-menu[hidden] { display: none; }
.prompt-slot-menu button {
  padding: 7px 9px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 6px;
}
.prompt-slot-menu button:hover { color: var(--accent); background: var(--accent-soft); }

.composer textarea {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 74px;
  max-height: 148px;
  padding: 11px 104px 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  resize: none;
  background: color-mix(in srgb, var(--ground) 74%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.prompt-rich-editor {
  width: 100%;
  min-height: 74px;
  max-height: 148px;
  overflow: auto;
  padding: 11px 104px 10px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  background: color-mix(in srgb, var(--ground) 74%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
}

.prompt-rich-editor:focus {
  outline: 0;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.prompt-rich-editor:empty::before {
  color: var(--ink-3);
  pointer-events: none;
  content: attr(data-placeholder);
}

.prompt-rich-editor:focus:empty::before { color: transparent; }

.composer textarea::placeholder { color: var(--ink-3); }
.composer textarea:focus {
  outline: 0;
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ข้อความตัวอย่างหายทันทีที่เริ่มพิมพ์ — มันเป็นตัวช่วยตอนกล่องยังว่าง
   ไม่ใช่ของที่ต้องอ่านแข่งกับสิ่งที่ตัวเองกำลังพิมพ์อยู่ */
.composer textarea:focus::placeholder { color: transparent; }

/* ลากภาพมาค้างไว้เหนือแถบ — ต้องเห็นว่าปล่อยตรงนี้แล้วมีผล */
.composer.is-drop-target .composer-body { border-color: var(--accent); }
.composer-prompt.is-drop-role textarea,
.composer-prompt.is-drop-role .prompt-rich-editor,
.chip.is-drop-role {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.paste-note { margin: 0; font-size: 11.5px; color: var(--ink-3); }
.paste-note.is-error { color: var(--danger-ink); }

.ghost-btn { padding: 5px 8px; cursor: pointer; background: transparent; border-color: transparent; }
.ghost-btn svg { width: 13px; height: 13px; }
.composer-enhance { position: absolute; z-index: 2; top: 7px; right: 7px; }

/* ปุ่ม Enhance ชี้เมาส์แล้วเปลี่ยนเป็นสีธีม (เหลืองส้ม) เหมือน .btn ปกติ — ต้อง
   :not([disabled]) กันไม่ให้ตอนกำลังโหลด (hx-disabled-elt ใส่ disabled ให้เอง)
   ไปทับสไตล์เทาของ .composer [disabled] ด้านบน */
.composer-enhance:hover:not([disabled]) {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

/* สลับ ไอคอน+ข้อความปกติ ↔ spinner+"Enhancing…" ตอนกำลังยิง request — ปุ่มที่มี
   hx-post จะได้ class "htmx-request" จาก htmx เองระหว่างรอ ไม่ต้องมี JS เพิ่ม */
.enhance-spinner-ring,
.enhance-btn-loading-text { display: none; }

.composer-enhance.htmx-request .enhance-icon,
.composer-enhance.htmx-request .enhance-btn-label { display: none; }

.composer-enhance.htmx-request .enhance-spinner-ring,
.composer-enhance.htmx-request .enhance-btn-loading-text { display: inline-flex; }

.enhance-spinner-ring {
  width: 11px;
  height: 11px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* กล่องข้อเสนอของปุ่ม Enhance — โผล่ใต้กล่อง prompt เสมอ ไม่แทนที่ข้อความให้เอง
   ต้องกด "Use this" ก่อน (ดู composer.js data-enhance-apply/dismiss) */
.enhance-box {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
}

.enhance-box.is-error { background: var(--danger-soft); border-color: var(--danger-line); }

.enhance-label {
  margin: 0 0 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.enhance-text { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink); white-space: pre-wrap; }
.enhance-error { margin: 0; font-size: 13px; color: var(--danger-ink); }

.enhance-actions { display: flex; gap: 8px; margin-top: 9px; }
.enhance-actions .btn { padding: 6px 12px; font-size: 12.5px; }

/* ---------- แถวควบคุม ---------- */

/* wrap ได้เสมอ — โหมดวิดีโอมีช่องเยอะ และปุ่ม Generate กว้างขึ้นเมื่อมีราคา credit
   ต่อท้าย ถ้าห้ามขึ้นบรรทัดใหม่ ปุ่มจะล้นออกนอกกรอบ composer · ปุ่มมี margin-left: auto
   จึงตกลงไปชิดขวาของบรรทัดใหม่เอง */
.composer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.round-btn {
  justify-content: center;
  width: 29px;
  height: 29px;
  padding: 0;
  font-size: 14px;
  cursor: pointer;
}

.pill { position: relative; min-height: 29px; padding: 0 8px; cursor: pointer; }
.pill svg { flex: none; width: 13px; height: 13px; color: var(--ink-3); }
.pill-static { padding: 5px 9px; cursor: default; }

/* `<select>` ไม่มีกรอบของตัวเอง — กรอบมาจาก .pill ที่ครอบอยู่ */
.pill select {
  padding: 5px 19px 5px 1px;
  font: inherit;
  font-size: 10.5px;
  color: var(--ink);
  cursor: pointer;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%236d757e' stroke-width='1.6'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E") right 4px center / 11px no-repeat;
  border: 0;
  appearance: none;
}

.pill select:focus { outline: 0; }
.pill:focus-within { border-color: var(--accent-line); }
.pill select option { color: var(--ink); background: var(--surface); }

/* ช่องพิมพ์เลขอิสระในพิล เช่นความยาวคลิป — ต่างจาก .pill select ตรงที่ไม่มีลูกศร
   แต่มีหน่วย (s) ต่อท้ายแทน ซ่อนลูกศรขึ้นลงของเบราว์เซอร์เพราะพิลแคบเกินจะพอดี */
.pill-number input[type="number"] {
  width: 34px;
  padding: 5px 1px;
  font: inherit;
  font-size: 10.5px;
  color: var(--ink);
  text-align: right;
  background: transparent;
  border: 0;
  appearance: textfield;
  -moz-appearance: textfield;
}

.pill-number input[type="number"]::-webkit-outer-spin-button,
.pill-number input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.pill-number input[type="number"]:focus { outline: 0; }
.pill-suffix { font-size: 10.5px; color: var(--ink-3); }

/* ---------- ตัวนับจำนวน ---------- */

.stepper { padding: 2px; }

.stepper-btn {
  width: 23px;
  height: 23px;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: 999px;
}

.stepper-btn:hover { color: var(--ink); background: var(--surface-2); }

.stepper input {
  width: 22px;
  padding: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  background: transparent;
  border: 0;
  appearance: textfield;
}

.stepper input::-webkit-inner-spin-button { appearance: none; }

/* ---------- สวิตช์ ---------- */

.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch:has(input:disabled) { display: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch-track {
  position: relative;
  width: 38px;
  height: 21px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.15s;
}

.switch-track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  content: "";
  background: var(--ink-3);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after {
  background: var(--accent-ink);
  transform: translateX(17px);
}

@media (prefers-reduced-motion: reduce) {
  .switch-track,
  .switch-track::after { transition: none; }
}

/* ---------- ปุ่ม Generate ---------- */

.composer-go {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
  min-height: 42px;
  padding: 9px 16px;
  white-space: nowrap;
  border-radius: 9px;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 18%, transparent);
}

.composer-go svg { width: 14px; height: 14px; }

.go-count {
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-ink);
  border-radius: 999px;
}

/* ---------- Event overview quick composer ---------- */

.event-quick-composer.composer {
  position: relative;
  inset: auto;
  z-index: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: none;
  padding: 12px;
  margin: 0;
  border-top: 1px solid var(--line);
}

.event-quick-composer .event-quick-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.event-quick-composer .mode-option {
  width: auto;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.event-quick-composer .composer-body {
  gap: 8px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.event-quick-composer .composer-head { min-height: 0; }

.event-quick-composer .ref-panel {
  position: static;
  max-height: 280px;
  box-shadow: none;
}

.event-quick-composer textarea {
  min-height: 84px;
  max-height: 160px;
  padding: 10px;
  resize: vertical;
}

.event-quick-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.event-quick-actions .pill {
  min-width: 0;
  flex: 1;
}

.event-quick-actions select { width: 100%; min-width: 0; }

.event-quick-duration {
  flex: 0 0 auto;
  min-width: 104px;
}

.event-quick-duration-label { color: var(--ink-3); font-size: 11px; }

.event-quick-duration input {
  width: 44px;
  padding: 0;
  color: var(--ink);
  text-align: right;
  background: transparent;
  border: 0;
}

.event-quick-actions .composer-go {
  flex: none;
  min-height: 34px;
  padding: 7px 12px;
  margin-left: 0;
}

@media (max-width: 1280px) {
  .canvas { padding-bottom: 350px; }
  .canvas-hero { align-items: flex-start; }
  .composer { flex-direction: column; }
  .mode-strip { flex-direction: row; width: auto; }
  .mode-option { flex: 1; width: auto; min-height: 48px; flex-direction: row; gap: 7px; }
}

/* 720px คือจุดที่ sidebar ย้ายไปอยู่ด้านบน — แถบสั่งงานต้องเปลี่ยนที่จุดเดียวกัน */
@media (max-width: 720px) {
  .composer { right: 12px; bottom: 12px; left: 12px; }
  .canvas { padding-bottom: 400px; }
  .canvas-hero { flex-direction: column; gap: 18px; margin-bottom: 20px; }
  .canvas-toolbar { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .composer-go { width: 100%; margin-left: 0; justify-content: center; }
}

@media (max-width: 480px) {
  .canvas { padding-bottom: 32px; }
  .canvas-count { display: none; }
  .canvas-toolbar { justify-content: flex-end; }
  .composer {
    position: static;
    width: 100%;
    max-width: none;
    margin: 0 0 22px;
  }
  .composer-body { padding: 10px; }
  .mode-strip { padding: 4px; }
  .mode-option { min-height: 42px; }
  .composer textarea,
  .prompt-rich-editor { min-height: 72px; padding-right: 84px; resize: none; }
  .composer-enhance { right: 5px; }
  .round-btn[disabled] { display: none; }
}

/* ---------- Chat ---------- */
/* บทบาทใหม่: หนึ่งข้อความในบทสนทนา — ดู docs/recipes/ui-patterns.md หัวข้อ Chat */

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.chat-message {
  max-width: 640px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/* ข้อความของ user ชิดขวา ของ assistant ชิดซ้าย — แยกฝั่งให้เห็นชัดโดยไม่ต้อง
   อ่านป้าย role ทุกบรรทัด */
.chat-message.is-user { align-self: flex-end; background: var(--accent-soft); border-color: var(--accent-line); }
.chat-message.is-assistant { align-self: flex-start; }
.chat-message.is-failed { border-color: var(--danger-line); background: var(--danger-soft); }

.chat-message-role { margin: 0 0 4px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.chat-message-body { margin: 0; white-space: pre-wrap; color: var(--ink); }
.chat-message-error { margin: 6px 0 0; font-size: 12.5px; color: var(--danger-ink); }

.chat-composer { display: flex; gap: 8px; align-items: flex-start; }

.chat-composer textarea {
  flex: 1;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  resize: vertical;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.chat-composer textarea::placeholder { color: var(--ink-3); }
.chat-composer textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- credits (billing/) --------------------------------------------------- */

.credit-summary { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.credit-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.credit-stat-label { font-size: 13px; color: var(--ink-2); }
.credit-stat-value { font-size: 24px; font-variant-numeric: tabular-nums; }
.table th.num,
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.is-negative { color: var(--danger-ink); }
.pricing-rate { max-width: 240px; }
.table td.num .row-input { width: 96px; text-align: right; }

/* dashboard เงิน — แท่งรายวันกับแท่งในตาราง ใช้สีเดียว (accent) เพราะเป็นข้อมูลชุดเดียว */
.spend-chart { margin-bottom: 28px; }
.spend-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
}
.spend-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.spend-bar:hover .spend-bar-fill { background: var(--accent-hover); }
.spend-bar-fill {
  width: 100%;
  min-height: 3px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
}
.spend-axis { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.spend-breakdowns { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.spend-breakdown-title { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.spend-cell { width: 40%; }
.spend-inline { display: block; height: 8px; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; }
.credit-mine-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  margin-bottom: 20px;
  padding: 16px 20px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.credit-mine-card > div { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.credit-mine-card.is-empty { border-color: var(--line-strong); background: var(--surface); }
.credit-mine-card.is-out { border-color: var(--danger-line); background: var(--danger-soft); }
.credit-mine-note { flex: 1; min-width: 220px; margin: 0; color: var(--ink-2); font-size: 14px; }

/* credit ของฉันบนแถบบน — ต่อท้ายชื่อผู้ใช้ */
.topbar-actions a.credit-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--accent-line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.topbar-actions a.credit-pill:hover { color: var(--ink); border-color: var(--accent); }
.credit-pill-icon { width: 13px; height: 13px; color: var(--accent); }
.credit-pill-unit { color: var(--ink-2); }
.topbar-actions a.credit-pill.is-empty { background: transparent; border-color: var(--line-strong); color: var(--ink-3); }
.credit-pill.is-empty .credit-pill-icon { color: var(--ink-3); }
.topbar-actions a.credit-pill.is-out { border-color: var(--danger-line); background: var(--danger-soft); color: var(--danger-ink); }

/* ราคาบนปุ่ม Generate (static/js/credit-quote.js) — แดงเมื่อ credit ของฉันไม่พอ */
.go-cost {
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-ink) 14%, transparent);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.go-cost.is-short { background: var(--danger); color: #fff; }
.go-cost.is-unpriced { background: var(--ink-3); color: var(--ground); }
