/* ============================================================
   Ranny AutoAffiliate — ธีมเกราะเขียว–ทอง
   หน้านี้เลือกใช้โทนมืดโทนเดียวโดยตั้งใจ (ล้อกับโลโก้)
   ทุกสีจึงถูกระบุตรง ๆ ไม่พึ่งพื้นหลังของเบราว์เซอร์
   ============================================================ */

:root {
  --void: #050c09;
  --plate: #091510;
  --plate-2: #0d1e16;
  --plate-3: #12291d;
  --plate-hi: #17362447;

  --gold: #d8b451;
  --gold-bright: #f2d98f;
  --gold-deep: #a8853a;
  --gold-ghost: rgba(216, 180, 81, 0.14);
  --gold-line: rgba(216, 180, 81, 0.22);
  --gold-line-hi: rgba(216, 180, 81, 0.45);

  --emerald: #35b87a;
  --emerald-deep: #1b7048;
  --rust: #c4573f;
  --royal: #7f6ad0;

  --ink: #e9f0e9;
  --ink-dim: #9fb3a5;
  --ink-faint: #6a8175;

  --font-display: 'Cinzel', 'Bai Jamjuree', Georgia, serif;
  --font-ui: 'Bai Jamjuree', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Thai', 'Bai Jamjuree', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', monospace;

  --rail-w: 258px;
  --gap: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 78% -12%, rgba(53, 184, 122, 0.1), transparent 62%),
    radial-gradient(760px 520px at 6% 108%, rgba(216, 180, 81, 0.08), transparent 60%),
    var(--void);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-ui);
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

::selection {
  background: var(--gold);
  color: var(--void);
}

/* ---------- โลโก้ ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  flex: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  color: #2a1f06;
  background: linear-gradient(150deg, var(--gold-bright), var(--gold) 46%, var(--gold-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 2px 12px rgba(216, 180, 81, 0.28);
}

.brand__name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  color: #f3f7f2;
}

.brand__name em {
  font-style: normal;
  color: var(--emerald);
}

.brand__sub {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ============================================================
   ฟอร์มและปุ่ม (ใช้ร่วมกับหน้าเข้าสู่ระบบ)
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}

.field > label {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.field input {
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 12px 14px;
  color: var(--ink);
  background: #061009;
  border: 1px solid rgba(216, 180, 81, 0.18);
  border-radius: 2px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input::placeholder {
  color: #4b5f53;
}

.field input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 180, 81, 0.14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.02em;
  border: 1px solid var(--gold-deep);
  border-radius: 2px;
  color: #221904;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold) 52%, var(--gold-deep));
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn--ghost {
  color: var(--gold);
  background: transparent;
  border-color: var(--gold-line-hi);
}

.btn--ghost:hover {
  background: var(--gold-ghost);
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ============================================================
   โครงหน้าแดชบอร์ด
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- แถบเมนูซ้าย ---------- */

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 0 18px;
  background: linear-gradient(190deg, #0b1a12, #060f0a 62%);
  border-right: 1px solid var(--gold-line);
}

.rail__brand {
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(216, 180, 81, 0.12);
}

.rail__label {
  padding: 0 20px;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #4f6459;
}

.rail__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 10px;
}

.navlink {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px 11px 18px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-dim);
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
  width: 100%;
  transition: color 0.15s ease, background 0.15s ease;
}

.navlink:hover {
  color: var(--ink);
  background: rgba(216, 180, 81, 0.06);
}

.navlink.is-active {
  color: var(--gold-bright);
  border-left-color: var(--gold);
  background: linear-gradient(90deg, rgba(216, 180, 81, 0.16), transparent 82%);
}

.navlink__icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.navlink__count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 2px;
  color: var(--ink-faint);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(216, 180, 81, 0.12);
}

.navlink.is-active .navlink__count {
  color: var(--gold);
  border-color: var(--gold-line-hi);
}

.rail__foot {
  margin-top: auto;
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.usercard {
  padding: 13px 14px;
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  background: linear-gradient(160deg, rgba(216, 180, 81, 0.08), transparent);
}

.usercard__top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.usercard__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: #241a05;
  background: linear-gradient(150deg, var(--gold-bright), var(--gold-deep));
}

.usercard__name {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.usercard__user {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--gold);
}

.usercard__slots {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid rgba(216, 180, 81, 0.14);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-faint);
}

.usercard__slots b {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}

/* ---------- แถบหัวเรื่อง ---------- */

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 28px;
  background: rgba(6, 14, 10, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gold-line);
}

.topbar__title {
  min-width: 0;
}

.eyebrow {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.topbar__title h1 {
  font-size: 21px;
  line-height: 1.2;
}

.topbar__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search {
  position: relative;
  width: 240px;
}

.search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink);
  background: #071109;
  border: 1px solid rgba(216, 180, 81, 0.16);
  border-radius: 2px;
}

.search input::placeholder {
  color: #4b5f53;
}

.search input:focus {
  outline: none;
  border-color: var(--gold-line-hi);
}

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  stroke: var(--ink-faint);
  fill: none;
  stroke-width: 1.7;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12.5px;
  color: var(--ink-dim);
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  background: rgba(216, 180, 81, 0.05);
  white-space: nowrap;
}

.chip b {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

.chip--emerald b {
  color: var(--emerald);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
  flex: none;
}

/* ---------- พื้นที่เนื้อหา ---------- */

.well {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 56px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.view[hidden] {
  display: none;
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  animation: rise 0.28s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .view {
    animation: none;
  }
}

/* ---------- การ์ดเกราะ ---------- */

.plate {
  position: relative;
  padding: 18px 20px;
  background: linear-gradient(168deg, var(--plate-2), var(--plate));
  border: 1px solid rgba(216, 180, 81, 0.16);
  border-radius: 2px;
}

.plate::before,
.plate::after {
  content: '';
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1px solid var(--gold-line-hi);
  pointer-events: none;
}

.plate::before {
  top: -1px;
  left: -1px;
  border-right: 0;
  border-bottom: 0;
}

.plate::after {
  right: -1px;
  bottom: -1px;
  border-left: 0;
  border-top: 0;
}

.plate__head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.plate__head h2 {
  font-size: 16px;
}

.plate__head p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
}

.plate__head .spacer {
  margin-left: auto;
}

/* ---------- แถว KPI ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kpi__label {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.kpi__value {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

.kpi__value small {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-faint);
}

.kpi__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-dim);
}

.kpi--emerald .kpi__value {
  color: var(--emerald);
}

.kpi--rust .kpi__value {
  color: #e08c76;
}

.spark {
  width: 78px;
  height: 26px;
  flex: none;
}

.trend {
  font-family: var(--font-mono);
  font-size: 12px;
}

.trend--up {
  color: var(--emerald);
}

.trend--down {
  color: var(--rust);
}

/* ---------- โครงสองคอลัมน์ ---------- */

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

/* ---------- ตาราง ---------- */

.tablewrap {
  overflow-x: auto;
  margin: 0 -20px -18px;
  padding: 0 20px 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  white-space: nowrap;
}

thead th {
  padding: 0 14px 9px 0;
  text-align: left;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border-bottom: 1px solid rgba(216, 180, 81, 0.18);
}

tbody td {
  padding: 12px 14px 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background 0.14s ease;
}

tbody tr:hover {
  background: var(--plate-hi);
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.who {
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(155deg, #1c3d29, #102019);
  border: 1px solid var(--gold-line);
}

.who__name {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.25;
}

.who__user {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--gold);
}

/* ---------- แถบช่องล็อกอิน ---------- */

.slots {
  display: flex;
  align-items: center;
  gap: 9px;
}

.slots__pips {
  display: flex;
  gap: 3px;
}

.pip {
  width: 7px;
  height: 16px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.pip.on {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  border-color: var(--gold-deep);
  box-shadow: 0 0 6px rgba(216, 180, 81, 0.35);
}

.pip.full {
  background: linear-gradient(180deg, #56d99a, var(--emerald-deep));
  border-color: var(--emerald-deep);
  box-shadow: 0 0 6px rgba(53, 184, 122, 0.4);
}

.slots__text {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

.slots__text b {
  color: var(--ink);
  font-weight: 500;
}

/* ---------- ป้ายสถานะ ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid;
}

.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.pill--good {
  color: #6fdca8;
  border-color: rgba(53, 184, 122, 0.4);
  background: rgba(53, 184, 122, 0.1);
}

.pill--normal {
  color: var(--gold-bright);
  border-color: var(--gold-line-hi);
  background: rgba(216, 180, 81, 0.09);
}

.pill--warn {
  color: #e8907a;
  border-color: rgba(196, 87, 63, 0.45);
  background: rgba(196, 87, 63, 0.12);
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.04);
}

.tag--emerald {
  color: #6fdca8;
  border-color: rgba(53, 184, 122, 0.35);
  background: rgba(53, 184, 122, 0.09);
}

.tag--gold {
  color: var(--gold-bright);
  border-color: var(--gold-line-hi);
  background: rgba(216, 180, 81, 0.09);
}

.tag--royal {
  color: #b3a4f5;
  border-color: rgba(127, 106, 208, 0.4);
  background: rgba(127, 106, 208, 0.12);
}

/* ---------- แถบความคืบหน้า ---------- */

.bar {
  position: relative;
  width: 100%;
  min-width: 92px;
  height: 6px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--emerald-deep), var(--emerald));
}

.bar--gold > i {
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright));
}

.barline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.barline .num {
  font-size: 12.5px;
  color: var(--ink-dim);
  min-width: 38px;
  text-align: right;
}

/* ---------- ปุ่มเล็กในตาราง ---------- */

.mini {
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  transition: background 0.14s ease, border-color 0.14s ease;
}

.mini:hover {
  background: var(--gold-ghost);
  border-color: var(--gold-line-hi);
}

.mini--warn {
  color: #e8907a;
  border-color: rgba(196, 87, 63, 0.35);
}

.mini--warn:hover {
  background: rgba(196, 87, 63, 0.12);
}

.actions {
  display: flex;
  gap: 6px;
}

/* ---------- ฟีดกิจกรรม ---------- */

.feed {
  display: flex;
  flex-direction: column;
}

.feed__item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13.5px;
}

.feed__item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.feed__time {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  padding-top: 2px;
}

.feed__body {
  position: relative;
  padding-left: 14px;
  color: var(--ink-dim);
  line-height: 1.5;
  white-space: normal;
}

.feed__body::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.feed__item[data-kind='warn'] .feed__body::before {
  background: var(--rust);
}

.feed__item[data-kind='login'] .feed__body::before,
.feed__item[data-kind='join'] .feed__body::before {
  background: var(--emerald);
}

.feed__item[data-kind='lesson'] .feed__body::before {
  background: var(--royal);
}

/* ---------- กราฟแท่งรายสัปดาห์ ---------- */

.weekly {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  align-items: end;
  height: 148px;
  padding-top: 6px;
}

.weekly__col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  height: 100%;
  justify-content: flex-end;
}

.weekly__bar {
  width: 100%;
  max-width: 34px;
  border-radius: 1px 1px 0 0;
  background: linear-gradient(180deg, var(--gold), rgba(216, 180, 81, 0.16));
  border-top: 1px solid var(--gold-bright);
  transition: filter 0.15s ease;
}

.weekly__col:hover .weekly__bar {
  filter: brightness(1.25);
}

.weekly__day {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--ink-faint);
}

.weekly__val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-dim);
}

/* ---------- การ์ดโปรแกรม ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: var(--gap);
}

.program__top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.program__name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--gold-bright);
}

.program__ver {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
}

.program__desc {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--ink-dim);
  line-height: 1.55;
}

.program__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid rgba(216, 180, 81, 0.14);
  border-bottom: 1px solid rgba(216, 180, 81, 0.14);
}

.stat__k {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stat__v {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.program__features {
  list-style: none;
  margin: 13px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-dim);
}

.program__features li {
  display: flex;
  gap: 9px;
  align-items: baseline;
}

.program__features li::before {
  content: '◆';
  color: var(--gold-deep);
  font-size: 9px;
  flex: none;
}

/* ---------- เนื้อหาการเรียน ---------- */

.module {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.module__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(216, 180, 81, 0.18);
}

.module__no {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  border: 1px solid var(--gold-line-hi);
  border-radius: 2px;
}

.lesson {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lesson:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.lesson__title {
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 500;
}

.lesson__meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 2px;
}

.lesson__done {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-dim);
  min-width: 108px;
}

.lesson[data-published='false'] .lesson__title {
  color: var(--ink-faint);
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-faint);
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink-faint);
  transition: transform 0.16s ease, background 0.16s ease;
}

.switch input:checked + .switch__track {
  background: rgba(53, 184, 122, 0.25);
  border-color: rgba(53, 184, 122, 0.5);
}

.switch input:checked + .switch__track::after {
  transform: translateX(16px);
  background: var(--emerald);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ---------- Gem ---------- */

.gemhero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--gap);
  align-items: stretch;
}




.rank {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rank:last-child {
  border-bottom: 0;
}

.rank__no {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-faint);
  width: 22px;
  text-align: center;
  flex: none;
}

.rank:nth-child(1) .rank__no {
  color: var(--gold-bright);
}

.rank:nth-child(2) .rank__no {
  color: #cfd6cf;
}

.rank:nth-child(3) .rank__no {
  color: #c08a52;
}

.rank__gems {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}




.ledger__sub {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 2px;
}




.reward {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.reward:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.reward__name {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
}

.reward__stock {
  font-size: 12px;
  color: var(--ink-faint);
}


/* ---------- แจ้งเตือน ---------- */

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: 340px;
  padding: 13px 16px;
  font-size: 13.5px;
  color: var(--ink);
  background: linear-gradient(160deg, var(--plate-3), var(--plate));
  border: 1px solid var(--gold-line-hi);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
  animation: toastin 0.22s ease both;
}

.toast--error {
  border-left-color: var(--rust);
}

.toast[hidden] {
  display: none;
}

@keyframes toastin {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.empty {
  padding: 28px 0;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13.5px;
}

/* ---------- จอเล็ก ---------- */

@media (max-width: 1180px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split,
  .gemhero {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--gold-line);
  }

  .rail__brand {
    padding: 0 14px 0 0;
    border-bottom: 0;
    border-right: 1px solid rgba(216, 180, 81, 0.12);
  }

  .rail__label,
  .rail__foot {
    display: none;
  }

  .rail__nav {
    flex-direction: row;
    margin-top: 0;
  }

  .navlink {
    white-space: nowrap;
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 8px 12px;
  }

  .navlink.is-active {
    border-left: 0;
    border-bottom-color: var(--gold);
    background: rgba(216, 180, 81, 0.1);
  }

  .well,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .search {
    width: 150px;
  }

  .kpis {
    grid-template-columns: 1fr;
  }

  .lesson {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ============================================================
   ส่วนจัดการสมาชิก (เฉพาะแอดมิน) และมุมมองสมาชิก
   ============================================================ */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.navlink--admin {
  margin-top: 6px;
  border-top: 1px solid rgba(216, 180, 81, 0.12);
  padding-top: 13px;
}

.navlink--admin .navlink__icon {
  stroke: var(--gold);
}

/* ---------- ตัวควบคุมในตาราง ---------- */

.sel,
.numin,
textarea {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--ink);
  background: #071109;
  border: 1px solid rgba(216, 180, 81, 0.18);
  border-radius: 2px;
  padding: 7px 10px;
  transition: border-color 0.15s ease;
}

.sel:hover,
.numin:hover {
  border-color: var(--gold-line-hi);
}

.sel:focus,
.numin:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(216, 180, 81, 0.12);
}

.sel:disabled,
.numin:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sel {
  min-width: 108px;
}

.numin {
  width: 68px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.inline {
  display: flex;
  align-items: center;
  gap: 9px;
}

.hintline {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ---------- ฟอร์มเพิ่มโปรแกรม ---------- */

.formgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

.formgrid .field {
  margin-bottom: 14px;
}

.formgrid .field--wide {
  grid-column: 1 / -1;
}

.formgrid input,
.formgrid textarea,
.formgrid .sel {
  width: 100%;
}

.formgrid input {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 9px 12px;
}

/* ---------- คำขอสมัคร ---------- */

.requests {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
}

.request {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid rgba(216, 180, 81, 0.2);
  border-left: 3px solid var(--gold);
  background: rgba(216, 180, 81, 0.05);
  border-radius: 2px;
}

.request .actions {
  margin-left: auto;
  flex-direction: column;
}

.request__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 3px;
}

/* ---------- ตารางสิทธิ์ ---------- */

.matrix thead th {
  font-size: 10px;
  letter-spacing: 0.08em;
  padding-right: 10px;
  white-space: normal;
  max-width: 92px;
  vertical-align: bottom;
}

.matrix tbody td {
  padding-right: 10px;
}

.cell-mid {
  text-align: center;
}

.switch--bare {
  gap: 0;
}

.switch--bare .switch__track {
  margin: 0 auto;
}

/* ---------- การ์ดสิทธิ์ของสมาชิก ---------- */

.permgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 10px;
}

.perm {
  display: flex;
  gap: 11px;
  padding: 12px 13px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.02);
}

.perm.is-on {
  border-color: rgba(53, 184, 122, 0.32);
  background: rgba(53, 184, 122, 0.07);
}

.perm__dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

.perm.is-on .perm__dot {
  background: var(--emerald);
  box-shadow: 0 0 8px rgba(53, 184, 122, 0.55);
}

.perm__label {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-dim);
}

.perm.is-on .perm__label {
  color: var(--ink);
}

.perm__desc {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.5;
  margin-top: 2px;
}

@media (max-width: 860px) {
  .formgrid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   กลุ่มเมนู “ช่องทาง” และหน้าช่องรายแพลตฟอร์ม
   ============================================================ */

.rail__group--split {
  padding-top: 16px;
  border-top: 1px solid rgba(216, 180, 81, 0.14);
}

/* ---------- แถบเลือกแพลตฟอร์ม ---------- */

.platformbar {
  display: flex;
  gap: 4px;
  padding: 5px;
  overflow-x: auto;
  background: linear-gradient(168deg, var(--plate-2), var(--plate));
  border: 1px solid rgba(216, 180, 81, 0.16);
  border-radius: 999px;
  scrollbar-width: thin;
}

.ptab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  flex: none;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-dim);
  background: none;
  border: 0;
  border-radius: 999px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
}

.ptab svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ptab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
}

.ptab.is-active {
  color: #06251a;
  background: linear-gradient(160deg, #52d99b, var(--emerald) 60%, var(--emerald-deep));
  box-shadow: 0 2px 14px rgba(53, 184, 122, 0.3);
}

.ptab.is-active:hover {
  color: #06251a;
}

.ptab__soon {
  font-family: var(--font-mono);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  padding: 0 5px;
}

.ptab.is-active .ptab__soon {
  color: #06251a;
  border-color: rgba(6, 37, 26, 0.35);
}

/* ---------- ไอคอนช่องในตาราง ---------- */

.avatar--platform {
  background: linear-gradient(155deg, #16382a, #0c1c15);
  border-color: rgba(53, 184, 122, 0.35);
}

.avatar--platform svg {
  width: 17px;
  height: 17px;
  stroke: var(--emerald);
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 860px) {
  .rail__group {
    display: contents;
  }

  .rail__group--split {
    border-top: 0;
    padding-top: 0;
  }
}

/* ============================================================
   คลัง Gem — การ์ด Gem, กรอบแนบภาพ, กล่องผลลัพธ์, ประวัติผลงาน
   ============================================================ */

/* ปุ่มขวาสุดของหัวแผ่น — ดันไปชิดขวาให้อัตโนมัติ */
.plate__head > div:first-child + * {
  margin-left: auto;
}

.btn--sm {
  padding: 8px 14px;
  font-size: 12px;
}

.notice {
  padding: 11px 14px;
  margin-bottom: var(--gap);
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-dim);
  border: 1px solid var(--gold-line);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
  background: rgba(216, 180, 81, 0.06);
}
.notice b {
  color: var(--gold-bright);
}
.notice code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gold-bright);
}
.notice--soft {
  margin: 0 0 12px;
  border-left-color: var(--ink-faint);
  background: rgba(159, 179, 165, 0.06);
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-faint);
  text-align: center;
}

/* ---------- กริดการ์ด Gem ---------- */

.gemgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 12px;
}

.gemcard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 15px 16px;
  border: 1px solid rgba(216, 180, 81, 0.18);
  border-top: 2px solid var(--gold);
  border-radius: 2px;
  background: linear-gradient(168deg, var(--plate-3), var(--plate-2));
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.gemcard:hover {
  border-color: var(--gold-line-hi);
  transform: translateY(-2px);
}
.gemcard--emerald {
  border-top-color: var(--emerald);
}
.gemcard--royal {
  border-top-color: var(--royal);
}
.gemcard.is-draft {
  opacity: 0.62;
  border-top-style: dashed;
}

.gemcard__top {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}
.gemcard__icon {
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  background: var(--gold-ghost);
}
.gemcard__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--gold-bright);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gemcard--emerald .gemcard__icon svg {
  stroke: var(--emerald);
}
.gemcard--royal .gemcard__icon svg {
  stroke: var(--royal);
}
.gemcard__id {
  min-width: 0;
}
.gemcard__name {
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}
.gemcard__tagline {
  margin-top: 2px;
  font-size: 12px;
  color: var(--gold);
}
.gemcard__top .tag {
  margin-left: auto;
  flex: 0 0 auto;
}

.gemcard__desc {
  flex: 1;
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-dim);
}

.gemcard__foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 11px;
  border-top: 1px dashed rgba(216, 180, 81, 0.16);
}
.gemcard__uses {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-right: auto;
}

.gemgrid--locked .gemcard {
  opacity: 0.55;
}

/* ---------- กรอบแนบภาพ ---------- */

.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 210px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  border: 1px dashed var(--gold-line-hi);
  border-radius: 2px;
  background: rgba(216, 180, 81, 0.04);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover,
.dropzone.is-over {
  border-color: var(--gold);
  background: rgba(216, 180, 81, 0.1);
}
.dropzone.is-filled {
  padding: 12px;
  border-style: solid;
}
.dropzone__icon {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dropzone__title {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
}
.dropzone__hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.dropzone__img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 2px;
}
.dropzone__name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-faint);
  word-break: break-all;
}

/* ---------- กล่องผลลัพธ์ ---------- */

.gemhero--single {
  grid-template-columns: minmax(0, 1fr);
}

.gemout__wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gemout {
  flex: 1;
  margin: 0;
  padding: 15px 16px;
  max-height: 460px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(216, 180, 81, 0.16);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
  background: #061009;
}
.gemout--error {
  border-left-color: var(--rust);
  color: #e7b3a6;
}

/* ช่องตอบกลับ Gem — โผล่เมื่อ Gem ถามกลับก่อนให้พร้อมพ์จริง */
.gemreply {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(216, 180, 81, 0.16);
}
.gemreply label {
  display: block;
  margin: 12px 0 6px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--ink-dim);
}
.gemreply textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: #061009;
  border: 1px solid rgba(216, 180, 81, 0.16);
  border-radius: 2px;
  resize: vertical;
}
.gemreply textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.gemreply textarea:disabled {
  opacity: 0.55;
}

.thinking {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 180px;
}
.thinking span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  animation: thinkpulse 1.1s ease-in-out infinite;
}
.thinking span:nth-child(2) {
  animation-delay: 0.16s;
}
.thinking span:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes thinkpulse {
  0%, 100% {
    opacity: 0.22;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* ---------- ประวัติผลงาน ---------- */

.jobrow {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(216, 180, 81, 0.1);
}
.jobrow:last-child {
  border-bottom: 0;
}
.jobrow__thumb {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  object-fit: cover;
  border: 1px solid var(--gold-line);
  border-radius: 2px;
  background: #061009;
}
.jobrow__main {
  flex: 1;
  min-width: 0;
}
.jobrow__name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.jobrow__meta {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.jobrow__text {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-dim);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.jobrow__side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  flex: 0 0 auto;
}

@media (max-width: 1100px) {
  .gemgrid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 760px) {
  .jobrow {
    flex-wrap: wrap;
  }
  .jobrow__side {
    flex-direction: row;
    align-items: center;
    width: 100%;
  }
  .dropzone {
    min-height: 170px;
  }
}

/* เช็คบ็อกซ์ในฟอร์มไม่ควรโดนยืดเต็มความกว้างเหมือนช่องกรอกอื่น */
.formgrid .field > .inline {
  flex-direction: row;
  align-items: center;
  text-transform: none;
  letter-spacing: normal;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink-dim);
  cursor: pointer;
}
.formgrid input[type='checkbox'] {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  accent-color: var(--gold);
}

.actions--spread {
  align-items: center;
  justify-content: space-between;
}
