/* theailand-idea — ใช้ design token ร่วมจาก theailand-core (/core/tokens.css · navy+gold+chrome)
   dark/light = tokens.css จัดการผ่าน data-theme + prefers-color-scheme (ไม่ override ที่นี่)
   ฟอนต์: Anuphan หัว · Sarabun เนื้อ (family-consistent กับ Spine) */
:root { --radius-lg: 20px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Sarabun", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
h1, h2 { font-family: "Anuphan", "Sarabun", sans-serif; font-weight: 700; letter-spacing: -0.01em; }
.wrap { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 18px; }

/* header */
.site-header { padding: 22px 0 8px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 2rem; line-height: 1; }
.brand h1 { margin: 0; font-size: 1.6rem; color: var(--c-navy); }
:root[data-theme="dark"] .brand h1 { color: var(--c-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .brand h1 { color: var(--c-text); } }
.tagline { margin: 2px 0 0; color: var(--c-text-muted); font-size: 0.95rem; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--c-text-muted); }
.user-email { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 0.85rem; color: var(--c-primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* panel */
.panel {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 20px; margin: 16px 0;
}
.howto { margin: 0 0 14px; color: var(--c-text-muted); font-size: 0.98rem; }

textarea {
  width: 100%; min-height: 116px; resize: vertical;
  border: 1px solid var(--c-border); border-radius: 14px;
  background: var(--c-surface-2); color: var(--c-text);
  padding: 14px 16px; font: inherit;
  outline: 2px solid transparent; transition: outline-color .15s, border-color .15s;
}
textarea:focus { outline-color: color-mix(in srgb, var(--c-gold) 55%, transparent); border-color: var(--c-gold); }

/* buttons */
.actions { display: flex; gap: 10px; margin-top: 14px; }
.btn {
  border: 0; border-radius: 12px; padding: 13px 18px; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { flex: 1; background: linear-gradient(180deg, var(--c-navy-2), var(--c-navy)); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: var(--c-navy-2); }
.btn-mic { background: var(--c-surface-2); color: var(--c-text); border: 1px solid var(--c-border); min-width: 96px; }
.btn-mic .mic-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c-text-muted); transition: background .2s; }
.btn-mic.is-listening { border-color: var(--c-danger); color: var(--c-danger); }
.btn-mic.is-listening .mic-dot { background: var(--c-danger); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(1.4); } }
.hint { margin: 10px 0 0; font-size: 0.88rem; color: var(--c-text-muted); min-height: 1.2em; }
.hint.is-error { color: var(--c-danger); }

/* list + table (mobile-first · responsive) */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.list-head h2 { margin: 0; font-size: 1.2rem; }
.count { color: var(--c-text-muted); font-size: 0.9rem; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.idea-table { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
.idea-table thead th {
  text-align: left; font-family: "Anuphan", "Sarabun", sans-serif; font-weight: 600;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--c-text-muted); padding: 0 10px 8px; border-bottom: 1px solid var(--c-border);
}
.idea-table tbody td { padding: 12px 10px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.idea-table tbody tr:last-child td { border-bottom: 0; }
.idea-table tbody tr:hover td { background: var(--c-surface-2); }
.col-text { width: 100%; }
.idea-text { white-space: pre-wrap; word-break: break-word; }
.col-date, .col-time { white-space: nowrap; color: var(--c-text-muted); font-size: 0.85rem; text-align: right; }
.col-date { padding-left: 14px !important; }
.empty { color: var(--c-text-muted); text-align: center; padding: 16px 0; }

/* login gate */
.gate h2 { margin: 0 0 8px; font-size: 1.25rem; }
.consent { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; font-size: 0.95rem; color: var(--c-text); cursor: pointer; }
.consent input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--c-gold); }
.consent a { color: var(--c-primary); }
.gbtn-wrap { display: flex; justify-content: center; min-height: 44px; margin: 6px 0; transition: opacity .15s; }
.gbtn-wrap.gated { opacity: .4; pointer-events: none; filter: grayscale(.6); }

/* paywall (ปิดอยู่ free mode) */
.paywall h2 { margin: 0 0 6px; }
.sub-info .ref { font-size: .85rem; color: var(--c-text-muted); }
.sub-info code { word-break: break-all; }

/* policy pages */
.legal { line-height: 1.7; }
.legal h1 { font-size: 1.5rem; margin: 0 0 4px; color: var(--c-navy); }
:root[data-theme="dark"] .legal h1 { color: var(--c-text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .legal h1 { color: var(--c-text); } }
.legal h2 { font-size: 1.1rem; margin: 22px 0 6px; }
.legal .updated { color: var(--c-text-muted); font-size: 0.85rem; margin: 0 0 16px; }
.legal ul { padding-left: 20px; margin: 8px 0; }
.legal li { margin: 5px 0; }
.legal a { color: var(--c-primary); }
.legal .back { display: inline-block; margin-top: 24px; color: var(--c-primary); text-decoration: none; font-weight: 600; }

/* footer */
.site-footer { padding: 22px 0 36px; text-align: center; color: var(--c-text-muted); font-size: 0.88rem; }
.brand-link { color: var(--c-primary); text-decoration: none; font-weight: 600; }
.brand-link:hover { text-decoration: underline; }
.footer-links { margin: 8px 0 0; }
.footer-links a { color: var(--c-text-muted); text-decoration: none; }
.footer-links a:hover { text-decoration: underline; color: var(--c-primary); }

/* admin */
.admin-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 18px; }
.stat { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 12px 16px; flex: 1; min-width: 120px; }
.stat .num { font-size: 1.6rem; font-weight: 700; font-family: "Anuphan", sans-serif; color: var(--c-navy); }
:root[data-theme="dark"] .stat .num { color: var(--c-gold); }
.stat .lbl { color: var(--c-text-muted); font-size: 0.82rem; }
.stat.warn .num { color: var(--c-danger); }
.flag { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin: 0 4px 4px 0; background: color-mix(in srgb, var(--c-danger) 18%, transparent); color: var(--c-danger); }
.flag--ok { background: color-mix(in srgb, var(--c-success) 18%, transparent); color: var(--c-success); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; color: var(--c-text-muted); word-break: break-all; }
tr.suspicious td { background: color-mix(in srgb, var(--c-danger) 8%, transparent); }
.admin-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-btn { border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text); border-radius: 999px; padding: 7px 16px; font: inherit; cursor: pointer; }
.tab-btn.active { background: var(--c-navy); color: #fff; border-color: var(--c-navy); }
.admin-gate { text-align: center; padding: 30px 0; color: var(--c-text-muted); }
