/* =========================================================
   BIM AI — design system
   Restrained editorial UI: solid fills, 1px rules, one accent.
   No gradients, no glass effects.
   ========================================================= */

:root {
  --paper: #ffffff;
  --surface: #f7f7f4;
  --surface-2: #efefeb;
  --ink: #17181a;
  --ink-2: #3f4145;
  --muted: #737576;
  --muted-2: #9a9c9d;
  --rule: #e2e2dd;
  --rule-strong: #cfcfc9;

  --accent: #23507a;
  --accent-hover: #1b3f61;
  --accent-soft: #eef3f8;

  --sidebar: #14161a;
  --sidebar-2: #1c1f24;
  --sidebar-ink: #e6e7e9;
  --sidebar-muted: #8d9198;
  --sidebar-rule: #262a30;

  --ok: #2f7d5a;
  --ok-soft: #eaf4ef;
  --warn: #9a6a12;
  --warn-soft: #fbf3e2;
  --danger: #a8322b;
  --danger-soft: #fbeeed;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(23, 24, 26, 0.06);
  --shadow-md: 0 6px 20px rgba(23, 24, 26, 0.1);

  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "Courier New", monospace;

  --sidebar-w: 268px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.018em;
  line-height: 1.25;
  font-weight: 600;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #d4d4ce;
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: #b8b8b1;
  background-clip: content-box;
}

/* ============================== CONTROLS ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 550;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--ink-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  color: #a8322b;
  border-color: #e0c4c2;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}

.btn-quiet:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: transparent;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 6px;
}

.btn.is-busy {
  color: transparent;
  position: relative;
}

.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  color: #fff;
}

.btn:not(.btn-primary).is-busy::after {
  color: var(--ink);
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
}

.field input,
.field select,
.field textarea,
.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  font-size: 14px;
  font-weight: 400;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field input:disabled,
.field input:read-only {
  background: var(--surface);
  color: var(--muted);
}

.field small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}

.input-wrap {
  position: relative;
}

.input-wrap input {
  padding-right: 40px;
}

.eye {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.eye:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: var(--rule-strong);
  position: relative;
  transition: background 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(14px);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.toggle-row-text strong {
  display: block;
  font-size: 13.5px;
  font-weight: 550;
}

.toggle-row-text small {
  font-size: 12px;
  color: var(--muted);
}

.notice {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  font-size: 13px;
  margin-bottom: 14px;
}

.notice.error {
  border-color: #e3c9c7;
  background: var(--danger-soft);
  color: #7e2621;
}

.notice.success {
  border-color: #c6ded2;
  background: var(--ok-soft);
  color: #1f5c42;
}

.notice.warn {
  border-color: #e6d5ae;
  background: var(--warn-soft);
  color: #7a540e;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.badge.owner {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.badge.admin {
  background: var(--accent-soft);
  border-color: #c6d8e7;
  color: var(--accent);
}

.badge.vip {
  background: var(--warn-soft);
  border-color: #e2d0a6;
  color: var(--warn);
}

.badge.member {
  background: var(--surface-2);
  color: var(--muted);
}

/* ====================== PER-ACCOUNT CONFIGURATION ======================= */

.tool-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tool-toggle .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.tool-toggle.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.tool-toggle.on .dot {
  opacity: 1;
}

.tool-toggle[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.tool-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.tool-toggle.on .tool-count {
  color: var(--accent);
}

.edit-box {
  margin: 8px 0 0;
}

.edit-box textarea {
  width: 100%;
  min-height: 62px;
  resize: vertical;
}

/* ================================ AUTH ================================ */

.auth-page {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 520px);
  background: var(--surface);
}

.auth-intro {
  padding: 56px 56px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--rule);
  background: var(--paper);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 17px;
}

.wordmark .mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
  font-weight: 700;
}

.auth-intro h1 {
  font-size: 34px;
  max-width: 22ch;
  margin: 0;
}

.auth-intro .lede {
  margin: 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 14.5px;
}

.spec-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  margin: 0;
  padding: 24px 0 0;
  border-top: 1px solid var(--rule);
  list-style: none;
}

.spec-list li {
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
}

.spec-list .num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted-2);
  padding-top: 2px;
}

.tier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 4px;
}

.tier-table th,
.tier-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--rule);
}

.tier-table th {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.tier-table td:first-child {
  font-weight: 600;
}

.auth-form-col {
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.pane {
  display: none;
}

.pane.active {
  display: block;
}

.pane h2 {
  margin: 0 0 6px;
  font-size: 23px;
}

.pane .sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13.5px;
}

.rule-split {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted-2);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.rule-split::before,
.rule-split::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.foot-switch {
  margin: 22px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
}

.text-btn {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: inherit;
}

.text-btn:hover {
  text-decoration: underline;
}

.meter {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.meter-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter-track i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--rule-strong);
  transition: width 0.2s ease;
}

.meter-label {
  font-size: 11.5px;
  color: var(--muted);
}

.contact-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  color: var(--muted);
}

.contact-inline a {
  color: var(--ink-2);
  font-weight: 550;
}

/* =============================== MODAL =============================== */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 24, 26, 0.45);
}

.dialog {
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.dialog.wide {
  max-width: 720px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-head h3 {
  margin: 0;
  font-size: 17px;
}

.dialog-head p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.dialog-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.dialog-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}

.tab {
  padding: 9px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--muted);
}

.tab:hover {
  color: var(--ink);
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.account-grid {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}

.account-grid div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}

.account-grid div:last-child {
  border-bottom: 0;
}

.account-grid div > span:first-child {
  color: var(--muted);
}

.account-grid div > span:last-child {
  text-align: right;
  overflow-wrap: anywhere;
}

/* ============================== APP SHELL ============================== */

.app-body {
  height: 100%;
  overflow: hidden;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100%;
}

/* The sidebar is an off-canvas drawer on every screen size: the hamburger
   opens it, the cross (or a leftward swipe) closes it. */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 14px 12px;
  gap: 12px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(var(--sidebar-w), 86vw);
  z-index: 80;
  overflow-y: auto;
  transform: translateX(-102%);
  transition: transform 0.24s ease;
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-md);
}

.sidebar .wordmark {
  padding: 2px 6px 8px;
  color: var(--sidebar-ink);
}

.wordmark .logo {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 6px;
  object-fit: cover;
}

.sidebar-head {
  display: flex;
  align-items: center;
}

.sidebar-close {
  display: grid;
  margin-left: auto;
}

.side-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  text-align: left;
}

.side-item:hover {
  background: var(--sidebar-2);
  color: var(--sidebar-ink);
}

.side-item.active {
  background: var(--sidebar-2);
  color: var(--sidebar-ink);
  font-weight: 550;
}

.side-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--sidebar-muted);
  font-variant-numeric: tabular-nums;
}

.side-label {
  padding: 14px 10px 6px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  font-weight: 650;
}

.new-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--sidebar-rule);
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-ink);
  font-size: 13.5px;
  font-weight: 550;
}

.new-btn:hover {
  background: var(--sidebar-2);
  border-color: #3a4048;
}

.history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-right: 2px;
}

.history::-webkit-scrollbar-thumb {
  background: var(--rule-strong);
  background-clip: content-box;
}

.hist {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px 7px 10px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  width: 100%;
}

.hist:hover {
  background: var(--sidebar-2);
  color: var(--sidebar-ink);
}

.hist.active {
  background: var(--sidebar-2);
  color: var(--sidebar-ink);
}

.hist-body {
  flex: 1;
  min-width: 0;
}

.hist-title {
  display: block;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-meta {
  display: block;
  font-size: 10.5px;
  color: var(--sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hist-del {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--sidebar-muted);
  opacity: 0;
}

.hist:hover .hist-del,
.hist.active .hist-del {
  opacity: 1;
}

.hist-del:hover {
  background: var(--sidebar-2);
  color: var(--sidebar-ink);
}

.side-empty {
  padding: 14px 10px;
  font-size: 12px;
  color: var(--sidebar-muted);
  line-height: 1.6;
}

.side-foot {
  border-top: 1px solid var(--sidebar-rule);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quota-box {
  padding: 10px;
  border: 1px solid var(--sidebar-rule);
  border-radius: 6px;
}

.quota-box .qhead {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--sidebar-muted);
  margin-bottom: 8px;
}

.quota-box .qhead strong {
  color: var(--sidebar-ink);
  font-weight: 550;
}

.qrows {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.qrow {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--sidebar-muted);
}

.qrow .track {
  height: 3px;
  border-radius: 2px;
  background: var(--sidebar-rule);
  overflow: hidden;
}

.qrow .track i {
  display: block;
  height: 100%;
  background: var(--sidebar-muted);
}

.qrow.locked {
  opacity: 0.5;
}

.qrow .val {
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
}

.avatar {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #333944;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
}

.user-row .who {
  min-width: 0;
  flex: 1;
}

.user-row .who strong {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--sidebar-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-row .who small {
  font-size: 10.5px;
  color: var(--sidebar-muted);
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-muted);
}

.icon-btn:hover {
  background: var(--sidebar-2);
  color: var(--sidebar-ink);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: block;
  background: rgba(23, 24, 26, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.scrim.open {
  opacity: 1;
  pointer-events: auto;
}

/* ================================ MAIN ================================ */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--paper);
  /* The decorative layer is wider than the viewport on purpose. Clipping the
     horizontal axis here keeps that decoration from ever adding a sideways
     scroll, while the panels keep scrolling vertically as usual. `clip` is used
     instead of `hidden` so no scroll container is created. */
  overflow-x: clip;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  z-index: 20;
}

.menu-btn {
  display: grid;
}

.select-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
}

.select-btn:hover {
  background: var(--surface);
}

.select-btn .sub {
  color: var(--muted);
  font-weight: 400;
}

.popover-host {
  position: relative;
}

.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 300px;
  max-height: min(420px, 68vh);
  overflow-y: auto;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.popover.right {
  left: auto;
  right: 0;
}

.pop-label {
  padding: 8px 9px 4px;
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.pop-item {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.pop-item:hover {
  background: var(--surface);
}

.pop-item.active {
  background: var(--accent-soft);
}

.pop-item .dot {
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  flex: none;
}

.pop-item .txt {
  min-width: 0;
}

.pop-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.pop-item small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.pop-item.disabled {
  opacity: 0.55;
}

.topbar-spacer {
  flex: 1;
}

.tb-note {
  font-size: 11.5px;
  color: var(--muted);
}

/* ================================ CHAT ================================ */

.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.thread {
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 20px 8px;
}

.welcome {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 20px;
  gap: 10px;
}

.welcome h1 {
  margin: 0;
  font-size: 27px;
}

.welcome p {
  margin: 0;
  color: var(--muted);
  max-width: 60ch;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  margin-top: 14px;
}

.tile {
  padding: 11px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  text-align: left;
}

.tile:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tile strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}

.tile small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.chip {
  padding: 6px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper);
  font-size: 12.5px;
  color: var(--ink-2);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.msg {
  padding: 14px 0;
  border-bottom: 1px solid var(--rule);
}

.msg:last-child {
  border-bottom: 0;
}

.msg.user {
  display: flex;
  justify-content: flex-end;
  border-bottom: 0;
  padding: 12px 0;
}

.bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.user-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 78%;
}

.user-col .bubble {
  max-width: 100%;
}

.user-col .files {
  justify-content: flex-end;
  margin-bottom: 0;
}

.msg.ai {
  display: flex;
  gap: 12px;
}

.ai-mark {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
  overflow: hidden;
}

.ai-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.ai-body {
  flex: 1;
  min-width: 0;
}

.ai-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-head .who {
  font-size: 12.5px;
  font-weight: 600;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 10.5px;
  color: var(--muted);
  background: var(--surface);
}

.prose {
  font-size: 14.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose p {
  margin: 0 0 11px;
}

.prose h2,
.prose h3,
.prose h4 {
  margin: 18px 0 8px;
  font-size: 15px;
}

.prose ul,
.prose ol {
  margin: 8px 0 12px;
  padding-left: 20px;
}

.prose li {
  margin: 3px 0;
}

.prose code {
  padding: 1px 5px;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.87em;
}

.prose pre {
  margin: 10px 0;
  padding: 13px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: #1b1d21;
  overflow-x: auto;
}

.prose pre code {
  border: 0;
  background: none;
  padding: 0;
  color: #d8dade;
  font-size: 12.5px;
  line-height: 1.6;
}

.prose blockquote {
  margin: 10px 0;
  padding: 8px 13px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--ink-2);
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 10px 0;
}

.prose th,
.prose td {
  border: 1px solid var(--rule);
  padding: 6px 9px;
  text-align: left;
}

/* Rendered maths. KaTeX supplies the glyphs; these rules only fit them in. */
.prose .katex {
  font-size: 1.04em;
}

.prose .katex-display {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
  overflow-y: hidden;
}

.prose .katex-display > .katex {
  white-space: normal;
}

.math-block {
  margin: 12px 0;
  overflow-x: auto;
}

.math-block .katex-display {
  margin: 0;
}

/* A formula that is too wide scrolls instead of breaking the layout. */
.prose .katex-html {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
}

.files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  max-width: 300px;
}

.file-card img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--rule);
}

.file-card .fc-body {
  min-width: 0;
}

.file-card strong {
  display: block;
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card small {
  color: var(--muted);
  font-size: 10.5px;
}

.thinking {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 13px 14px;
  background: var(--surface);
  margin-bottom: 12px;
}

.thinking-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 10px;
}

.thinking-label {
  background: linear-gradient(90deg, var(--ink) 0%, var(--muted) 45%, var(--ink) 90%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmerText 2.6s linear infinite;
}

@keyframes shimmerText {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

/* Three dots orbiting a centre — reads as "searching", not a countdown. */
.orbit {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  border: 1px solid var(--rule);
}

.orbit i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: var(--accent);
  animation: orbit 1.5s linear infinite;
}

.orbit i:nth-child(2) { animation-delay: -0.5s; opacity: 0.7; }
.orbit i:nth-child(3) { animation-delay: -1s; opacity: 0.45; }

@keyframes orbit {
  0% { transform: rotate(0deg) translateX(7px) rotate(0deg); }
  100% { transform: rotate(360deg) translateX(7px) rotate(-360deg); }
}

/* A light sweeping across the panel while sources are being read. */
.thinking-scan {
  position: relative;
  height: 2px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
  margin-bottom: 12px;
}

.thinking-scan i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: scan 1.6s ease-in-out infinite;
}

@keyframes scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

.thinking-sources {
  margin-top: 10px;
}

.src-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.src-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-2);
  font-size: 11.5px;
  text-decoration: none;
  animation: chipIn 0.35s ease both;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.src-chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.src-chip .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 5px;
}

/* The count and the remainder are labels, not links, so they never pretend to
   be a source. */
.src-count,
.src-more {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.src-count {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}

.src-more {
  border: 1px dashed var(--rule-strong);
  color: var(--muted);
}

.src-chips.hidden,
.thinking-sources:empty {
  display: none;
}

@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Source photos found on the web. */
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.img-grid.single {
  grid-template-columns: minmax(0, 420px);
}

.img-card {
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.img-frame {
  position: relative;
  display: block;
  line-height: 0;
}

.img-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.img-dl {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(16, 18, 22, 0.62);
  color: #fff;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.18s ease, background 0.18s ease;
}

.img-card:hover .img-dl,
.img-dl:focus-visible {
  opacity: 1;
}

.img-dl:hover {
  background: rgba(16, 18, 22, 0.85);
}

.img-src {
  align-self: flex-start;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--accent);
  text-decoration: none;
}

.img-src:hover {
  text-decoration: underline;
}

.img-card img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.img-card:hover img {
  transform: scale(1.03);
}

.img-card figcaption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--ink-2);
  line-height: 1.35;
}

.img-card figcaption span {
  font-weight: 400;
  font-size: 10.5px;
  color: var(--muted);
}

/* Collapsible source list under a finished answer. */
.src-list {
  margin: 10px 0 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
}

.src-list summary {
  cursor: pointer;
  padding: 8px 11px;
  font-weight: 600;
  color: var(--ink-2);
  list-style: none;
}

.src-list summary::-webkit-details-marker {
  display: none;
}

.src-list summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 7px;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.src-list[open] summary::before {
  transform: rotate(90deg);
}

.src-list ol {
  margin: 0;
  padding: 0 12px 10px 30px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.src-list li {
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.src-list li a {
  color: var(--accent);
  text-decoration: none;
}

.src-list li a:hover {
  text-decoration: underline;
}

.src-list li span {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
}

/* Character-by-character reveal for a finished answer. */
.prose .word {
  display: inline-block;
  white-space: nowrap;
}

.prose .w {
  display: inline-block;
  transition: opacity 0.12s ease, transform 0.12s ease, filter 0.12s ease;
}

.prose.typing .w {
  opacity: 0;
  transform: translateY(3px);
  filter: blur(1.5px);
}

.prose.typing .w.on {
  opacity: 1;
  transform: none;
  filter: none;
}

.prose .caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.16em;
  background: var(--accent);
  animation: caretBlink 0.9s steps(1) infinite;
}

@keyframes caretBlink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .prose .w,
  .src-chip,
  .thinking-label,
  .orbit i,
  .thinking-scan i {
    animation: none !important;
    opacity: 1;
    transform: none;
    filter: none;
    color: inherit;
    background: none;
    -webkit-text-fill-color: currentColor;
  }

  .prose .caret {
    display: none;
  }
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--muted);
}

.step {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.step-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.step-label {
  overflow-wrap: anywhere;
}

.step-detail {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.step .n {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted-2);
  min-width: 14px;
}

.step.done .n {
  color: var(--accent);
}

.step.done {
  color: var(--ink-2);
}

.step.now {
  color: var(--ink);
  font-weight: 550;
}

.step.now .step-detail {
  color: var(--ink-2);
}

.prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(120, 120, 120, 0.35);
  overflow-wrap: anywhere;
}

.prose a:hover {
  border-bottom-color: var(--accent);
}

.prose ol li {
  margin: 4px 0;
}

.reason {
  margin-bottom: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
}

.reason summary {
  cursor: pointer;
  padding: 9px 12px;
  font-weight: 600;
  color: var(--ink-2);
  list-style: none;
}

.reason summary::-webkit-details-marker {
  display: none;
}

.reason summary::before {
  content: "▸ ";
  color: var(--muted);
}

.reason[open] summary::before {
  content: "▾ ";
}

.reason .reason-body {
  padding: 0 12px 11px;
  color: var(--muted);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.reason .reason-body p,
.reason .reason-body ul,
.reason .reason-body ol {
  margin: 0 0 7px;
}

.reason .reason-body ul,
.reason .reason-body ol {
  padding-left: 18px;
}

.reason .reason-body > *:last-child {
  margin-bottom: 0;
}

.reason .reason-body strong {
  color: var(--ink-2);
}

.msg-tools {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

.tool {
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 11.5px;
  color: var(--muted);
}

.tool:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.generated {
  display: block;
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--surface);
}

/* ------------------------------ composer ------------------------------ */

.composer-area {
  padding: 10px 16px 16px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
}

.composer {
  max-width: 760px;
  margin: 0 auto;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  background: var(--paper);
  padding: 8px 8px 6px 12px;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.composer textarea {
  display: block;
  width: 100%;
  border: 0;
  outline: none;
  resize: none;
  min-height: 22px;
  max-height: 180px;
  padding: 6px 0;
  font-size: 14.5px;
  line-height: 1.55;
  background: transparent;
}

.composer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 6px 0 2px;
}

.att-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
  font-size: 11.5px;
}

.att-chip img {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 3px;
}

.att-chip button {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.hint {
  font-size: 11px;
  color: var(--muted-2);
  margin-left: auto;
}

.send {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}

.send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send:disabled {
  background: var(--rule-strong);
  cursor: not-allowed;
}

/* Stop button: shown while the AI is still working. */
.send.stop {
  background: var(--danger);
}

.send.stop:hover:not(:disabled) {
  background: #8f2a24;
}

.quota-strip {
  max-width: 760px;
  margin: 8px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}

.quota-strip span {
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}

/* ============================== INBOX ============================== */

.panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.panel-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.panel-inner h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.panel-inner .lede {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13.5px;
}

.dm-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.dm {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 11px 13px;
  background: var(--paper);
  max-width: 78%;
}

.dm.mine {
  align-self: flex-end;
  background: var(--accent-soft);
  border-color: #cfdcea;
}

.dm.from-owner {
  background: var(--surface-2);
}

.dm-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 5px;
}

.dm-body {
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dm-body.removed {
  color: var(--muted);
  font-style: italic;
}

.dm-tools {
  display: flex;
  gap: 4px;
  margin-top: 7px;
}

.contact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.contact-card {
  padding: 13px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.contact-card small {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.contact-card strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.dm-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.composer-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.composer-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.composer-reply,
.composer-attach {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
}

.composer-reply .cr-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.composer-reply small {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

.composer-reply .cr-text > span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-attach img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--rule);
}

.composer-attach > span {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cr-close {
  flex: none;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.cr-close:hover {
  color: var(--ink);
  background: var(--rule);
}

.dm-quote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
  padding: 6px 8px;
  border-left: 3px solid var(--accent);
  border-radius: 7px;
  background: var(--surface-2);
}

.dm-quote small {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
}

.dm-quote span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

.dm-image {
  display: block;
  margin-top: 7px;
  max-width: 280px;
}

.dm-image img {
  display: block;
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 10px;
}

.dm-form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  resize: none;
  outline: none;
  font-size: 14px;
}

.dm-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.thread-pick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.thread-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  text-align: left;
}

.thread-row:hover {
  border-color: var(--accent);
}

.thread-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.thread-row .tr-body {
  flex: 1;
  min-width: 0;
}

.thread-row strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.thread-row small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================= DASHBOARD ============================= */

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.stat {
  padding: 12px 13px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat small {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.stat strong {
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat .sub {
  font-size: 11px;
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar .input {
  flex: 1;
  min-width: 200px;
}

.table-box {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: auto;
}

table.grid {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  font-size: 12.5px;
}

table.grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 12px;
  text-align: left;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}

table.grid td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

table.grid tbody tr:last-child td {
  border-bottom: 0;
}

table.grid tbody tr:hover {
  background: var(--surface);
}

.who-cell strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
}

.who-cell small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.qedit {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qedit label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--muted);
}

.qedit input {
  width: 56px;
  padding: 3px 5px;
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
  font-size: 11.5px;
  outline: none;
}

.qedit input:focus {
  border-color: var(--accent);
}

.num {
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.role-quick {
  height: 28px;
  padding: 0 6px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.role-quick:disabled {
  opacity: 0.6;
  cursor: progress;
}

.empty {
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ============================== CHARTS ============================== */

.chart {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--paper);
  margin-bottom: 14px;
}

.chart h4 {
  margin: 0 0 2px;
  font-size: 13.5px;
}

.chart .chart-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 12px;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 110px;
}

.bars .col {
  flex: 1;
  min-width: 3px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 4px;
}

.bars .col i {
  display: block;
  width: 100%;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}

.bars .col i.zero {
  background: var(--rule);
}

.bars .col span {
  font-size: 9px;
  color: var(--muted-2);
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 12px;
}

.legend-row {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.legend-row .track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
}

.legend-row .track i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.legend-row .val {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 32px;
  text-align: right;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.kpi {
  padding: 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.kpi small {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kpi strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

/* =============================== TOASTS =============================== */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(340px, calc(100vw - 32px));
}

.toast {
  padding: 10px 13px;
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  animation: rise 0.2s ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--ok);
}

.toast.warn {
  border-left-color: var(--warn);
}

/* ============================== ANIMATION ============================= */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================== RESPONSIVE ============================= */

@media (max-width: 1080px) {
  .auth-page {
    grid-template-columns: 1fr;
  }
  .auth-intro {
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    padding: 36px 32px 28px;
  }
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  .sidebar {
    width: min(286px, 84vw);
  }
  .auth-intro {
    padding: 28px 22px 22px;
  }
  .auth-intro h1 {
    font-size: 26px;
  }
  .auth-form-col {
    padding: 30px 22px;
  }
  .panel-inner {
    padding: 18px 14px 32px;
  }
  .contact-grid {
    grid-template-columns: 1fr;
  }
  .thread {
    padding: 16px 14px 6px;
  }
  .composer-area {
    padding: 8px 12px 12px;
  }
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tb-note {
    display: none;
  }
  .bubble {
    max-width: 90%;
  }
  .dm {
    max-width: 90%;
  }
}

@media (max-width: 620px) {
  .tiles {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .spec-list {
    grid-template-columns: 1fr;
  }
  .dialog {
    padding: 18px;
  }
  .hint {
    display: none;
  }
  .select-btn .sub {
    display: none;
  }
}

/* ============================== COMMUNITY ============================== */

.community-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.community-list {
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 14px;
}

.dm-list {
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}

/* =============================== FEEDBACK ============================== */

.feedback-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.feedback-main {
  min-width: 0;
}

.feedback-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}

.feedback-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  text-align: left;
}

.feedback-card:hover {
  border-color: var(--accent);
}

.feedback-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.feedback-card strong {
  font-size: 13px;
  font-weight: 600;
}

.fc-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fc-date {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted);
}

.fc-preview {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.fc-meta {
  font-size: 10.5px;
  color: var(--muted);
}

.feedback-thread {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.feedback-thread-head h3 {
  margin: 8px 0 6px;
  font-size: 16px;
}

.fth-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.fth-body {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--ink-2);
  white-space: pre-wrap;
}

.fth-attach {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  margin-bottom: 10px;
}

.fth-attach img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
}

.fth-status-note {
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.status-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.feedback-side {
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--surface);
  position: sticky;
  top: 12px;
}

.feedback-side h2 {
  margin: 0 0 12px;
  font-size: 15px;
}

.feedback-attach {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.feedback-side .field > span em {
  font-style: normal;
  color: var(--muted);
  font-weight: 400;
}

@media (max-width: 900px) {
  .feedback-layout {
    grid-template-columns: 1fr;
  }
  .feedback-side {
    position: static;
    order: -1;
  }
  .feedback-list {
    max-height: 40vh;
  }
}

/* ============================== DAYA INGAT ============================= */

.memory-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}

.memory-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 11px 13px;
}

.mem-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.mem-head strong {
  font-size: 13.5px;
  font-weight: 600;
}

.mem-head .fc-date {
  margin-left: auto;
  font-size: 10.5px;
  color: var(--muted);
}

.mem-body {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.memory-card .tool {
  padding-left: 0;
}

[data-theme='dark'] .memory-card {
  background: var(--surface);
  border-color: var(--rule);
}

[data-theme='dark'] .mem-body {
  color: var(--ink-2);
}

/* ================================ THEMES =============================== */

/* Light is the default: white surfaces, light sidebar. */
:root {
  --sidebar: #f7f7f4;
  --sidebar-2: #ecece7;
  --sidebar-ink: #17181a;
  --sidebar-muted: #737576;
  --sidebar-rule: #e2e2dd;
}

/* Dark: every surface, including the sidebar and history, goes dark. */
[data-theme='dark'] {
  --paper: #0f1115;
  --surface: #16191f;
  --surface-2: #1d2128;
  --ink: #e9ecf1;
  --ink-2: #c2c7d0;
  --muted: #8f959f;
  --muted-2: #6b7280;
  --rule: #262a32;
  --rule-strong: #363b45;

  --accent: #6f9fd8;
  --accent-hover: #86b1e4;
  --accent-soft: #1a2432;

  --sidebar: #0b0d11;
  --sidebar-2: #171a20;
  --sidebar-ink: #e9ecf1;
  --sidebar-muted: #8f959f;
  --sidebar-rule: #23272f;

  --ok: #4fae83;
  --ok-soft: #14251d;
  --warn: #d0a24a;
  --warn-soft: #241f14;
  --danger: #d9736c;
  --danger-soft: #261716;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* System: dark history/sidebar, light chat area. */
[data-theme='system'] {
  --sidebar: #14161a;
  --sidebar-2: #1c1f24;
  --sidebar-ink: #e6e7e9;
  --sidebar-muted: #8d9198;
  --sidebar-rule: #262a30;
}

[data-theme='dark'] .prose pre {
  background: #05070a;
  border-color: #2a2f38;
}

[data-theme='dark'] .prose pre code {
  color: #d5d9e0;
}

[data-theme='dark'] .prose code {
  background: #1a1e25;
  color: #a9c4e8;
}

[data-theme='dark'] .sidebar .wordmark .mark {
  background: #e9ecf1;
  color: #0b0d11;
}

[data-theme='dark'] .avatar {
  background: #2a2f38;
}

[data-theme='dark'] .overlay {
  background: rgba(0, 0, 0, 0.62);
}

[data-theme='dark'] .dialog,
[data-theme='dark'] .popover {
  background: #14171d;
  border-color: #2a2f38;
}

[data-theme='dark'] .field input,
[data-theme='dark'] .field select,
[data-theme='dark'] .field textarea,
[data-theme='dark'] .input,
[data-theme='dark'] .dm-form textarea,
[data-theme='dark'] .composer {
  background: #0c0e12;
  border-color: #2a2f38;
  color: var(--ink);
}

[data-theme='dark'] .btn {
  background: #171a20;
  border-color: #2f343d;
  color: var(--ink);
}

[data-theme='dark'] .btn:hover:not(:disabled) {
  background: #1f232b;
  border-color: #3d434e;
}

[data-theme='dark'] .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0d11;
}

[data-theme='dark'] .btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

[data-theme='dark'] .btn-quiet {
  background: transparent;
  border-color: transparent;
}

[data-theme='dark'] .stat,
[data-theme='dark'] .chart,
[data-theme='dark'] .contact-card,
[data-theme='dark'] .kpi,
[data-theme='dark'] .dm,
[data-theme='dark'] .thread-row,
[data-theme='dark'] .file-card,
[data-theme='dark'] .thinking,
[data-theme='dark'] .reason,
[data-theme='dark'] .account-grid,
[data-theme='dark'] .table-box {
  background: var(--surface);
  border-color: var(--rule);
}

[data-theme='dark'] .dm.mine {
  background: #1a2432;
  border-color: #2b3a4d;
}

[data-theme='dark'] .dm.from-owner {
  background: var(--surface-2);
}

[data-theme='dark'] table.grid th {
  background: #14171d;
}

[data-theme='dark'] .bubble {
  background: var(--surface-2);
  border-color: var(--rule);
}

[data-theme='dark'] .toast {
  background: #171a20;
  border-color: #2f343d;
}

[data-theme='dark'] .notice {
  background: var(--surface);
  border-color: var(--rule-strong);
}

[data-theme='dark'] .notice.error {
  background: var(--danger-soft);
  border-color: #4a2a28;
  color: #e8a29c;
}

[data-theme='dark'] .notice.success {
  background: var(--ok-soft);
  border-color: #24402f;
  color: #8fd3b0;
}

[data-theme='dark'] .notice.warn {
  background: var(--warn-soft);
  border-color: #453a22;
  color: #e0c07a;
}

[data-theme='dark'] .badge {
  background: var(--surface-2);
  border-color: var(--rule-strong);
  color: var(--ink-2);
}

[data-theme='dark'] .badge.owner {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

[data-theme='dark'] .badge.owner-solid {
  background: #000000;
  border-color: #3a3a3a;
  color: #ffffff;
}

[data-theme='dark'] .badge.admin {
  background: #1a2432;
  border-color: #2b3a4d;
  color: #9dc0e6;
}

[data-theme='dark'] .badge.vip {
  background: #241f14;
  border-color: #453a22;
  color: #e0c07a;
}

[data-theme='dark'] .badge.member {
  background: var(--surface-2);
  color: var(--muted);
}

[data-theme='dark'] .auth-page {
  background: var(--paper);
}

[data-theme='dark'] .auth-intro {
  background: var(--surface);
  border-color: var(--rule);
}

[data-theme='dark'] .tier-table th,
[data-theme='dark'] .tier-table td {
  border-color: var(--rule);
}

[data-theme='dark'] .switch span {
  background: #3a404a;
}

[data-theme='dark'] .switch input:checked + span {
  background: var(--accent);
}

[data-theme='dark'] .switch span::after {
  background: #e9ecf1;
}

[data-theme='dark'] .qrow .track,
[data-theme='dark'] .meter-track,
[data-theme='dark'] .legend-row .track,
[data-theme='dark'] .bar {
  background: #23272f;
}

[data-theme='dark'] .qrow .track i {
  background: #6f7681;
}

[data-theme='dark'] .quota-box {
  border-color: var(--sidebar-rule);
}

[data-theme='dark'] .side-item:hover,
[data-theme='dark'] .hist:hover {
  background: var(--sidebar-2);
}

[data-theme='dark'] .hist.active {
  background: #23272f;
}

[data-theme='dark'] .new-btn {
  border-color: var(--sidebar-rule);
}

[data-theme='dark'] .new-btn:hover {
  background: var(--sidebar-2);
}

[data-theme='dark'] .icon-btn:hover {
  background: var(--sidebar-2);
}

[data-theme='dark'] .user-row .who strong {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .quota-box .qhead strong {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .qrow .val {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .sidebar .wordmark {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .side-item {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .side-item.active,
[data-theme='dark'] .side-item:hover {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .hist {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .hist.active,
[data-theme='dark'] .hist:hover {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .side-label,
[data-theme='dark'] .side-empty,
[data-theme='dark'] .hist-meta,
[data-theme='dark'] .user-row .who small {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .sidebar {
  border-right: 1px solid var(--sidebar-rule);
}

[data-theme='dark'] .topbar {
  background: var(--paper);
  border-color: var(--rule);
}

[data-theme='dark'] .composer-area {
  background: var(--paper);
  border-color: var(--rule);
}

[data-theme='dark'] .select-btn {
  background: var(--surface);
  border-color: var(--rule-strong);
  color: var(--ink);
}

[data-theme='dark'] .select-btn:hover {
  background: var(--surface-2);
}

[data-theme='dark'] .chip {
  background: var(--surface);
  border-color: var(--rule-strong);
  color: var(--ink-2);
}

[data-theme='dark'] .chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme='dark'] .tile {
  background: var(--surface);
  border-color: var(--rule);
}

[data-theme='dark'] .tile:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

[data-theme='dark'] .msg {
  border-color: var(--rule);
}

[data-theme='dark'] .generated {
  border-color: var(--rule-strong);
  background: var(--surface);
}

[data-theme='dark'] .meta-tag {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--muted);
}

[data-theme='dark'] .tool:hover {
  background: var(--surface-2);
  color: var(--ink);
}

[data-theme='dark'] .tab {
  color: var(--muted);
}

[data-theme='dark'] .tab.active {
  color: var(--ink);
}

[data-theme='dark'] .tabs {
  border-color: var(--rule);
}

[data-theme='dark'] .dialog-close:hover,
[data-theme='dark'] .eye:hover {
  background: var(--surface-2);
  color: var(--ink);
}

[data-theme='dark'] .account-grid div {
  border-color: var(--rule);
}

[data-theme='dark'] .qedit input,
[data-theme='dark'] .limit-input {
  background: #0c0e12;
  border-color: var(--rule-strong);
  color: var(--ink);
}

[data-theme='dark'] .search-input {
  background: #0c0e12;
  border-color: var(--rule-strong);
  color: var(--ink);
}

[data-theme='dark'] .admin-table th {
  background: #14171d;
}

[data-theme='dark'] .admin-table td {
  border-color: var(--rule);
}

[data-theme='dark'] .admin-table tbody tr:hover {
  background: var(--surface);
}

[data-theme='dark'] .bars .col i.zero {
  background: var(--rule);
}

[data-theme='dark'] .typing-bubble {
  background: var(--surface);
  border-color: var(--rule);
}

[data-theme='dark'] .typing-bubble i {
  background: var(--muted);
}

[data-theme='dark'] .empty-note,
[data-theme='dark'] .side-empty {
  border-color: var(--rule);
}

[data-theme='dark'] .google-account {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--ink);
}

[data-theme='dark'] .google-account:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

[data-theme='dark'] .google-other input {
  background: #0c0e12;
  border-color: var(--rule-strong);
  color: var(--ink);
}

[data-theme='dark'] .btn-google {
  background: #e9ecf1;
  border-color: #e9ecf1;
  color: #17181a;
}

[data-theme='dark'] .btn-google:hover {
  background: #ffffff;
}

[data-theme='dark'] .demo-note,
[data-theme='dark'] .legal,
[data-theme='dark'] .meter-label {
  color: var(--muted-2);
}

[data-theme='dark'] .rule-split {
  color: var(--muted-2);
}

[data-theme='dark'] .rule-split::before,
[data-theme='dark'] .rule-split::after {
  background: var(--rule);
}

[data-theme='dark'] .auth-page .contact-inline {
  border-color: var(--rule);
}

[data-theme='dark'] .auth-page .contact-inline a {
  color: var(--ink-2);
}

[data-theme='dark'] .spec-list {
  border-color: var(--rule);
}

[data-theme='dark'] .spec-list li {
  color: var(--ink-2);
}

[data-theme='dark'] .auth-intro .lede {
  color: var(--muted);
}

[data-theme='dark'] .pane .sub {
  color: var(--muted);
}

[data-theme='dark'] .foot-switch {
  color: var(--muted);
}

[data-theme='dark'] .text-btn {
  color: var(--accent);
}

[data-theme='dark'] .field > span {
  color: var(--ink-2);
}

[data-theme='dark'] .field small {
  color: var(--muted);
}

[data-theme='dark'] .field input::placeholder,
[data-theme='dark'] .field textarea::placeholder,
[data-theme='dark'] .composer textarea::placeholder,
[data-theme='dark'] .dm-form textarea::placeholder {
  color: var(--muted-2);
}

[data-theme='dark'] .composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

[data-theme='dark'] .send {
  background: var(--accent);
  color: #0b0d11;
}

[data-theme='dark'] .send:disabled {
  background: var(--rule-strong);
  color: var(--muted);
}

[data-theme='dark'] .send.stop {
  background: var(--danger);
  color: #1a0f0e;
}

[data-theme='dark'] .send.stop:hover:not(:disabled) {
  background: #e58a83;
}

[data-theme='dark'] .quota-strip span {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--muted);
}

[data-theme='dark'] .welcome p,
[data-theme='dark'] .panel-inner .lede {
  color: var(--muted);
}

[data-theme='dark'] .tile small,
[data-theme='dark'] .model-card-text small {
  color: var(--muted-2);
}

[data-theme='dark'] .pop-item:hover {
  background: var(--surface-2);
}

[data-theme='dark'] .pop-item.active {
  background: var(--accent-soft);
}

[data-theme='dark'] .pop-item small {
  color: var(--muted);
}

[data-theme='dark'] .pop-label {
  color: var(--muted-2);
}

[data-theme='dark'] .popover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

[data-theme='dark'] .dialog {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

[data-theme='dark'] .toast {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

[data-theme='dark'] .account-row {
  border-color: var(--rule);
}

[data-theme='dark'] .account-row span:first-child {
  color: var(--muted);
}

[data-theme='dark'] .dm-body.removed {
  color: var(--muted-2);
}

[data-theme='dark'] .dm-meta {
  color: var(--muted-2);
}

[data-theme='dark'] .thread-row:hover {
  border-color: var(--accent);
}

[data-theme='dark'] .thread-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

[data-theme='dark'] .thread-row small {
  color: var(--muted);
}

[data-theme='dark'] .contact-card small {
  color: var(--muted);
}

[data-theme='dark'] .contact-card a {
  color: var(--accent);
}

[data-theme='dark'] .stat small,
[data-theme='dark'] .stat .sub,
[data-theme='dark'] .chart .chart-sub {
  color: var(--muted);
}

[data-theme='dark'] .legend-row .val {
  color: var(--muted);
}

[data-theme='dark'] .bars .col span {
  color: var(--muted-2);
}

[data-theme='dark'] .who-cell small,
[data-theme='dark'] .usage-text {
  color: var(--muted);
}

[data-theme='dark'] .admin-empty,
[data-theme='dark'] .empty {
  color: var(--muted);
}

[data-theme='dark'] .status-badge {
  color: var(--ok);
}

[data-theme='dark'] .status-badge.banned {
  color: var(--danger);
}

[data-theme='dark'] .role-badge {
  background: #1a2432;
  color: #9dc0e6;
}

[data-theme='dark'] .role-badge.admin {
  background: #14251d;
  color: #8fd3b0;
}

[data-theme='dark'] .role-badge.banned {
  background: var(--danger-soft);
  color: #e8a29c;
}

[data-theme='dark'] .thinking-head,
[data-theme='dark'] .step {
  color: var(--muted);
}

[data-theme='dark'] .step.done {
  color: var(--ink-2);
}

[data-theme='dark'] .step.now {
  color: var(--ink);
}

[data-theme='dark'] .reason summary {
  color: var(--ink-2);
}

[data-theme='dark'] .reason .reason-body {
  color: var(--muted);
}

[data-theme='dark'] .msg-content,
[data-theme='dark'] .prose {
  color: var(--ink-2);
}

[data-theme='dark'] .prose strong {
  color: var(--ink);
}

[data-theme='dark'] .prose blockquote {
  background: var(--accent-soft);
  color: var(--ink-2);
}

[data-theme='dark'] .prose th,
[data-theme='dark'] .prose td {
  border-color: var(--rule);
}

[data-theme='dark'] .user-bubble {
  background: var(--surface-2);
  border-color: var(--rule);
}

[data-theme='dark'] .bubble {
  color: var(--ink);
}

[data-theme='dark'] .ai-head .who {
  color: var(--ink);
}

[data-theme='dark'] .assistant-name {
  color: var(--ink);
}

[data-theme='dark'] .msg-model {
  color: var(--muted);
}

[data-theme='dark'] .thinking-chip {
  background: var(--accent-soft);
  color: var(--accent);
}

[data-theme='dark'] .image-link {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--rule);
}

[data-theme='dark'] .att-chip {
  background: var(--surface-2);
  border-color: var(--rule-strong);
  color: var(--ink-2);
}

[data-theme='dark'] .file-card small {
  color: var(--muted);
}

[data-theme='dark'] .file-card strong {
  color: var(--ink);
}

[data-theme='dark'] .composer-hint,
[data-theme='dark'] .hint {
  color: var(--muted-2);
}

[data-theme='dark'] .quota-box .qhead {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .qrow {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .qrow.locked {
  opacity: 0.45;
}

[data-theme='dark'] .side-foot {
  border-color: var(--sidebar-rule);
}

[data-theme='dark'] .sidebar-head .wordmark {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .sidebar .wordmark .mark {
  background: var(--sidebar-ink);
  color: var(--sidebar);
}

[data-theme='dark'] .icon-btn {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .icon-btn:hover {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .hist-del:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-ink);
}

[data-theme='dark'] .new-btn {
  color: var(--sidebar-ink);
}

[data-theme='dark'] .new-btn:hover {
  border-color: #3a4048;
}

[data-theme='dark'] .side-item .count {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .scrim {
  background: rgba(0, 0, 0, 0.55);
}

[data-theme='dark'] .menu-btn {
  color: var(--ink);
}

[data-theme='dark'] .tb-note {
  color: var(--muted);
}

[data-theme='dark'] .lock-pill {
  background: var(--surface);
  border-color: var(--rule);
  color: var(--muted);
}

[data-theme='dark'] .tag {
  background: var(--accent-soft);
  color: var(--accent);
}

[data-theme='dark'] .tag.locked {
  background: var(--warn-soft);
  color: var(--warn);
}

[data-theme='dark'] .picker-item:hover {
  background: var(--surface-2);
}

[data-theme='dark'] .picker-item.is-active {
  background: var(--accent-soft);
}

[data-theme='dark'] .picker-item-text small {
  color: var(--muted);
}

[data-theme='dark'] .picker-menu {
  background: #14171d;
  border-color: var(--rule-strong);
}

[data-theme='dark'] .model-card {
  background: var(--surface);
  border-color: var(--rule);
}

[data-theme='dark'] .model-card:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

[data-theme='dark'] .model-card-text small {
  color: var(--muted-2);
}

[data-theme='dark'] .suggestion {
  border-color: var(--rule-strong);
  color: var(--muted);
}

[data-theme='dark'] .suggestion:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme='dark'] .empty-state > p {
  color: var(--muted);
}

[data-theme='dark'] .empty-state h1 {
  color: var(--ink);
}

[data-theme='dark'] .welcome h1 {
  color: var(--ink);
}

[data-theme='dark'] .panel-inner h1 {
  color: var(--ink);
}

[data-theme='dark'] .dash-head h1 {
  color: var(--ink);
}

[data-theme='dark'] .admin-head h1 {
  color: var(--ink);
}

[data-theme='dark'] .admin-head p {
  color: var(--muted);
}

[data-theme='dark'] .stat strong {
  color: var(--ink);
}

[data-theme='dark'] .kpi strong {
  color: var(--ink);
}

[data-theme='dark'] .kpi small {
  color: var(--muted);
}

[data-theme='dark'] .chart h4 {
  color: var(--ink);
}

[data-theme='dark'] .legend-row {
  color: var(--ink-2);
}

[data-theme='dark'] .legend-row .track i {
  background: var(--accent);
}

[data-theme='dark'] .bars .col i {
  background: var(--accent);
}

[data-theme='dark'] .qedit label {
  color: var(--muted);
}

[data-theme='dark'] .row-actions .btn {
  background: var(--surface);
}

[data-theme='dark'] .row-actions .btn:hover:not(:disabled) {
  background: var(--surface-2);
}

[data-theme='dark'] .btn-danger {
  color: var(--danger);
  border-color: #4a2a28;
}

[data-theme='dark'] .btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

[data-theme='dark'] .dialog-head p {
  color: var(--muted);
}

[data-theme='dark'] .dialog-head h3 {
  color: var(--ink);
}

[data-theme='dark'] .dialog-foot {
  border-color: var(--rule);
}

[data-theme='dark'] .account-grid div > span:first-child {
  color: var(--muted);
}

[data-theme='dark'] .account-grid div > span:last-child {
  color: var(--ink-2);
}

[data-theme='dark'] .toggle-row {
  border-color: var(--rule);
}

[data-theme='dark'] .toggle-row-text small {
  color: var(--muted);
}

[data-theme='dark'] .toggle-row-text strong {
  color: var(--ink);
}

[data-theme='dark'] .settings-modal h2 {
  color: var(--ink);
}

[data-theme='dark'] .settings-modal .modal-head p {
  color: var(--muted);
}

[data-theme='dark'] .modal-close {
  color: var(--muted);
}

[data-theme='dark'] .modal-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

[data-theme='dark'] .google-head {
  color: var(--ink);
}

[data-theme='dark'] .google-sub {
  color: var(--muted);
}

[data-theme='dark'] .google-sub strong {
  color: var(--accent);
}

[data-theme='dark'] .google-register {
  background: var(--warn-soft);
  border-color: #453a22;
}

[data-theme='dark'] .google-register p {
  color: var(--warn);
}

[data-theme='dark'] .account-meta strong {
  color: var(--ink);
}

[data-theme='dark'] .account-meta small {
  color: var(--muted-2);
}

[data-theme='dark'] .account-skeleton {
  background: linear-gradient(90deg, #171a20, #1f232b, #171a20);
  background-size: 200% 100%;
}

[data-theme='dark'] .empty-note {
  color: var(--muted);
}

[data-theme='dark'] .history-empty {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .side-empty {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .section-label {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .side-label {
  color: var(--sidebar-muted);
}

[data-theme='dark'] .user-chip:hover {
  background: var(--sidebar-2);
}

[data-theme='dark'] .user-avatar {
  background: #2a2f38;
  color: var(--sidebar-ink);
}

[data-theme='dark'] .avatar {
  background: #2a2f38;
  color: var(--sidebar-ink);
}

[data-theme='dark'] .account-avatar {
  background: var(--accent);
  color: #0b0d11;
}

[data-theme='dark'] .google-account svg {
  color: var(--muted-2);
}

[data-theme='dark'] .demo-note {
  border-color: var(--rule);
}

[data-theme='dark'] .legal {
  color: var(--muted-2);
}

[data-theme='dark'] .auth-body {
  background: var(--paper);
}

[data-theme='dark'] .auth-shell {
  background: var(--paper);
  border-color: var(--rule);
}

[data-theme='dark'] .auth-brand {
  background: var(--surface);
  border-color: var(--rule);
}

[data-theme='dark'] .auth-brand::after {
  display: none;
}

[data-theme='dark'] .auth-body::before {
  opacity: 0.35;
}

[data-theme='dark'] .brand-name .accent {
  color: var(--accent);
}

[data-theme='dark'] .eyebrow {
  color: var(--accent);
}

[data-theme='dark'] .grad {
  background: none;
  -webkit-text-fill-color: var(--ink);
  color: var(--ink);
}

[data-theme='dark'] .model-chips li {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--ink-2);
}

[data-theme='dark'] .brand-foot {
  border-color: var(--rule);
  color: var(--muted-2);
}

[data-theme='dark'] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(79, 174, 131, 0.16);
}

[data-theme='dark'] .auth-panel {
  background: var(--paper);
}

[data-theme='dark'] .card-head h2 {
  color: var(--ink);
}

[data-theme='dark'] .card-head p {
  color: var(--muted);
}

[data-theme='dark'] .divider {
  color: var(--muted-2);
}

[data-theme='dark'] .divider::before,
[data-theme='dark'] .divider::after {
  background: var(--rule);
}

[data-theme='dark'] .switch {
  color: var(--muted);
}

[data-theme='dark'] .link-btn {
  color: var(--accent);
}

[data-theme='dark'] .link-btn:hover {
  color: var(--accent-hover);
}

[data-theme='dark'] .strength {
  color: var(--muted-2);
}

[data-theme='dark'] .strength-bar {
  background: var(--surface-2);
}

[data-theme='dark'] .alert {
  border-color: var(--rule-strong);
}

[data-theme='dark'] .alert.error {
  background: var(--danger-soft);
  border-color: #4a2a28;
  color: #e8a29c;
}

[data-theme='dark'] .alert.success {
  background: var(--ok-soft);
  border-color: #24402f;
  color: #8fd3b0;
}

[data-theme='dark'] .alert.warning {
  background: var(--warn-soft);
  border-color: #453a22;
  color: #e0c07a;
}

[data-theme='dark'] .alert.info {
  background: var(--accent-soft);
  border-color: #2b3a4d;
  color: #9dc0e6;
}

[data-theme='dark'] .modal-backdrop {
  background: rgba(0, 0, 0, 0.62);
}

[data-theme='dark'] .modal {
  background: #14171d;
  border-color: var(--rule-strong);
}

[data-theme='dark'] .google-other input::placeholder {
  color: var(--muted-2);
}

[data-theme='dark'] .google-other input:focus {
  border-color: var(--accent);
}

[data-theme='dark'] .google-account:hover {
  background: var(--accent-soft);
}

[data-theme='dark'] .account-skeleton {
  background: linear-gradient(90deg, #171a20, #1f232b, #171a20);
}

[data-theme='dark'] .empty-note {
  border-color: var(--rule);
}

[data-theme='dark'] .google-register .btn {
  background: #e9ecf1;
  border-color: #e9ecf1;
  color: #17181a;
}

[data-theme='dark'] .google-register .btn:hover {
  background: #ffffff;
}

[data-theme='dark'] .demo-note {
  color: var(--muted-2);
}

[data-theme='dark'] .meter-label {
  color: var(--muted-2);
}

[data-theme='dark'] .contact-inline a {
  color: var(--ink-2);
}

[data-theme='dark'] .contact-inline {
  border-color: var(--rule);
  color: var(--muted);
}

[data-theme='dark'] .tier-table td:first-child {
  color: var(--ink);
}

[data-theme='dark'] .tier-table td {
  color: var(--ink-2);
}

[data-theme='dark'] .tier-table th {
  color: var(--muted);
}

[data-theme='dark'] .spec-list .num {
  color: var(--muted-2);
}

[data-theme='dark'] .auth-intro h1 {
  color: var(--ink);
}

[data-theme='dark'] .wordmark {
  color: var(--ink);
}

[data-theme='dark'] .auth-intro .wordmark {
  color: var(--ink);
}

[data-theme='dark'] .auth-intro .wordmark .mark {
  background: var(--ink);
  color: var(--paper);
}

[data-theme='dark'] .pane h2 {
  color: var(--ink);
}

[data-theme='dark'] .field input:read-only,
[data-theme='dark'] .field input:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

[data-theme='dark'] .eye {
  color: var(--muted);
}

[data-theme='dark'] .eye:hover {
  background: var(--surface-2);
  color: var(--ink);
}

[data-theme='dark'] .btn.is-busy::after {
  color: #0b0d11;
}

[data-theme='dark'] .btn:not(.btn-primary).is-busy::after {
  color: var(--ink);
}

[data-theme='dark'] .btn-google.is-busy::after {
  border-color: rgba(23, 24, 26, 0.3);
  border-top-color: #17181a;
}

[data-theme='dark'] .toast {
  color: var(--ink);
}

[data-theme='dark'] .toast::before {
  background: var(--accent);
}

[data-theme='dark'] .toast.error::before {
  background: var(--danger);
}

[data-theme='dark'] .toast.success::before {
  background: var(--ok);
}

[data-theme='dark'] .toast.warn::before {
  background: var(--warn);
}

[data-theme='dark'] ::-webkit-scrollbar-thumb {
  background: #2f343d;
  background-clip: content-box;
}

[data-theme='dark'] ::-webkit-scrollbar-thumb:hover {
  background: #3d434e;
  background-clip: content-box;
}

[data-theme='dark'] ::selection {
  background: rgba(111, 159, 216, 0.35);
}

[data-theme='dark'] :focus-visible {
  outline-color: var(--accent);
}

/* ============================ RESPONSIVE FIXES ========================= */

@media (max-width: 900px) {
  .topbar {
    gap: 6px;
    padding: 8px 10px;
  }
  .select-btn {
    padding: 6px 9px;
    font-size: 12.5px;
  }
  .select-btn .sub {
    display: none;
  }
  .tb-note {
    display: none;
  }
  .community-list,
  .dm-list {
    max-height: 44vh;
  }
}

@media (max-width: 700px) {
  .topbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar {
    display: none;
  }
  .topbar > * {
    flex: none;
  }
  .topbar-spacer {
    flex: 1 1 auto;
    min-width: 0;
  }
  #contactBtn {
    display: none;
  }
  .panel-inner {
    padding: 16px 12px 28px;
  }
  .panel-inner h1 {
    font-size: 19px;
  }
  .contact-grid {
    grid-template-columns: 1fr;
  }
  .thread-pick {
    max-height: 34vh;
    overflow-y: auto;
  }
  .dm-form {
    gap: 6px;
  }
  .dm-form .btn {
    padding: 9px 12px;
  }
  .community-list,
  .dm-list {
    max-height: 40vh;
  }
  .dm {
    max-width: 94%;
  }
  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dialog {
    max-height: calc(100vh - 24px);
    padding: 16px;
  }
  .dialog.wide {
    max-width: 100%;
  }
  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tab {
    white-space: nowrap;
  }
  .table-box {
    border-radius: 8px;
  }
  table.grid {
    min-width: 760px;
  }
  .admin-head {
    align-items: flex-start;
  }
  .admin-head-actions {
    width: 100%;
  }
  .admin-head-actions .btn {
    flex: 1;
  }
  .toolbar .input {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .topbar {
    padding: 7px 8px;
  }
  .select-btn {
    padding: 5px 8px;
    font-size: 12px;
    max-width: 46vw;
  }
  .select-btn > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #communityBtn {
    display: none;
  }
  .composer-area {
    padding: 6px 8px 10px;
  }
  .composer {
    padding: 6px 6px 4px 10px;
  }
  .composer textarea {
    font-size: 14px;
  }
  .quota-strip {
    gap: 4px;
    font-size: 10px;
  }
  .quota-strip span {
    padding: 2px 5px;
  }
  .thread {
    padding: 12px 10px 4px;
  }
  .msg.ai {
    gap: 8px;
  }
  .ai-mark {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
  .bubble {
    max-width: 100%;
    font-size: 13.5px;
  }
  .user-col {
    max-width: 94%;
  }
  .prose {
    font-size: 14px;
  }
  .prose pre {
    padding: 10px;
    font-size: 12px;
  }
  .panel-inner {
    padding: 14px 10px 24px;
  }
  .contact-card {
    padding: 11px;
  }
  .dm {
    max-width: 100%;
  }
  .dm-form textarea {
    font-size: 13.5px;
  }
  .dialog {
    padding: 14px;
    border-radius: 10px;
  }
  .dialog-head h3 {
    font-size: 15.5px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .kpi-row,
  .stat-row {
    grid-template-columns: 1fr 1fr;
  }
  .stat strong {
    font-size: 18px;
  }
  .kpi strong {
    font-size: 15px;
  }
  .bars {
    height: 84px;
  }
  .legend-row {
    grid-template-columns: 70px 1fr auto;
    font-size: 11.5px;
  }
  .qedit label {
    flex-wrap: wrap;
  }
  .row-actions {
    gap: 3px;
  }
  .row-actions .btn {
    padding: 4px 7px;
    font-size: 11.5px;
  }
  .auth-intro {
    padding: 22px 16px 18px;
  }
  .auth-form-col {
    padding: 22px 16px;
  }
  .auth-intro h1 {
    font-size: 22px;
  }
  .tier-table {
    font-size: 11.5px;
  }
  .tier-table th,
  .tier-table td {
    padding: 6px 6px;
  }
  .contact-inline {
    gap: 6px 12px;
    font-size: 11.5px;
  }
  .toasts {
    right: 10px;
    bottom: 10px;
    left: 10px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------- source photos & citations (dark) ------------------ */

[data-theme='dark'] .thinking-scan {
  background: #23272f;
}

[data-theme='dark'] .src-chip {
  background: #1b1f26;
  border-color: #2b3038;
  color: #c3c8d1;
}

[data-theme='dark'] .src-chip:hover {
  border-color: #6f7681;
  color: #eef1f6;
}

[data-theme='dark'] .img-card,
[data-theme='dark'] .src-list {
  background: #1b1f26;
  border-color: #2b3038;
}

[data-theme='dark'] .img-card figcaption {
  color: #c3c8d1;
}

[data-theme='dark'] .src-list summary {
  color: #c3c8d1;
}

[data-theme='dark'] .src-list li {
  color: #c3c8d1;
}

[data-theme='dark'] .src-list li a {
  color: #8fb4ff;
}

/* ====================== BONUS KUOTA & DURASI ====================== */

.bonus {
  color: var(--danger);
  font-weight: 700;
  font-size: 10.5px;
  margin-left: 3px;
}

.dur-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dur-btn {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.dur-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.dur-row input {
  width: 64px;
  text-align: center;
  padding: 5px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-size: 12.5px;
  outline: none;
}

.dur-row input:focus {
  border-color: var(--accent);
}

.dur-unit {
  font-size: 11.5px;
  color: var(--muted);
  min-width: 34px;
}

/* ========================= UPGRADE ROLE ========================= */

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.upgrade-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.uc-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.uc-head strong {
  font-size: 13.5px;
}

.uc-price {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.upgrade-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.upgrade-card .btn {
  align-self: flex-start;
}

/* ========================== INFORMASI ========================== */

.info-section {
  margin-bottom: 26px;
}

.info-section h2 {
  font-size: 15px;
  margin: 0 0 10px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.info-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 13px 14px;
}

.ic-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.ic-head strong {
  font-size: 13.5px;
}

.ic-price {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.ic-sub {
  margin: 0 0 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.ic-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.6;
}

.ic-list li {
  margin-bottom: 3px;
}

.ic-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
}

.ic-tags span {
  font-size: 10.5px;
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--muted);
}

.info-rows {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.info-row {
  display: flex;
  gap: 12px;
  padding: 9px 13px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}

.info-row:last-child {
  border-bottom: 0;
}

.info-row strong {
  min-width: 150px;
  flex: none;
}

.info-row span {
  color: var(--muted);
}

/* ======================= UP ROLE INFORMATION ======================= */

.uprole-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.uprole-card .dm-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.uprole-card .dm-body p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.uprole-card .dm-body small {
  font-size: 11px;
  color: var(--muted);
}

.uprole-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--rule);
}

@media (max-width: 640px) {
  .info-row {
    flex-direction: column;
    gap: 2px;
  }

  .info-row strong {
    min-width: 0;
  }
}

/* Selectable upgrade request cards (member view). */
.uprole-card[data-my-request] {
  cursor: pointer;
}

.uprole-card[data-my-request]:hover {
  border-color: var(--rule-strong);
}

.uprole-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

[data-theme='dark'] .uprole-card.active {
  box-shadow: 0 0 0 2px rgba(111, 159, 216, 0.25);
}

/* ===================== AUTH DECOR (sparkles + curves) ===================== */

.auth-page {
  position: relative;
  overflow: hidden;
}

.auth-intro,
.auth-form-col {
  position: relative;
  z-index: 1;
}

.auth-decor {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.decor-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
}

.decor-lines .curve {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.1;
  stroke-linecap: round;
  opacity: 0.28;
  stroke-dasharray: 6 10;
  animation: curveDrift 26s linear infinite;
}

.decor-lines .c1 { animation-duration: 30s; opacity: 0.3; }
.decor-lines .c2 { animation-duration: 38s; animation-direction: reverse; opacity: 0.22; }
.decor-lines .c3 { animation-duration: 34s; opacity: 0.26; }
.decor-lines .c4 { animation-duration: 42s; animation-direction: reverse; opacity: 0.2; }

@keyframes curveDrift {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -320; }
}

.spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px 1px var(--accent);
  opacity: 0;
  animation: sparkle 6s ease-in-out infinite;
}

.spark::before,
.spark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  border-radius: 1px;
}

.spark::before { width: 1px; height: 14px; }
.spark::after { width: 14px; height: 1px; }

.spark.s1  { left: 8%;  top: 14%; animation-delay: 0s;    animation-duration: 5.5s; }
.spark.s2  { left: 22%; top: 62%; animation-delay: 1.1s;  animation-duration: 7s; }
.spark.s3  { left: 34%; top: 28%; animation-delay: 2.3s;  animation-duration: 6.2s; }
.spark.s4  { left: 46%; top: 78%; animation-delay: 0.6s;  animation-duration: 8s; }
.spark.s5  { left: 58%; top: 18%; animation-delay: 3.1s;  animation-duration: 6.8s; }
.spark.s6  { left: 68%; top: 54%; animation-delay: 1.8s;  animation-duration: 5.8s; }
.spark.s7  { left: 78%; top: 34%; animation-delay: 2.7s;  animation-duration: 7.4s; }
.spark.s8  { left: 88%; top: 70%; animation-delay: 0.9s;  animation-duration: 6.4s; }
.spark.s9  { left: 14%; top: 84%; animation-delay: 3.6s;  animation-duration: 7.8s; }
.spark.s10 { left: 52%; top: 44%; animation-delay: 4.2s;  animation-duration: 6.6s; }
.spark.s11 { left: 92%; top: 22%; animation-delay: 1.4s;  animation-duration: 5.2s; }
.spark.s12 { left: 30%; top: 8%;  animation-delay: 2.9s;  animation-duration: 7.2s; }

@keyframes sparkle {
  0%, 100% { opacity: 0; transform: scale(0.4) rotate(0deg); }
  40%      { opacity: 0.9; transform: scale(1) rotate(45deg); }
  60%      { opacity: 0.7; transform: scale(0.85) rotate(90deg); }
}

[data-theme='dark'] .decor-lines .curve { opacity: 0.4; }
[data-theme='dark'] .spark { box-shadow: 0 0 10px 2px var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .decor-lines .curve,
  .spark {
    animation: none;
  }
  .spark { opacity: 0.5; }
}

/* ============================ CONFIRM DIALOG ============================ */

.confirm-dialog {
  max-width: 400px;
  text-align: center;
  padding: 26px 24px 20px;
}

.confirm-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.confirm-icon.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.confirm-dialog h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.confirm-dialog p {
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.confirm-actions .btn {
  min-width: 110px;
  justify-content: center;
}

[data-theme='dark'] .confirm-icon {
  background: rgba(111, 159, 216, 0.16);
}

[data-theme='dark'] .confirm-icon.danger {
  background: rgba(217, 115, 108, 0.16);
}

/* ===================== APP AMBIENCE (post-login) ===================== */

/* A very slow, low-contrast glow behind the chat area. It is deliberately
   subtle: it should read as depth, not as a decorative gradient. */
.main {
  position: relative;
  isolation: isolate;
}

/* The header keeps a single soft glow behind it and nothing else: no travelling
   accent line, no gradient rule. The chat area below is left clean. */
.main::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 45% at 18% 0%, rgba(35, 80, 122, 0.07), transparent 70%),
    radial-gradient(50% 40% at 92% 12%, rgba(35, 80, 122, 0.05), transparent 72%);
  animation: ambienceDrift 34s ease-in-out infinite alternate;
}

@keyframes ambienceDrift {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: 0.9; }
  50%  { transform: translate3d(-1.5%, 1%, 0) scale(1.04); opacity: 1; }
  100% { transform: translate3d(1.5%, -1%, 0) scale(1.02); opacity: 0.85; }
}

/* Welcome screen: a soft entrance for the heading and tiles. */
.welcome h1 {
  animation: riseIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.welcome p {
  animation: riseIn 0.5s cubic-bezier(0.22, 0.61, 0.36, 1) 0.06s both;
}

.welcome .tiles {
  animation: riseIn 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) 0.12s both;
}

.welcome .starters {
  animation: riseIn 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) 0.18s both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Tiles get a restrained lift and accent edge on hover. */
.tile {
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.tile:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Messages fade in as they are appended. */
.msg {
  animation: msgIn 0.28s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Sidebar: kept a flat, solid panel so it reads as a hard edge against the
   chat instead of a glowing seam. */

/* Light mode was visually empty: white paper with no depth. These layers add
   structure without turning the page into a gradient poster. */

/* A soft accent wash at the very top of the chat column. */
[data-theme='light'] .main::before {
  background:
    radial-gradient(70% 40% at 20% 0%, rgba(35, 80, 122, 0.09), transparent 70%),
    radial-gradient(55% 35% at 88% 6%, rgba(35, 80, 122, 0.06), transparent 72%);
}

/* Sidebar: a warm top glow so it is not a flat block. */
[data-theme='light'] .sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  pointer-events: none;
  background: radial-gradient(ellipse 130% 100% at 50% 0%, rgba(35, 80, 122, 0.08), transparent 72%);
}

/* Tiles read as cards on white: give them a faint tinted top edge. */
[data-theme='dark'] .main::before {
  background:
    radial-gradient(60% 45% at 18% 0%, rgba(111, 159, 216, 0.12), transparent 70%),
    radial-gradient(50% 40% at 92% 12%, rgba(111, 159, 216, 0.08), transparent 72%);
}

/* System theme: dark sidebar, light chat — keep the glow light. */
[data-theme='system'] .main::before {
  background:
    radial-gradient(60% 45% at 18% 0%, rgba(35, 80, 122, 0.06), transparent 70%),
    radial-gradient(50% 40% at 92% 12%, rgba(35, 80, 122, 0.04), transparent 72%);
}

@media (prefers-reduced-motion: reduce) {
  .main::before,
  .welcome h1,
  .welcome p,
  .welcome .tiles,
  .welcome .starters,
  .msg {
    animation: none;
  }
}

/* ===================== AUTH DECOR � refined pass ===================== */

/* Soft light pools behind the curves. Kept very low contrast so the page
   still reads as a clean editorial layout. */
.decor-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  pointer-events: none;
}

.decor-orb.o1 {
  width: 420px;
  height: 420px;
  left: -120px;
  top: -140px;
  background: radial-gradient(circle, rgba(35, 80, 122, 0.16), transparent 70%);
  animation: orbFloat 26s ease-in-out infinite alternate;
}

.decor-orb.o2 {
  width: 520px;
  height: 520px;
  right: -180px;
  bottom: -200px;
  background: radial-gradient(circle, rgba(35, 80, 122, 0.12), transparent 70%);
  animation: orbFloat 32s ease-in-out infinite alternate-reverse;
}

@keyframes orbFloat {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(30px, 24px, 0) scale(1.08); }
}

/* The extra curves drift at different speeds so the field never looks static. */
.decor-lines .c5 { animation-duration: 46s; opacity: 0.18; }
.decor-lines .c6 { animation-duration: 40s; animation-direction: reverse; opacity: 0.16; }

/* Sparkles: a four-point star drawn with two crossing bars, plus a soft halo. */
.spark {
  width: 2px;
  height: 2px;
  background: transparent;
  box-shadow: none;
}

.spark::before,
.spark::after {
  background: var(--accent);
  box-shadow: 0 0 6px 1px rgba(35, 80, 122, 0.45);
}

.spark::before { width: 1px; height: 16px; }
.spark::after  { width: 16px; height: 1px; }

.spark.s13 { left: 6%;  top: 46%; animation-delay: 0.4s; animation-duration: 6.9s; }
.spark.s14 { left: 40%; top: 58%; animation-delay: 2.1s; animation-duration: 5.6s; }
.spark.s15 { left: 64%; top: 86%; animation-delay: 3.4s; animation-duration: 7.6s; }
.spark.s16 { left: 84%; top: 8%;  animation-delay: 1.7s; animation-duration: 6.1s; }

/* A few sparkles are larger, which gives the field depth. */
.spark.s3::before, .spark.s3::after,
.spark.s7::before, .spark.s7::after,
.spark.s11::before, .spark.s11::after {
  transform: translate(-50%, -50%) scale(1.5);
}

[data-theme='dark'] .decor-orb.o1 {
  background: radial-gradient(circle, rgba(111, 159, 216, 0.22), transparent 70%);
}

[data-theme='dark'] .decor-orb.o2 {
  background: radial-gradient(circle, rgba(111, 159, 216, 0.16), transparent 70%);
}

[data-theme='dark'] .spark::before,
[data-theme='dark'] .spark::after {
  box-shadow: 0 0 8px 2px rgba(111, 159, 216, 0.55);
}

@media (prefers-reduced-motion: reduce) {
  .decor-orb {
    animation: none;
  }
}

/* ==================== LIGHT MODE DECORATION ==================== */

/* Light mode was visually empty: white paper with no depth. These layers add
   structure without turning the page into a gradient poster. */

/* A soft accent wash at the very top of the chat column. */
[data-theme='light'] .main::before {
  background:
    radial-gradient(70% 40% at 20% 0%, rgba(35, 80, 122, 0.09), transparent 70%),
    radial-gradient(55% 35% at 88% 6%, rgba(35, 80, 122, 0.06), transparent 72%);
}

/* Tiles read as cards on white: give them a faint tinted top edge. */
[data-theme='light'] .tile {
  background: linear-gradient(180deg, rgba(35, 80, 122, 0.035), transparent 60%), var(--paper);
}

[data-theme='light'] .tile:hover {
  background: linear-gradient(180deg, rgba(35, 80, 122, 0.07), transparent 60%), var(--paper);
}

/* Stat cards and info cards get the same faint tint. */
[data-theme='light'] .stat,
[data-theme='light'] .info-card,
[data-theme='light'] .upgrade-card {
  background: linear-gradient(180deg, rgba(35, 80, 122, 0.03), transparent 55%), var(--paper);
}

/* The composer sits on a slightly tinted strip so it separates from the grid. */
[data-theme='light'] .composer-area {
  background: linear-gradient(180deg, rgba(35, 80, 122, 0.03), var(--paper) 40%);
}

/* Auth page: the decor needs more presence on a white background. */
[data-theme='light'] .decor-lines .curve {
  opacity: 0.34;
}

[data-theme='light'] .decor-orb.o1 {
  background: radial-gradient(circle, rgba(35, 80, 122, 0.2), transparent 70%);
}

[data-theme='light'] .decor-orb.o2 {
  background: radial-gradient(circle, rgba(35, 80, 122, 0.15), transparent 70%);
}

[data-theme='light'] .auth-intro {
  background:
    radial-gradient(ellipse 90% 60% at 0% 0%, rgba(35, 80, 122, 0.05), transparent 70%),
    var(--paper);
}

/* System theme keeps a light chat, so it gets the same soft wash. */

/* ==================== RESPONSIVE: TABLET ==================== */

@media (max-width: 1024px) {
  .info-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
  .upgrade-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .panel-inner {
    max-width: 100%;
  }
  .thread,
  .welcome,
  .composer {
    max-width: 100%;
  }
}

/* ==================== RESPONSIVE: PHONE ==================== */

@media (max-width: 640px) {
  /* Dialogs must never overflow the viewport. */
  .overlay {
    padding: 10px;
    align-items: center;
  }
  .dialog {
    max-height: calc(100vh - 20px);
    padding: 16px;
    border-radius: 10px;
  }
  .dialog.wide {
    max-width: 100%;
  }
  .dialog-foot {
    flex-wrap: wrap;
  }
  .dialog-foot .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .confirm-actions {
    flex-direction: column-reverse;
  }
  .confirm-actions .btn {
    width: 100%;
    min-width: 0;
  }

  /* Grids collapse to a single column. */
  .info-grid,
  .upgrade-grid {
    grid-template-columns: 1fr;
  }
  .stat-row {
    grid-template-columns: 1fr 1fr;
  }
  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }
  .info-row {
    flex-direction: column;
    gap: 2px;
  }
  .info-row strong {
    min-width: 0;
  }

  /* Duration pickers and action rows wrap instead of overflowing. */
  .dur-row {
    flex-wrap: wrap;
  }
  .uprole-actions {
    gap: 6px;
  }
  .uprole-actions .btn {
    flex: 1 1 auto;
  }
  .uprole-actions .dur-row {
    width: 100%;
  }

  /* Composer and message tools wrap. */
  .composer-bar {
    flex-wrap: wrap;
  }
  .msg-tools,
  .dm-tools {
    flex-wrap: wrap;
  }
  .quota-strip {
    flex-wrap: wrap;
  }
  .table-box {
    -webkit-overflow-scrolling: touch;
  }

  /* Auth page: compact but still readable. */
  .auth-intro {
    padding: 20px 16px 16px;
    gap: 20px;
  }
  .auth-form-col {
    padding: 20px 16px 28px;
  }
  .auth-intro h1 {
    font-size: 21px;
  }
  .auth-intro .lede {
    font-size: 13px;
  }
  .spec-list {
    gap: 10px 16px;
    padding-top: 18px;
  }
  .tier-table {
    font-size: 11px;
  }
  .tier-table th,
  .tier-table td {
    padding: 6px 5px;
  }
  .contact-inline {
    flex-direction: column;
    gap: 6px;
  }

  /* Decor: smaller orbs, fewer sparkles so the phone stays light. */
  .decor-orb.o1 {
    width: 260px;
    height: 260px;
    left: -100px;
    top: -110px;
  }
  .decor-orb.o2 {
    width: 300px;
    height: 300px;
    right: -120px;
    bottom: -140px;
  }
  .spark.s13,
  .spark.s14,
  .spark.s15,
  .spark.s16 {
    display: none;
  }

  /* Panels and chat. */
  .panel-inner {
    padding: 16px 12px 28px;
  }
  .panel-inner h1 {
    font-size: 19px;
  }
  .thread {
    padding: 14px 12px 4px;
  }
  .composer-area {
    padding: 8px 10px 12px;
  }
  .dm,
  .bubble,
  .user-col {
    max-width: 100%;
  }
  .toasts {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
}

/* ==================== RESPONSIVE: SMALL PHONE ==================== */

@media (max-width: 400px) {
  .stat-row,
  .kpi-row {
    grid-template-columns: 1fr;
  }
  .auth-intro h1 {
    font-size: 19px;
  }
  .spec-list {
    grid-template-columns: 1fr;
  }
  .tier-table {
    font-size: 10.5px;
  }
  .tier-table th,
  .tier-table td {
    padding: 5px 4px;
  }
  .select-btn {
    max-width: 40vw;
    font-size: 11.5px;
  }
  .composer textarea {
    font-size: 13.5px;
  }
  .prose {
    font-size: 13.5px;
  }
  .dialog {
    padding: 14px;
  }
  .dialog-head h3 {
    font-size: 15px;
  }
  .dur-row input {
    width: 52px;
  }
  .wordmark {
    font-size: 15px;
  }
  .wordmark .logo {
    width: 26px;
    height: 26px;
  }
}

/* Landscape phones: keep the composer reachable. */
@media (max-height: 480px) and (orientation: landscape) {
  .welcome {
    padding: 20px 16px;
    justify-content: flex-start;
  }
  .welcome h1 {
    font-size: 20px;
  }
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .auth-intro {
    padding: 18px 16px;
  }
}

/* ===================== WELCOME GATE (after login) ===================== */

:root {
  --cloud-dur: 3.6s;
}

@media (max-width: 1024px) {
  :root {
    --cloud-dur: 3s;
  }
}

@media (max-width: 640px) {
  :root {
    --cloud-dur: 2.4s;
  }
}

.welcome-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 18px;
  overflow-y: auto;
  background: var(--paper);
}

.gate-card {
  width: 100%;
  max-width: 620px;
  margin: auto;
  padding: 26px 26px 22px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-md);
  animation: gateIn 0.32s ease both;
}

@keyframes gateIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.gate-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.gate-logo {
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 9px;
  object-fit: cover;
  border: 1px solid var(--rule);
}

.gate-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.gate-head h1 {
  margin: 4px 0 0;
  font-size: 25px;
  font-weight: 650;
}

.gate-block {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.gate-label {
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.gate-countdown {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.cd-cell {
  flex: 1 1 76px;
  min-width: 64px;
  padding: 9px 4px 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.cd-cell strong {
  display: block;
  font-size: 22px;
  font-weight: 650;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.cd-cell span {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cd-cell.cd-ms {
  flex: 1 1 96px;
}

.cd-cell.cd-ms strong {
  font-size: 19px;
  color: var(--accent);
}

.gate-expiry {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.gate-expiry.permanent {
  color: var(--ok);
  font-weight: 550;
}

.gate-role-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.gate-role-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gate-role-note {
  font-size: 12.5px;
  color: var(--muted);
}

.gate-benefits {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.gate-benefits li {
  position: relative;
  padding-left: 22px;
  font-size: 13px;
  color: var(--ink-2);
}

.gate-benefits li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 6px;
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--ok);
  border-bottom: 2px solid var(--ok);
  transform: rotate(-45deg);
}

.gate-start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 18px;
  padding: 13px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
}

.gate-start:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.gate-start svg {
  transition: transform 0.2s ease;
}

.gate-start:hover svg {
  transform: translateX(3px);
}

.gate-hint {
  margin: 10px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

/* ======================= CLOUD SCREEN TRANSITION ====================== */

.cloud-veil {
  position: fixed;
  inset: 0;
  z-index: 420;
  overflow: hidden;
  pointer-events: none;
  --cloud: #ffffff;
}

[data-theme='dark'] .cloud-veil {
  --cloud: #eef1f6;
}

.cloud-side {
  position: absolute;
  inset: 0;
}

.cloud-bank {
  position: absolute;
  top: -18%;
  bottom: -18%;
  width: 92%;
  will-change: transform;
  filter: drop-shadow(0 0 2vh rgba(23, 24, 26, 0.1));
}

.cloud-left .cloud-bank {
  left: 0;
  transform: translateX(-125%);
}

.cloud-right .cloud-bank {
  right: 0;
  transform: translateX(125%);
}

.cloud-bank .fill {
  position: absolute;
  inset: 0;
  background: var(--cloud);
}

.cloud-bank .puff {
  position: absolute;
  border-radius: 50%;
  background: var(--cloud);
  box-shadow: 0 0 2.4vh 1.1vh var(--cloud);
}

.cloud-left .p1 { top: -8vh;  right: -7vh;  width: 34vh; height: 34vh; }
.cloud-left .p2 { top: 11vh;  right: -19vh; width: 46vh; height: 46vh; }
.cloud-left .p3 { top: 35vh;  right: -10vh; width: 36vh; height: 36vh; }
.cloud-left .p4 { top: 55vh;  right: -21vh; width: 50vh; height: 50vh; }
.cloud-left .p5 { top: 81vh;  right: -11vh; width: 38vh; height: 38vh; }
.cloud-left .p6 { top: 99vh;  right: -17vh; width: 42vh; height: 42vh; }

.cloud-right .p1 { top: -8vh;  left: -7vh;  width: 34vh; height: 34vh; }
.cloud-right .p2 { top: 11vh;  left: -19vh; width: 46vh; height: 46vh; }
.cloud-right .p3 { top: 35vh;  left: -10vh; width: 36vh; height: 36vh; }
.cloud-right .p4 { top: 55vh;  left: -21vh; width: 50vh; height: 50vh; }
.cloud-right .p5 { top: 81vh;  left: -11vh; width: 38vh; height: 38vh; }
.cloud-right .p6 { top: 99vh;  left: -17vh; width: 42vh; height: 42vh; }

.cloud-veil.run .cloud-left .cloud-bank {
  animation: cloudSweepRight var(--cloud-dur) cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

.cloud-veil.run .cloud-right .cloud-bank {
  animation: cloudSweepLeft var(--cloud-dur) cubic-bezier(0.45, 0, 0.55, 1) forwards;
}

@keyframes cloudSweepRight {
  from { transform: translateX(-125%); }
  to   { transform: translateX(125%); }
}

@keyframes cloudSweepLeft {
  from { transform: translateX(125%); }
  to   { transform: translateX(-125%); }
}

@media (max-width: 640px) {
  .welcome-gate {
    padding: 16px 12px;
  }
  .gate-card {
    padding: 20px 16px 18px;
  }
  .gate-head h1 {
    font-size: 21px;
  }
  .gate-logo {
    width: 36px;
    height: 36px;
  }
  .cd-cell {
    flex: 1 1 30%;
    min-width: 0;
    padding: 8px 2px 6px;
  }
  .cd-cell strong {
    font-size: 19px;
  }
  .cd-cell.cd-ms {
    flex: 1 1 100%;
  }
  .gate-benefits li {
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --cloud-dur: 0.6s;
  }
  .gate-card {
    animation: none;
  }
}

/* ==================== SMOOTH SCROLLING EVERYWHERE ==================== */

/* Native smooth scrolling makes wheel/trackpad and programmatic jumps feel
   continuous instead of snapping. `overscroll-behavior` keeps the page from
   rubber-banding when an inner list reaches its end. */
html {
  scroll-behavior: smooth;
}

.scroll,
.panel,
.popover,
.sheet-body,
.dm-list,
.community-list,
.feedback-list,
.feedback-thread,
.dialog,
.sidebar {
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@media (prefers-reduced-motion: reduce) {
  html,
  .scroll,
  .panel,
  .popover,
  .sheet-body,
  .dm-list,
  .community-list,
  .feedback-list,
  .feedback-thread,
  .dialog,
  .sidebar {
    scroll-behavior: auto;
  }
}

/* ============== LIVE RESET / LIFETIME LABELS ============== */

.tb-reset {
  font-size: 11px;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.qreset,
.qlife {
  margin: 2px 0 6px;
  font-size: 10.5px;
  color: var(--sidebar-muted);
  font-variant-numeric: tabular-nums;
}

.qlife {
  margin: 6px 0 0;
  padding-top: 6px;
  border-top: 1px solid var(--sidebar-rule);
}

.qstrip-reset {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.qstrip-reset b {
  font-weight: 650;
}

/* Phones and tablets use a centred sheet instead of the anchored popover, so
   the marker chip would duplicate the sheet header. */
@media (max-width: 1024px) {
  .tb-reset {
    display: none;
  }
}

/* ==================== COMPACT PICKER SHEET ==================== */

.sheet-root {
  position: fixed;
  inset: 0;
  z-index: 330;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 17, 21, 0.5);
  animation: sheetFade 0.18s ease both;
}

@keyframes sheetFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  max-height: min(86vh, 620px);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: sheetRise 0.22s ease both;
}

@keyframes sheetRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--rule);
}

.sheet-head h3 {
  margin: 0;
  font-size: 16px;
}

.sheet-head p {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sheet-close {
  margin-left: auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
}

.sheet-close:hover {
  background: var(--surface);
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
}

.sheet-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
}

.sheet-item:hover {
  background: var(--surface);
}

.sheet-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.sheet-item.disabled {
  opacity: 0.6;
}

.sheet-item .dot {
  width: 4px;
  align-self: stretch;
  border-radius: 3px;
  flex: none;
}

.sheet-txt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.sheet-txt strong {
  font-size: 13.5px;
  font-weight: 600;
}

.sheet-txt small {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
}

.sheet-txt .sheet-state {
  color: var(--ink-2);
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

.sheet-check {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .sheet-root {
    padding: 10px;
    align-items: center;
  }
  .sheet-card {
    max-height: 88vh;
  }
  .sheet-head h3 {
    font-size: 15px;
  }
}

/* ==================== QUOTA EXHAUSTED ALERT ==================== */

.quota-alert {
  max-width: 420px;
  text-align: center;
}

.quota-alert-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--warn-soft);
  color: var(--warn);
}

.quota-alert h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.quota-alert p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-2);
}

.quota-alert-reset {
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.quota-alert .confirm-actions {
  justify-content: center;
}

/* ==================== OWNER: ACTIVE PERIOD CONTROLS ==================== */

.active-left {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.active-left.permanent {
  color: var(--ok);
}

.extend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.extend-row input {
  width: 74px;
  padding: 6px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--paper);
  font-size: 12.5px;
}

.extend-row select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--paper);
  font-size: 12.5px;
}

.extend-label {
  display: block;
  margin-top: 8px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* ==================== CLOUD REVEAL (visible pass) ==================== */

/* White clouds on white paper were invisible, so the veil now dims the page a
   little and the clouds carry a soft grey edge. */
.cloud-veil {
  --cloud: #eef2f8;
  --cloud-shade: rgba(23, 24, 26, 0.16);
  background: rgba(23, 24, 26, 0);
  animation: veilDim var(--cloud-dur) ease-in-out forwards;
}

[data-theme='dark'] .cloud-veil {
  --cloud: #dfe6f0;
  --cloud-shade: rgba(0, 0, 0, 0.45);
  background: rgba(0, 0, 0, 0);
}

@keyframes veilDim {
  0%   { background-color: rgba(23, 24, 26, 0); }
  35%  { background-color: rgba(23, 24, 26, 0.16); }
  70%  { background-color: rgba(23, 24, 26, 0.16); }
  100% { background-color: rgba(23, 24, 26, 0); }
}

[data-theme='dark'] .cloud-veil {
  animation-name: veilDimDark;
}

@keyframes veilDimDark {
  0%   { background-color: rgba(0, 0, 0, 0); }
  35%  { background-color: rgba(0, 0, 0, 0.35); }
  70%  { background-color: rgba(0, 0, 0, 0.35); }
  100% { background-color: rgba(0, 0, 0, 0); }
}

.cloud-bank {
  filter: drop-shadow(0 0 2.2vh var(--cloud-shade));
}

.cloud-veil.run .cloud-bank {
  animation-timing-function: cubic-bezier(0.38, 0.02, 0.5, 1);
}

.cloud-bank .puff {
  box-shadow: 0 0 2.6vh 1.2vh var(--cloud);
}

/* ==================== THEME SWITCH + FINAL POLISH ==================== */

html {
  color-scheme: light;
}

[data-theme='dark'] {
  color-scheme: dark;
}

body,
.auth-page,
.sidebar,
.topbar,
.composer,
.dialog,
.popover,
.panel-inner {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.theme-toggle .ic-moon,
.theme-toggle.is-dark .ic-sun {
  display: none;
}

.theme-toggle.is-dark .ic-moon {
  display: inline-block;
}

.theme-toggle-auth {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 6;
  box-shadow: var(--shadow-sm);
}

[data-theme='dark'] .theme-toggle {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--ink);
}

/* Soft drifting clouds behind the auth page. They give the landing page depth
   without turning it into a decorative gradient. */
.decor-cloud {
  position: absolute;
  border-radius: 999px;
  background: var(--surface-2);
  filter: blur(28px);
  opacity: 0.55;
  pointer-events: none;
  animation: cloudFloat 26s ease-in-out infinite alternate;
}

.decor-cloud.dc1 {
  width: 360px;
  height: 120px;
  left: 8%;
  top: 26%;
  animation-duration: 30s;
}

.decor-cloud.dc2 {
  width: 460px;
  height: 150px;
  right: 4%;
  top: 58%;
  opacity: 0.42;
  animation-duration: 38s;
  animation-direction: alternate-reverse;
}

.decor-cloud.dc3 {
  width: 280px;
  height: 96px;
  left: 42%;
  bottom: 8%;
  opacity: 0.35;
  animation-duration: 34s;
}

[data-theme='dark'] .decor-cloud {
  background: rgba(111, 159, 216, 0.16);
  opacity: 0.5;
}

@keyframes cloudFloat {
  from { transform: translate3d(-18px, 8px, 0) scale(0.98); }
  to   { transform: translate3d(26px, -12px, 0) scale(1.05); }
}

/* Live thinking panel: the reader sees the actual analysis, not a spinner. */
.thinking-note {
  margin: 0 0 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
}

.thinking-note strong {
  color: var(--ink-2);
}

[data-theme='dark'] .thinking-note {
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .decor-cloud {
    animation: none;
  }
}

@media (max-width: 640px) {
  .theme-toggle-auth {
    top: 12px;
    right: 12px;
  }

  .theme-toggle-auth span {
    display: none;
  }

  .theme-toggle {
    padding: 0 8px;
  }
}

/* Final override: a word that has not been revealed yet must stay invisible,
   even if a theme stylesheet sets colour on it. */
.prose.typing .w:not(.on) {
  opacity: 0;
}


/* ================================================================== */
/* ============ KOMUNITAS · RIWAYAT PIN · CHAT OWNER ================ */
/* ================================================================== */

/* ---------------------------- badges ---------------------------------- */

.count.mention-count {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: #c0392b;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.btn .mention-count {
  margin-left: 6px;
  background: var(--danger);
  color: #fff;
}

.btn .mention-count.hidden,
.count.mention-count.hidden {
  display: none;
}

/* ------------------------- riwayat + pin ------------------------------- */

.history-pinned {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--sidebar-rule);
  max-height: 42%;
  overflow-y: auto;
}

.history-pinned.hidden {
  display: none;
}

.side-label.pinned-label {
  margin: 0 0 2px;
  color: var(--sidebar-muted);
}

.hist {
  position: relative;
  cursor: pointer;
}

.hist.pinned .hist-title {
  font-weight: 600;
}

.pin-dot {
  font-size: 10px;
  margin-right: 2px;
}

.hist-more {
  flex: none;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.hist:hover .hist-more,
.hist.active .hist-more,
.hist-more:focus-visible {
  opacity: 1;
}

.hist-more:hover {
  background: var(--sidebar-rule);
  color: var(--sidebar-ink);
}

.hist-menu {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  padding: 5px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-md);
}

.hist-menu.hidden {
  display: none;
}

.hm-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.hm-item:hover {
  background: var(--surface-2);
}

.hm-item.danger {
  color: var(--danger);
}

/* --------------------------- community -------------------------------- */

.community-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.community-head h1 {
  margin: 0 0 4px;
}

.community-head .lede {
  margin: 0;
}

.community-scroll {
  position: relative;
  flex: 1;
  min-height: 320px;
  max-height: 58vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 12px;
}

.community-list {
  margin-bottom: 0;
}

.dm-time {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.day-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.day-sep::before,
.day-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.day-sep span {
  padding: 1px 8px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--paper);
  white-space: nowrap;
}

.dm.highlight {
  animation: dmHighlight 2.4s ease;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

@keyframes dmHighlight {
  0% {
    background: var(--accent-soft);
  }
  100% {
    background: var(--paper);
  }
}

.dm.removed {
  border-style: dashed;
  background: var(--surface-2);
}

.mention {
  padding: 0 3px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.mention.all {
  background: var(--warn-soft);
  color: var(--warn);
}

.mention-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.mention-chip {
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--surface);
  font-size: 10.5px;
  color: var(--muted);
}

.mention-chip.all {
  border-color: #e6d5b0;
  background: var(--warn-soft);
  color: var(--warn);
}

.pin-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding: 7px 9px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.pin-bar.hidden {
  display: none;
}

.pin-label {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.pin-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 280px;
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11.5px;
  cursor: pointer;
}

.pin-item:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.pin-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jump-btn {
  position: relative;
  z-index: 5;
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 7px;
  margin: -46px auto 10px;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--paper);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

.jump-btn.hidden {
  display: none;
}

.load-more {
  display: block;
  margin: 8px auto;
  padding: 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 20px;
  background: var(--paper);
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}

.load-more.hidden {
  display: none;
}

.composer-hint {
  margin: 0;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.composer-hint.hidden {
  display: none;
}

/* --------------------------- mention popup ----------------------------- */

.mention-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-md);
}

.mention-pop.hidden {
  display: none;
}

.dm-form {
  position: relative;
}

.mention-opt {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.mention-opt:hover,
.mention-opt:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.mention-opt .txt {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mention-opt .txt strong {
  font-size: 12.5px;
}

.mention-opt .txt small {
  color: var(--muted);
  font-size: 11px;
}

.mention-opt.all .avatar {
  background: var(--warn-soft);
  color: var(--warn);
}

.mention-opt .avatar {
  width: 24px;
  height: 24px;
  font-size: 11px;
}

/* --------------------------- mentions dialog --------------------------- */

.mentions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
}

.mention-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.mention-row:hover {
  border-color: var(--accent);
}

.mention-row.unread {
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
}

.mr-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
}

.mr-head strong {
  color: var(--ink);
  font-size: 12.5px;
}

.mr-recipient {
  color: var(--accent);
}

.mr-when {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.mr-body {
  font-size: 13px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

/* -------------------------- moderation panel --------------------------- */

.mod-mute {
  padding: 11px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  background: var(--surface);
}

.mm-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.mm-left {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--danger);
  font-variant-numeric: tabular-nums;
}

.mm-detail {
  margin: 5px 0 8px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.input-sm {
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}

.mod-history {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 320px;
  overflow-y: auto;
}

.mod-row {
  display: grid;
  grid-template-columns: 130px 90px minmax(90px, 1fr) minmax(120px, 1.4fr) 90px;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
  font-size: 11.5px;
}

.mod-row:last-child {
  border-bottom: 0;
}

.mr-action {
  font-weight: 600;
  color: var(--danger);
}

.mr-action.ok {
  color: var(--ok);
}

.mr-who,
.mr-target,
.mr-why {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mr-when {
  text-align: right;
  color: var(--muted);
}

.cmd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px;
}

.cmd-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font-size: 11.5px;
}

.cmd-row code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}

.cmd-row span {
  color: var(--muted);
}

/* ---------------------------- owner chat ------------------------------- */

.oc-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.oc-title {
  flex: 1;
  min-width: 160px;
}

.oc-title h1 {
  margin: 0 0 2px;
}

.oc-title .lede {
  margin: 0;
}

.oc-head .input {
  max-width: 260px;
}

.oc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.oc-list.hidden {
  display: none;
}

.oc-thread.hidden {
  display: none;
}

.oc-thread {
  display: flex;
  flex-direction: column;
}

.thread-row.has-unread {
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
}

.oc-thread .dm-list {
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

/* ------------------------------- viewer -------------------------------- */

.viewer-overlay {
  z-index: 1300;
  background: rgba(12, 14, 17, 0.82);
}

.viewer-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 980px);
  max-height: 92vh;
  padding: 14px;
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--shadow-md);
}

.viewer-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: rgba(16, 18, 22, 0.55);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.viewer-nav:hover {
  background: rgba(16, 18, 22, 0.8);
}

.viewer-prev {
  left: 10px;
}

.viewer-next {
  right: 10px;
}

.viewer-caption {
  text-align: center;
  font-size: 12px;
  color: var(--ink-2);
  padding: 0 8px;
}

.viewer-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.viewer-stage img {
  display: block;
  max-width: 100%;
  max-height: 74vh;
  transition: transform 0.12s ease;
  transform-origin: center center;
}

.viewer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.viewer-zoom {
  min-width: 54px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.viewer-card .dialog-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}

button.dm-image,
button.fth-attach,
button.thumb-btn {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  text-align: left;
}

button.thumb-btn img {
  border-radius: 6px;
}

/* ---------------------------- per-level caps --------------------------- */

.cap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 7px;
  margin: 6px 0;
}

.cap-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
}

.cap-row input {
  width: 84px;
  padding: 4px 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  background: var(--paper);
  text-align: right;
}

/* ------------------------------ mobile --------------------------------- */

@media (max-width: 640px) {
  .community-scroll {
    max-height: 52vh;
    padding: 9px;
  }

  .oc-thread .dm-list {
    max-height: 46vh;
  }

  .mod-row {
    grid-template-columns: 1fr 1fr;
  }

  .mr-when {
    text-align: left;
  }

  .viewer-card {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* ------------------------------- dark ---------------------------------- */

[data-theme="dark"] .mention-row.unread,
[data-theme="dark"] .thread-row.has-unread {
  background: #2a1c1b;
}

[data-theme="dark"] .pin-bar {
  background: #232529;
}

[data-theme="dark"] .day-sep span {
  background: #1b1d21;
}

/* ==================================================================
   BIM AI — MOTION SYSTEM + NEW COMPONENTS (updated build)
   ------------------------------------------------------------------
   Rules kept from the original identity: solid fills, 1px rules, one
   accent, no glass, no decorative gradients. Everything added here is
   either a real component (pagers, directories, menus) or a motion
   layer with a purpose: it shows what changed, what is loading, and
   what a control does when touched.
   ================================================================== */

:root {
  /* Motion: three durations and three curves, used everywhere below so
     timing stays consistent instead of every component inventing its own. */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.25, 1.12);

  --elev-1: 0 1px 2px rgba(23, 24, 26, 0.06);
  --elev-2: 0 4px 14px rgba(23, 24, 26, 0.08);
  --elev-3: 0 10px 30px rgba(23, 24, 26, 0.12);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

[data-theme='dark'] {
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --elev-2: 0 6px 18px rgba(0, 0, 0, 0.55);
  --elev-3: 0 14px 36px rgba(0, 0, 0, 0.6);
}

/* ------------------------------ keyframes ------------------------------ */

@keyframes bim-rise {
  from {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes bim-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bim-pop {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes bim-slide-in {
  from {
    opacity: 0;
    transform: translate3d(18px, 0, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes bim-shimmer {
  from {
    background-position: -160% 0;
  }
  to {
    background-position: 260% 0;
  }
}

@keyframes bim-ring {
  0% {
    transform: scale(0.82);
    opacity: 0.55;
  }
  70% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

@keyframes bim-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes bim-pulse-soft {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.14);
  }
}

@keyframes bim-badge-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes bim-bar-grow {
  from {
    transform: scaleY(0.04);
  }
  to {
    transform: scaleY(1);
  }
}

/* One utility used by every list that renders rows in sequence: the delay is
   passed inline as --delay so a list animates in order, never all at once. */
.rise {
  animation: bim-rise var(--dur-slow) var(--ease-out) both;
  animation-delay: var(--delay, 0ms);
}

.fade-in {
  animation: bim-fade var(--dur-base) var(--ease-out) both;
}

/* --------------------------- view transitions -------------------------- */

/* Every panel that becomes active fades and lifts once, so switching menus
   reads as a change of place instead of an instant swap. */
.panel:not(.hidden) {
  animation: bim-rise var(--dur-slow) var(--ease-out) both;
}

.side-item {
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.side-item:hover {
  transform: translateX(2px);
}

.side-item.active {
  transform: none;
}

.tab {
  position: relative;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.tab::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--dur-base) var(--ease-out);
}

.tab:hover::after {
  transform: scaleX(0.4);
}

.tab.active::after {
  transform: scaleX(1);
}

.tab-panel.active,
.uprole-pane:not(.hidden) {
  animation: bim-rise var(--dur-base) var(--ease-out) both;
}

/* ---------------------------- micro-interactions ----------------------- */

.btn {
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn:hover:not(:disabled) {
  box-shadow: var(--elev-2);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0) scale(0.985);
  box-shadow: var(--elev-1);
}

.btn:focus-visible {
  box-shadow: var(--ring);
}

.btn-primary {
  box-shadow: var(--elev-1);
}

.btn.is-busy {
  cursor: progress;
}

/* A busy button keeps its width: the spinner replaces the label's opacity
   instead of the label disappearing. */
.btn.is-busy > span {
  opacity: 0.65;
}

.btn-sm {
  transition-duration: var(--dur-fast);
}

.tiles .tile,
.info-card,
.uprole-card,
.banned-card,
.memory-item,
.dm {
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out);
}

.tile:hover,
.info-card:hover,
.banned-card:hover {
  border-color: var(--rule-strong);
  box-shadow: var(--elev-2);
  transform: translateY(-2px);
}

.stat {
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.stat strong {
  font-variant-numeric: tabular-nums;
}

/* Summary cards that act as filters get an obvious selected state. */
.stat-btn {
  text-align: left;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: var(--paper);
}

.stat-btn:hover {
  border-color: var(--rule-strong);
  box-shadow: var(--elev-1);
}

.stat-btn.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.badge {
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.badge.pop,
.count.pop {
  animation: bim-badge-pop var(--dur-slow) var(--ease-spring);
}

/* ------------------------------- popups -------------------------------- */

.overlay {
  animation: bim-fade var(--dur-fast) var(--ease-out) both;
  backdrop-filter: blur(2px);
}

.dialog,
.popover {
  animation: bim-pop var(--dur-base) var(--ease-spring) both;
}

.popover {
  transform-origin: top right;
}

.dialog.wide {
  animation-duration: var(--dur-base);
}

/* The ban popup is deliberately outside the normal dismiss flow: the account
   cannot be used, so it ignores clicks on the backdrop (no handler) and keeps
   the page inert until the logout finishes. */
.ban-overlay {
  z-index: 200;
  backdrop-filter: blur(3px);
}

.ban-dialog {
  max-width: 460px;
  border-color: var(--danger);
}

body.ban-locked {
  overflow: hidden;
}

/* ------------------------------- toasts -------------------------------- */

.toast {
  animation: bim-slide-in var(--dur-base) var(--ease-out) both;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

/* ------------------------------- loading ------------------------------- */

/* The BIM AI loader: a soft accent ring with a pulsing halo. It reads as this
   product, not as a stock spinner. */
.ai-orb {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-top-color: var(--accent);
  animation: bim-spin 900ms linear infinite;
}

.ai-orb::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  animation: bim-ring 1800ms var(--ease-out) infinite;
}

.skeleton-list {
  display: grid;
  gap: 8px;
}

.skeleton-list span,
.skeleton {
  display: block;
  height: 46px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface-2) 40%,
    var(--surface) 80%
  );
  background-size: 220% 100%;
  animation: bim-shimmer 1400ms linear infinite;
}

.skeleton-row {
  height: 12px;
  margin: 6px 0;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .ai-orb,
  .ai-orb::after,
  .skeleton-list span,
  .skeleton {
    animation: none;
  }
}

/* ------------------------------- pager --------------------------------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}

.pager .btn {
  min-width: 108px;
}

.pager-info {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.pager .btn:disabled {
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

/* --------------------------- up role information ----------------------- */

.uprole-tabs {
  margin-top: 4px;
}

.uprole-pane {
  margin-top: 4px;
}

.uprole-pane.hidden {
  display: none;
}

.uprole-card.status-row {
  cursor: default;
}

.uprole-status {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--surface);
  color: var(--ink-2);
}

.uprole-status.new {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--rule-strong));
  background: var(--accent-soft);
  color: var(--accent);
}

.uprole-status.process {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--rule-strong));
  background: var(--warn-soft);
  color: var(--warn);
}

.uprole-status.done {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--rule-strong));
  background: var(--ok-soft);
  color: var(--ok);
}

.uprole-status.rejected {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--rule-strong));
  background: var(--danger-soft);
  color: var(--danger);
}

.uprole-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ----------------------- banned account directory ---------------------- */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.search-field {
  flex: 1 1 260px;
  min-width: 220px;
}

.select-field {
  flex: 0 1 230px;
}

.search-field input,
.select-field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.search-field input:focus,
.select-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.banned-box {
  min-height: 90px;
}

.banned-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.banned-card {
  display: grid;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--elev-1);
  border-left: 3px solid var(--danger);
}

.bc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bc-id {
  display: grid;
  min-width: 0;
}

.bc-id strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.bc-id small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.bc-rows {
  display: grid;
  gap: 6px;
  margin: 0;
}

.bc-rows > div {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  align-items: baseline;
}

.bc-rows dt {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted-2);
}

.bc-rows dd {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.bc-left {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

.bc-left.soon {
  color: var(--danger);
}

.bc-forever {
  color: var(--danger);
  font-weight: 600;
}

[data-theme='dark'] .banned-card {
  background: #14171d;
  border-color: #2a2f38;
  border-left-color: var(--danger);
}

[data-theme='dark'] .search-field input,
[data-theme='dark'] .select-field select,
[data-theme='dark'] .stat-btn {
  background: #0c0e12;
  border-color: #2a2f38;
  color: var(--ink);
}

[data-theme='dark'] .bc-left {
  color: var(--ink);
}

/* ---------------------------- responsive -------------------------------- */

/* Tablets: the directory gets two columns at most, and dialogs use the full
   height they are given instead of a fixed maximum. */
@media (max-width: 1024px) {
  .banned-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* Phones: every list becomes a single column, the toolbar stacks, and the
   pager keeps its buttons reachable with one thumb. */
@media (max-width: 640px) {
  .banned-grid {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-field,
  .select-field {
    flex: 1 1 auto;
    min-width: 0;
  }

  .pager {
    gap: 8px;
  }

  .pager .btn {
    min-width: 0;
    flex: 1 1 0;
  }

  .pager-info {
    order: -1;
    width: 100%;
  }

  .dialog {
    max-height: calc(100dvh - 24px);
  }

  .overlay {
    padding: 12px;
  }

  .bc-rows > div {
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .uprole-actions {
    gap: 6px;
  }

  .uprole-actions .btn {
    flex: 1 1 auto;
  }
}

/* Landscape phones: the directory cards and dialogs must not exceed the
   viewport height that is actually available. */
@media (max-height: 480px) and (orientation: landscape) {
  .banned-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .dialog {
    max-height: calc(100dvh - 16px);
  }
}

/* Long content must never be clipped: usernames, emails, reasons, and table
   cells all wrap instead of overflowing their container. */
.bc-id strong,
.bc-id small,
.bc-rows dd,
.grid td,
.grid th,
.dm-body p,
.info-row span,
.mem-body {
  overflow-wrap: anywhere;
}

/* A freshly published answer enters as one block, so the reader sees the
   thinking panel turn into a real answer instead of a silent swap. */
.msg.msg-enter {
  animation: bim-rise 380ms var(--ease-out) both;
}

/* The thinking panel's own loader: soft pulse, never a hard spin in the
   middle of the reader's line. */
.thinking-head .ai-orb {
  margin-right: 2px;
}

.thinking-label {
  animation: bim-pulse-soft 2600ms var(--ease-in-out) infinite;
}

@media (prefers-reduced-motion: reduce) {
  .msg.msg-enter,
  .thinking-label {
    animation: none !important;
  }
}

/* Reduced motion: every animation added in this section is switched off, and
   the interface keeps its final state (no elements stuck at opacity 0). */
@media (prefers-reduced-motion: reduce) {
  .rise,
  .fade-in,
  .panel:not(.hidden),
  .tab-panel.active,
  .uprole-pane:not(.hidden),
  .overlay,
  .dialog,
  .popover,
  .toast {
    animation: none !important;
  }

  .btn:hover:not(:disabled),
  .tile:hover,
  .info-card:hover,
  .banned-card:hover,
  .side-item:hover {
    transform: none;
  }
}

/* ==================================================================
   OWNER DASHBOARD — DETAIL DIALOG, 3D CARDS, RESPONSIVE TABLE
   ------------------------------------------------------------------
   The Aksi column is now a single Detail button; everything else lives
   in a dialog made of stacked cards. Each card can be tilted slightly in
   3D with the pointer, and the whole table turns into labelled cards on
   a phone instead of a horizontally scrolled grid.
   ================================================================== */

/* The tilt is driven by two custom properties the script writes on
   pointer move; without a pointer the card simply stays flat. */
.detail-card,
.stat-3d {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
}

.stat-3d {
  transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  transform-style: preserve-3d;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
  will-change: transform;
}

.stat-3d:hover {
  border-color: var(--rule-strong);
  box-shadow: var(--elev-3);
}

.detail-card {
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  position: relative;
  margin-top: 12px;
  padding: 14px 15px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--elev-1);
  transform: perspective(1100px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  transform-style: preserve-3d;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
  will-change: transform;
}

.detail-card:hover {
  border-color: var(--rule-strong);
  box-shadow: var(--elev-2);
}

.detail-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.detail-card h4 {
  margin: 0;
  font-size: 13.5px;
  letter-spacing: 0.01em;
}

.detail-hint {
  font-size: 11px;
  color: var(--muted);
}

.detail-card .chart-sub {
  margin: 0 0 10px;
}

.detail-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* A faint sheen across the top edge gives the card depth without glass. */
.detail-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 42%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent);
  pointer-events: none;
}

[data-theme='dark'] .detail-card {
  background: #14171d;
  border-color: #2a2f38;
}

/* ---------------------------- status chips ---------------------------- */

.detail-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -4px 0 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.chip.ok {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--rule-strong));
  background: var(--ok-soft);
  color: var(--ok);
}

.chip.danger {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--rule-strong));
  background: var(--danger-soft);
  color: var(--danger);
}

.chip.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--rule-strong));
  background: var(--warn-soft);
  color: var(--warn);
}

.chip.save-chip {
  margin-left: auto;
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.chip.save-chip.busy {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  animation: bim-pulse-soft 1200ms var(--ease-in-out) infinite;
}

.chip.save-chip.ok {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--rule-strong));
  background: var(--ok-soft);
  color: var(--ok);
}

.chip.save-chip.error {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--rule-strong));
  background: var(--danger-soft);
  color: var(--danger);
}

/* ------------------------- masa aktif (live) -------------------------- */

.detail-card.live {
  border-left: 3px solid var(--accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 5%, var(--paper)), var(--paper));
}

.detail-live-left {
  margin: 2px 0 2px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.detail-live-left.expired {
  color: var(--danger);
}

.detail-live-end {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.detail-live-badge {
  padding: 2px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--paper);
  color: var(--muted);
}

.detail-live-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.live-field {
  display: grid;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.live-field small {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  color: var(--muted-2);
}

.live-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.life-end {
  color: var(--muted);
}

[data-theme='dark'] .detail-card.live {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 10%, #14171d), #14171d);
}

/* ---------------------------- role chips ------------------------------ */

.role-seg {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.role-chip {
  flex: 1 1 92px;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}

.role-chip:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--elev-2);
}

.role-chip:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.role-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--elev-2);
}

.role-chip:disabled {
  opacity: 0.6;
  cursor: progress;
}

[data-theme='dark'] .role-chip {
  background: #0c0e12;
  border-color: #2a2f38;
}

[data-theme='dark'] .role-chip.active {
  background: var(--accent);
  color: #0b0d11;
}

/* -------------------------- action cards ------------------------------ */

.detail-card.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--rule));
}

.detail-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.detail-action {
  display: grid;
  gap: 2px;
  padding: 11px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  text-align: left;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.detail-action strong {
  font-size: 13px;
  font-weight: 600;
}

.detail-action small {
  font-size: 11.5px;
  color: var(--muted);
}

.detail-action:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--elev-2);
}

.detail-action:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.detail-action.warn:hover:not(:disabled) {
  border-color: var(--warn);
}

.detail-action.ok strong {
  color: var(--ok);
}

.detail-action.danger {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--rule-strong));
}

.detail-action.danger strong {
  color: var(--danger);
}

.detail-action.danger:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: var(--danger);
}

[data-theme='dark'] .detail-action {
  background: #0c0e12;
  border-color: #2a2f38;
}

[data-theme='dark'] .detail-action.danger:hover:not(:disabled) {
  background: #261716;
}

/* The config block sits inside the account card instead of its own chart. */
.acct-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
}

.acct-block h5 {
  margin: 0 0 4px;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

/* The read-only access summary: what the account's ROLE grants. */
.acct-facts {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.acct-facts > div {
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--surface);
}

.acct-facts small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.acct-facts strong {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

/* --------------------- dashboard table → cards ------------------------ */

/* The Detail button reads as the row's primary affordance. */
.btn.btn-detail {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.btn.btn-detail:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (max-width: 820px) {
  /* A table with six columns cannot be read on a phone, so each row becomes a
     card: the identity line stays at the top, every other cell gets its column
     name from data-label. */
  .table-box.cardable {
    border: 0;
    overflow: visible;
    background: transparent;
  }

  .table-box.cardable table.grid {
    min-width: 0;
    display: block;
  }

  .table-box.cardable thead {
    display: none;
  }

  .table-box.cardable tbody {
    display: grid;
    gap: 10px;
  }

  .table-box.cardable tr {
    display: grid;
    gap: 6px;
    padding: 12px 13px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    background: var(--paper);
    box-shadow: var(--elev-1);
  }

  .table-box.cardable td {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 10px;
    align-items: baseline;
    padding: 0;
    border: 0;
    font-size: 12.5px;
  }

  .table-box.cardable td::before {
    content: attr(data-label);
    font-size: 10.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-2);
    font-weight: 600;
  }

  .table-box.cardable td[data-role='identity'] {
    display: block;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--rule);
  }

  .table-box.cardable td[data-role='identity']::before {
    content: none;
  }

  /* The action cell is a single button, so it spans the full card width. */
  .table-box.cardable td[data-label='Aksi'] {
    grid-template-columns: 1fr;
    margin-top: 2px;
  }

  .table-box.cardable td[data-label='Aksi']::before {
    content: none;
  }

  .table-box.cardable .btn-detail {
    width: 100%;
    padding: 10px 12px;
  }

  .dash-head {
    align-items: stretch;
  }

  .dash-head .row-actions {
    width: 100%;
  }

  .dash-head .row-actions .btn {
    flex: 1;
  }
}

/* Tablet: the table keeps its columns but the detail cards go two-up. */
@media (min-width: 641px) and (max-width: 1024px) {
  .detail-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-live-tools {
    grid-template-columns: 1fr;
  }
}

/* Phone: everything stacks, buttons stay thumb-sized, dialogs fit the screen. */
@media (max-width: 640px) {
  .detail-card {
    padding: 12px 12px;
    transform: none;
  }

  .stat-3d {
    transform: none;
  }

  .detail-live-left {
    font-size: 19px;
  }

  .detail-action-grid,
  .detail-live-tools {
    grid-template-columns: 1fr;
  }

  .role-chip {
    flex: 1 1 42%;
  }

  .chip.save-chip {
    margin-left: 0;
  }

  .detail-card .form-row {
    grid-template-columns: 1fr;
  }

  #userDialog .dialog {
    max-height: calc(100dvh - 16px);
  }
}

/* Landscape phones: the dialog must not push its buttons off screen. */
@media (max-height: 480px) and (orientation: landscape) {
  .detail-card.live {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
    align-items: start;
  }

  .detail-card.live > header,
  .detail-card.live > p {
    grid-column: 1;
  }

  .detail-card.live .detail-live-tools {
    grid-column: 2;
    grid-row: 1 / span 4;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

/* Touch devices have no pointer, so the tilt stays flat and the cards use a
   tap press state instead. */
@media (hover: none) {
  .detail-card,
  .stat-3d {
    transform: none;
  }

  .detail-card:active,
  .stat-3d:active {
    transform: scale(0.995);
  }
}

@media (prefers-reduced-motion: reduce) {
  .detail-card,
  .detail-action,
  .role-chip,
  .chip.save-chip,
  .stat-3d {
    transform: none;
    animation: none !important;
    transition: none;
  }
}

/* ==================================================================
   LOGIN PAGE — seamless auto-login
   ------------------------------------------------------------------
   The auth card stays hidden for the few milliseconds the remembered
   session is checked, so someone who is already signed in lands in the
   app without the login form flashing first. The class is added by
   script.js and always removed (fetch answer, error, or timeout).
   ================================================================== */

html.booting .auth-page {
  visibility: hidden;
}

/* ==================================================================
   OWNER TABLE — easier to scan, easier to reach
   ------------------------------------------------------------------
   Every row is a real button (whole line clickable, keyboard reachable,
   with a sliding accent bar), the identity cell carries an initial
   badge, and status is a proper chip instead of a one-off colour.
   ================================================================== */

table.grid .who-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.who-text {
  min-width: 0;
}

.who-avatar {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  transition: transform var(--dur-base) var(--ease-out), background var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}

tr.dash-row {
  cursor: pointer;
}

tr.dash-row td:first-child {
  position: relative;
}

/* The accent bar slides down the first cell on hover/focus: a small, quiet
   signal that the whole line is interactive. */
tr.dash-row td:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top center;
  transition: transform var(--dur-base) var(--ease-out);
}

tr.dash-row:hover td:first-child::before,
tr.dash-row:focus-visible td:first-child::before {
  transform: scaleY(1);
}

tr.dash-row:hover .who-avatar,
tr.dash-row:focus-visible .who-avatar {
  transform: scale(1.06);
  background: var(--accent);
  color: #fff;
}

tr.dash-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Zebra striping keeps a long account list aligned to the eye. */
table.grid tbody tr.dash-row:nth-child(even) td {
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}

table.grid tbody tr.dash-row:nth-child(even):hover td {
  background: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
  tr.dash-row td:first-child::before,
  .who-avatar {
    transition: none;
  }
}

/* One conversation of another account, with the owner's Pin control beside it. */
.user-chat-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.user-chat-row .thread-row {
  flex: 1;
  min-width: 0;
}

.user-chat-row .btn {
  align-self: center;
  flex: none;
}

/* ==================================================================
   END — motion system + components
   ================================================================== */

/* ==================================================================
   V4 — quota clarity, real depth, mobile-first login
   ------------------------------------------------------------------
   Layered on the same tokens as the rest of the system. The quota
   model now shows a role CAP and an owner BONUS separately (the bonus
   is spent first and always reads green), the owner table no longer
   scrolls sideways, popups get genuine depth instead of a flat sheet,
   and the login page opens on the product before it asks for a login.
   ================================================================== */

/* ---------------------------- bonus (green) ---------------------------- */

/* The owner's bonus is extra, never a ceiling, so it reads as a gain. */
.bonus {
  color: var(--ok);
  font-weight: 700;
  font-size: 10.5px;
  margin-left: 3px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.qrow .val .bonus,
.qlevel-chip .bonus,
.sheet-state .bonus,
.qlevel-use .bonus {
  font-size: 11px;
  font-weight: 700;
}

.qlevel-chip .bonus::before {
  content: ' ';
}

/* ------------------------ quota per level (owner) ---------------------- */

.qedit.qlevels {
  gap: 10px;
}

.qlevel {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: var(--elev-1);
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.qlevel:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-2);
  border-color: var(--rule-strong);
}

.qlevel.locked {
  opacity: 0.62;
}

.qlevel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 92%, var(--paper)) 0%,
    color-mix(in srgb, var(--surface) 55%, var(--paper)) 100%
  );
  border-bottom: 1px solid var(--rule);
}

.qlevel-name {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.qlevel-use {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.qlevel-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    'cap bonus'
    'meta meta';
  gap: 11px 14px;
  padding: 12px;
}

.qlevel-field:nth-of-type(1) {
  grid-area: cap;
}

.qlevel-field:nth-of-type(2) {
  grid-area: bonus;
}

.qedit .qlevel-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.qlevel-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--muted);
}

.qedit .qlevel-field input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--paper);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.qedit .qlevel-field input:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  outline: none;
}

.qlevel-hint {
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted-2);
}

.qlevel-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.qlevel-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 8px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  font-size: 11px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.qlevel-chip b {
  font-weight: 650;
}

.qlevel-chip.muted {
  color: var(--muted);
  background: transparent;
}

.qlevel-chip.demo {
  margin: 0 2px;
  vertical-align: middle;
}

.qlevel-abs {
  flex: 1 1 100%;
  font-size: 10px;
  color: var(--muted-2);
}

/* ------------------- owner table: no sideways scrolling ---------------- */

@media (min-width: 821px) {
  .table-box.cardable {
    overflow: hidden;
  }

  .table-box.cardable table.grid {
    min-width: 0;
    table-layout: fixed;
  }

  .table-box.cardable table.grid th:nth-child(1) {
    width: 40%;
  }

  .table-box.cardable table.grid th:nth-child(2) {
    width: 11%;
  }

  .table-box.cardable table.grid th:nth-child(3) {
    width: 12%;
  }

  .table-box.cardable table.grid th:nth-child(4) {
    width: 24%;
  }

  .table-box.cardable table.grid th:nth-child(5) {
    width: 13%;
  }

  .table-box.cardable table.grid td {
    overflow-wrap: anywhere;
  }
}

/* ------------------------- real depth for popups ----------------------- */

/* A dialog is the front-most layer of the product, so it gets the deepest
   stack: a wide soft drop, a tight contact shadow, and a lit top edge. */
.dialog,
.popover {
  border-color: color-mix(in srgb, var(--rule-strong) 65%, transparent);
  box-shadow: var(--elev-3), 0 1px 2px color-mix(in srgb, var(--ink) 10%, transparent);
}

.dialog.wide {
  box-shadow: var(--elev-3), 0 2px 4px color-mix(in srgb, var(--ink) 8%, transparent);
}

/* Detail cards already tilt; they now answer to the pointer as well. */
.detail-card {
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

/* ----------------------------- ban popup ------------------------------- */

.ban-dialog {
  max-width: 480px;
  border-color: color-mix(in srgb, var(--danger) 55%, var(--rule));
  box-shadow: 0 24px 60px rgba(12, 8, 8, 0.34), var(--elev-3);
}

.ban-hero {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.ban-badge {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

.ban-hero h3 {
  margin: 0;
  font-size: 17px;
}

.ban-hero p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.ban-facts {
  margin: 0 0 14px;
  display: grid;
  gap: 8px;
}

.ban-facts > div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--surface);
}

.ban-facts dt {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--muted);
}

.ban-facts dd {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.ban-note {
  margin: 0 0 14px;
  font-size: 12px;
  color: var(--muted);
}

.ban-actions {
  display: grid;
  gap: 8px;
}

/* ----------------------- mobile-first login page ----------------------- */

/* On a phone the page opens on the product itself: the hero fills the first
   screen, and the login card only arrives once the reader scrolls. Nothing
   is hidden, the order simply follows how a visitor actually decides. */
@media (max-width: 1080px) {
  .auth-page {
    display: block;
  }

  .auth-intro {
    position: relative;
    min-height: 100svh;
    padding: 46px 20px 60px;
    justify-content: center;
    gap: 24px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    background:
      radial-gradient(
        120% 70% at 88% -10%,
        color-mix(in srgb, var(--accent) 12%, transparent) 0%,
        transparent 62%
      ),
      var(--paper);
  }

  .auth-intro h1 {
    font-size: clamp(23px, 6.4vw, 32px);
    max-width: 30ch;
  }

  .auth-intro .lede {
    font-size: 14px;
    max-width: 44ch;
  }

  /* The hero is a section, not a wall of text: each block gets its own card. */
  .auth-intro .spec-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--surface) 70%, var(--paper));
    box-shadow: var(--elev-1);
  }

  .auth-intro .tier-table {
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--paper);
    box-shadow: var(--elev-1);
  }

  .auth-intro .tier-table th {
    background: var(--surface);
  }

  .auth-intro .contact-inline {
    padding-top: 4px;
  }

  /* A clear, quiet invitation to keep going instead of a mystery void. */
  .auth-jump {
    display: inline-flex;
  }

  .auth-form-col {
    padding: 34px 20px 54px;
    justify-content: flex-start;
    background: var(--paper);
    scroll-margin-top: 16px;
  }

  .auth-card {
    max-width: 440px;
  }

  .auth-card .pane h2 {
    font-size: 21px;
  }
}

.auth-jump {
  display: none;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--elev-2);
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

.auth-jump:hover {
  transform: translateY(-1px);
  box-shadow: var(--elev-3);
  text-decoration: none;
}

.auth-jump span[aria-hidden] {
  animation: authJumpNudge 2.4s var(--ease-in-out) infinite;
}

@keyframes authJumpNudge {
  0%,
  70%,
  100% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(3px);
  }
}

/* --------------------- a little more life in the app ------------------- */

.hist,
.thread-row,
.oc-list-item,
.src-list li,
.detail-action {
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.hist:hover,
.thread-row:hover,
.oc-list-item:hover {
  transform: translateY(-1px);
}

.msg.ai .bubble,
.msg.user .bubble {
  transition: box-shadow var(--dur-base) var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .qlevel,
  .auth-jump,
  .hist,
  .thread-row,
  .oc-list-item,
  .msg.ai .bubble,
  .msg.user .bubble {
    transition: none;
    transform: none;
  }

  .auth-jump span[aria-hidden] {
    animation: none;
  }
}

/* --------------------------- empty states ------------------------------ */

/* An empty panel is the first thing a new account sees, so it gets a soft
   mark and a line of guidance instead of one lonely sentence in the middle of
   a large blank box. */
.empty {
  position: relative;
  padding: 40px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  max-width: 42ch;
  margin: 0 auto;
}

.empty::before {
  content: '';
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border-radius: 11px;
  border: 1px solid var(--rule-strong);
  background:
    radial-gradient(circle at 32% 30%, color-mix(in srgb, var(--accent) 24%, transparent) 0%, transparent 58%),
    var(--surface);
  box-shadow: var(--elev-1);
}

/* ==================================================================
   PRESENCE — live online/offline badge
   ------------------------------------------------------------------
   Computed from the heartbeat rule the server uses, and repainted by a
   1s tick, so the dashboard shows a real current status instead of the
   status as of the last page load.
   ================================================================== */

.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out);
}

.presence .dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.presence.on {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 34%, transparent);
  background: var(--ok-soft);
}

.presence.on .dot {
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent);
  animation: presencePulse 2.2s var(--ease-out) infinite;
}

.presence.off {
  color: var(--muted-2);
}

@keyframes presencePulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 50%, transparent);
  }
  70% {
    box-shadow: 0 0 0 6px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.presence-cell {
  display: inline-flex;
  align-items: center;
}

/* Table cell: keep the badge on one line and aligned with the other chips. */
@media (min-width: 821px) {
  .table-box.cardable table.grid td[data-label='Kehadiran'] {
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .presence.on .dot {
    animation: none;
  }
}

/* ==================================================================
   PASSWORD RESET — status panel and user confirmation popup
   ------------------------------------------------------------------
   There is no notification bell any more: the "Status Reset Password"
   menu entry carries the pending count, because that page already lists
   every request and holds the Setuju / Tolak buttons.
   ================================================================== */

/* The owner's decision card. */
.pw-card .uprole-status {
  margin-left: 8px;
}

.pw-card .dm-body p {
  color: var(--muted);
}

/* A totals table shared by Up Role and Reset Password. */
.table-box .grid.compact {
  min-width: 0;
}

.table-box .grid.compact td {
  font-size: 12.5px;
}

.table-box .grid.compact td.num {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  width: 90px;
}

.table-box .grid.compact .up-note {
  color: var(--muted);
}

/* ------------------------- user confirmation popup --------------------- */

.reset-dialog {
  max-width: 500px;
  border-color: color-mix(in srgb, var(--accent) 42%, var(--rule));
  box-shadow: 0 26px 64px rgba(10, 12, 16, 0.36), var(--elev-3);
}

.reset-hero {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.reset-hero h3 {
  margin: 0;
  font-size: 17px;
}

.reset-hero p {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.reset-badge {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

.reset-message {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.6;
}

.reset-facts {
  margin: 0 0 14px;
  display: grid;
  gap: 8px;
}

.reset-facts > div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--surface);
}

.reset-facts dt {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--muted);
}

.reset-facts dd {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink);
}

.reset-contact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: var(--muted);
}

.reset-contact a {
  padding: 5px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 600;
}

.reset-sync {
  margin: 0 0 16px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.reset-sync b {
  color: var(--ink-2);
  font-weight: 650;
}

/* The reset meter reuses the register meter, with its own four levels. */
#resetMeterFill[data-level='1'] { background: var(--danger); }
#resetMeterFill[data-level='2'] { background: var(--warn); }
#resetMeterFill[data-level='3'] { background: var(--ok); }
#resetMeterFill[data-level='4'] { background: var(--ok); }

@media (max-width: 480px) {
  .reset-facts > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reset-dialog,
  .reset-badge {
    transition: none;
    animation: none;
  }
}

/* ==================================================================
   SIDEBAR — the chat history owns the whole column now
   ------------------------------------------------------------------
   The quota table that used to sit under the history list is gone: it
   squeezed the history into a short scroll box and repeated numbers the
   strip under the composer already shows. The list flexes to fill the
   freed height, and only the account lifetime stays below it.
   ================================================================== */

.history {
  flex: 1 1 auto;
}

.life-box {
  padding: 8px 10px;
  border: 1px solid var(--sidebar-rule);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--sidebar-muted);
  font-variant-numeric: tabular-nums;
}

[data-theme='dark'] .life-box {
  border-color: rgba(255, 255, 255, 0.1);
}

/* ==================================================================
   THREE-DOT ACTION MENU + OWNER CONVERSATION CONTROLS
   ------------------------------------------------------------------
   One menu component serves the owner conversation list, the owner
   conversation header, and the owner tools on a community message. The
   trigger is at least 40x40 on touch so it is easy to hit on a phone,
   and it is always visible (never hover-only) on touch devices.
   ================================================================== */

.row-more,
.more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.row-more:hover,
.more-btn:hover {
  color: var(--ink);
  background: var(--surface-2);
  border-color: var(--rule);
}

.row-more:active,
.more-btn:active {
  transform: scale(0.94);
}

.row-more:focus-visible,
.more-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* The inline variant sits inside the small community tool row, so it keeps
   the tap target height while staying visually compact. */
.row-more.inline {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 10px;
}

.more-btn {
  border-color: var(--rule);
  background: var(--paper);
}

.more-btn.hidden {
  display: none;
}

.action-menu {
  position: fixed;
  z-index: 1500;
  min-width: 232px;
  max-width: min(300px, calc(100vw - 20px));
  padding: 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-md), 0 18px 40px rgba(10, 12, 16, 0.16);
  animation: bim-menu-in 160ms var(--ease-out) both;
  transform-origin: top right;
}

.action-menu.hidden {
  display: none;
}

@keyframes bim-menu-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.am-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.am-item:hover,
.am-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.am-item.active {
  background: var(--accent-soft);
  color: var(--accent-ink, var(--ink));
}

.am-item.danger {
  color: var(--danger);
}

.am-item.danger:hover,
.am-item.danger:focus-visible {
  background: var(--danger-soft);
}

.am-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  opacity: 0.9;
}

.am-txt {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.am-txt strong {
  font-size: 13px;
  font-weight: 600;
}

.am-txt small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}

.am-item.danger .am-txt small {
  color: inherit;
  opacity: 0.75;
}

[data-theme='dark'] .action-menu {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.55);
}

/* Owner conversation row: a div with a row role, so the three-dot button can
   live inside it without nesting buttons. */
.thread-row[role='button'] {
  cursor: pointer;
}

.thread-row.is-pinned {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}

.oc-thread-note {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.oc-thread-note.hidden {
  display: none;
}

.oc-thread-note span {
  padding: 5px 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--ink-2);
}

/* ==================================================================
   UPGRADE REQUEST — Information page entry point, dialog, and the
   Setuju / Tolak card inside the private conversation with the owner.
   ================================================================== */

.upgrade-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.upgrade-panel .up-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 220px;
  flex: 1;
}

.upgrade-panel .up-text strong {
  font-size: 13.5px;
}

.upgrade-panel .up-text span {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
}

.upgrade-options {
  display: grid;
  gap: 8px;
  margin: 12px 0 4px;
}

.upgrade-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.upgrade-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.upgrade-option .uo-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upgrade-option .uo-main strong {
  font-size: 13px;
}

.upgrade-option .uo-main small {
  font-size: 11px;
  color: var(--muted);
}

.upgrade-option .uo-price {
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.req-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--surface-2);
}

.req-card.decided {
  border-left-color: var(--rule-strong);
}

.req-card.decided.ok {
  border-left-color: var(--ok, var(--accent));
}

.req-card.decided.no {
  border-left-color: var(--danger);
}

.req-card .req-tag {
  font-size: 12px;
  font-weight: 600;
}

.req-card .req-note {
  font-size: 11.5px;
  color: var(--muted);
}

.req-actions {
  display: flex;
  gap: 8px;
}

/* On a phone the chip and the buttons stack instead of squeezing the text. */
@media (max-width: 560px) {
  .req-card {
    flex-direction: column;
    align-items: stretch;
  }

  .req-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .upgrade-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .upgrade-panel .btn {
    width: 100%;
  }

  .action-menu {
    min-width: 0;
    width: min(300px, calc(100vw - 16px));
  }
}

/* Bigger tap targets on a touch device, where hover is not a signal. */
@media (hover: none) {
  .row-more,
  .more-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-color: var(--rule);
    background: var(--surface-2);
  }

  .row-more.inline {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .action-menu {
    animation: none;
  }
}

/* ==========================================================================
   SAVE / SYNC STATE CHIP
   --------------------------------------------------------------------------
   One small chip reports the real state of the last write, using the shared
   .chip look: "Menyimpan…" while a request is in flight, "Tersimpan" only
   after the backend confirmed it, "Offline" when the link is gone, and
   "Gagal disimpan" when a write was rejected. It is deliberately quiet — a
   status, not another piece of neon.
   ========================================================================== */
.sync-chip {
  gap: 6px;
  cursor: default;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

/* `.chip` sets display, which would otherwise beat the `hidden` attribute's
   UA rule; the chip is hidden whenever there is nothing to report. */
.sync-chip[hidden] {
  display: none;
}

.sync-chip::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.sync-chip[data-state='saving'],
.sync-chip[data-state='syncing'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.sync-chip[data-state='saving']::before,
.sync-chip[data-state='syncing']::before {
  animation: syncPulse 1s ease-in-out infinite;
}

.sync-chip[data-state='saved'] {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--rule-strong));
  background: var(--ok-soft);
  color: var(--ok);
}

.sync-chip[data-state='offline'] {
  color: var(--muted);
}

.sync-chip[data-state='failed'] {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--rule-strong));
  background: var(--danger-soft);
  color: var(--danger);
  cursor: pointer;
}

@keyframes syncPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sync-chip[data-state='saving']::before,
  .sync-chip[data-state='syncing']::before {
    animation: none;
    opacity: 1;
  }
}

/* The status chip is the first thing to give up room in a narrow topbar: the
   conversation matters more than a label. */
@media (max-width: 620px) {
  .sync-chip {
    display: none;
  }
}

/* ==========================================================================
   RESPONSIVE TYPE SCALE AND TOUCH TARGETS
   --------------------------------------------------------------------------
   Sizes flow with the viewport instead of being pinned to one desktop value.
   clamp() keeps every size between a readable floor and a sane ceiling, so a
   360px phone never inherits a desktop size and a very large monitor never
   gets an oversized heading. Nothing here is decorative: these are the sizes
   the spec asks to be proportional (titles, message body, labels, buttons,
   inputs, spacing).
   ========================================================================== */

html {
  font-size: clamp(16px, 0.24vw + 15.2px, 17px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* The most-read text in the app: chat answers. */
.bubble,
.msg {
  font-size: clamp(14px, 0.34vw + 13.2px, 15.75px);
  line-height: 1.62;
}

/* Community room and direct messages follow the chat body so both rooms read
   the same on the same device. */
.dm-body,
.dm-body p {
  font-size: clamp(14px, 0.34vw + 13.2px, 15.6px);
  line-height: 1.6;
}

/* Composer: never below 16px on a phone, because a smaller size makes mobile
   Safari zoom the whole page the moment the field is focused. */
.composer textarea {
  font-size: clamp(16px, 0.3vw + 15.1px, 16.5px);
  max-height: clamp(140px, 32vh, 240px);
}

/* Labels, chips and small print: 12px is the floor, 13.5px the ceiling. */
.hint,
.small,
.chip,
.badge,
.tool-toggle,
.tb-note,
.dm-meta {
  font-size: clamp(12px, 0.18vw + 11.5px, 13.5px);
}

/* Titles. */
.auth-intro h1,
.welcome h1 {
  font-size: clamp(26px, 2.4vw + 18px, 40px);
}

.dialog-head h3 {
  font-size: clamp(17px, 0.5vw + 15.6px, 21px);
}

/* Controls keep their proportions at every size. */
.btn {
  font-size: clamp(13.5px, 0.22vw + 12.8px, 15px);
}

.select-btn,
input,
select {
  font-size: clamp(14px, 0.24vw + 13.4px, 15.25px);
}

/* --- Touch targets -------------------------------------------------------
   Roughly 44 CSS pixels on the primary controls wherever the pointer is a
   finger. The icons stay visually small — only the hit area grows — and a
   fine pointer is left untouched so the desktop UI does not become bulky. */
@media (pointer: coarse) {
  .btn,
  .icon-btn,
  .send,
  .select-btn,
  .tool-toggle,
  .theme-toggle,
  .sync-chip,
  .chip {
    min-height: 44px;
  }

  .icon-btn,
  .send,
  .menu-btn,
  .theme-toggle {
    min-width: 44px;
  }

  .tool-toggle {
    padding: 0 14px;
  }

  /* Comfortable thumb spacing in the composer row. */
  .composer-bar {
    gap: 10px;
  }

  /* A 44px chip would look oversized in a list, so only the tappable chip
     menu entries grow, not the read-only ones. */
  .chip.save-chip,
  .chip.sync-chip {
    min-height: 0;
  }
}

/* --- Very small phones --------------------------------------------------- */
@media (max-width: 400px) {
  .composer textarea {
    font-size: 16px;
  }

  .bubble,
  .msg,
  .dm-body {
    font-size: 14px;
  }
}

/* --- Large desktop and 2K/4K monitors ------------------------------------ */
@media (min-width: 1600px) {
  :root {
    --sidebar-w: 300px;
  }

  .composer {
    max-width: 900px;
  }
}

@media (min-width: 2100px) {
  .composer {
    max-width: 1040px;
  }
}

/* --- Short landscape phones ---------------------------------------------- */
@media (max-height: 480px) and (orientation: landscape) {
  .composer textarea {
    max-height: 96px;
  }
}


/* ==========================================================================
   BIM AI — CYBERPUNK SHELL REDESIGN
   --------------------------------------------------------------------------
   The header is reduced to the hamburger plus the few controls that are truly
   needed. Model and thinking selection moved into the composer, next to the
   message they apply to. The palette is a dark base with a measured neon cyan
   accent and a violet secondary, thin hairline borders, and glow only on
   interactive elements. No decorative arcs, dashed rules or gradient sweeps.
   ========================================================================== */

/* The decorative layer is gone; panels still need an explicit paint order so
   the composer popovers sit above the chat scroller. */
.topbar {
  position: relative;
  z-index: 20;
}

.scroll,
.composer-area,
.panel {
  position: relative;
  z-index: 1;
}

/* ------------------------------- header --------------------------------- */

.topbar {
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 0;
  /* Transparent on purpose: the header blends into the page background
     instead of cutting the conversation area with a rule. */
  background: transparent;
}

/* The hamburger: a compact rounded square with a plain three-line icon. */
.menu-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--rule-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-2);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.menu-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.menu-btn:active {
  background: var(--surface-2);
}

.tb-brand {
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--ink-2);
}

/* ------------------- composer: model + thinking picks -------------------- */

.composer-picks,
.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.composer-picks {
  flex: 0 1 auto;
}

/* A compact chip, deliberately smaller than the topbar control it replaces so
   it never dominates the writing area. */
.select-btn.compact {
  gap: 5px;
  padding: 5px 9px;
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  max-width: 38vw;
  transition: border-color 160ms ease, color 160ms ease;
}

.select-btn.compact > span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.select-btn.compact .sub {
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.select-btn.compact .chev {
  flex: none;
  opacity: 0.5;
}

.select-btn.compact:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.select-btn.compact:hover .chev {
  opacity: 1;
}

/* The picker sits at the bottom of the window, so its panel opens UPWARD.
   The rightmost control aligns to its right edge so the panel cannot leave
   the viewport. */
.popover-host.up > .popover {
  top: auto;
  bottom: calc(100% + 8px);
  left: 0;
  right: auto;
  max-width: calc(100vw - 28px);
}

.popover-host.up:last-child > .popover {
  left: auto;
  right: 0;
}

.composer-bar {
  flex-wrap: wrap;
  gap: 6px;
}

/* The two pickers and the two tool chips keep their size; the hint is the only
   flexible item, so a narrow window shrinks the hint instead of wrapping the
   send button onto a line of its own. */
.composer-picks,
.composer-tools {
  flex: 0 0 auto;
}

.composer-bar .hint {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

/* --------------------- send button: small perfect circle ----------------- */

.send {
  position: relative;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink, #fff);
  transition: background 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}

.send:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send:active:not(:disabled) {
  transform: scale(0.94);
}

.send:disabled {
  background: var(--rule-strong);
  color: var(--muted-2);
  cursor: not-allowed;
}

/* "Working" state: the button becomes Stop and pulses, so it is obvious that
   something is running and that pressing it cancels. */
.send.stop {
  background: var(--danger);
  color: var(--accent-ink, #fff);
  animation: sendPulse 1.5s ease-in-out infinite;
}

.send.stop:hover:not(:disabled) {
  background: var(--danger);
}

@keyframes sendPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent);
  }
  60% {
    box-shadow: 0 0 0 6px transparent;
  }
}

/* ------------------------- cyberpunk dark palette ----------------------- */

[data-theme='dark'] {
  --paper: #060911;
  --surface: #0b1019;
  --surface-2: #121b28;
  --ink: #e6eefc;
  --ink-2: #b4c2d8;
  --muted: #7a89a2;
  --muted-2: #58657c;
  --rule: #131c2b;
  --rule-strong: #223049;

  /* Electric cyan is the primary accent; `--accent-ink` is the readable text
     colour to place ON a filled accent surface. */
  --accent: #37e3ff;
  --accent-hover: #66ecff;
  --accent-soft: rgba(55, 227, 255, 0.13);
  --accent-ink: #03141b;

  /* Violet is the restrained secondary accent. */
  --violet: #b06bff;
  --violet-soft: rgba(176, 107, 255, 0.15);

  --sidebar: #04070d;
  --sidebar-2: #0d1522;
  --sidebar-ink: #e6eefc;
  --sidebar-muted: #71819b;
  --sidebar-rule: #16202f;

  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, 0.12);
  --warn: #f5c451;
  --warn-soft: rgba(245, 196, 81, 0.12);
  --danger: #ff5d73;
  --danger-soft: rgba(255, 93, 115, 0.13);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* Text that sits on a filled accent surface must use the accent ink, not
   white: cyan with white text is unreadable. */
[data-theme='dark'] .btn-primary,
[data-theme='dark'] .send,
[data-theme='dark'] .send.stop,
[data-theme='dark'] .gate-start,
[data-theme='dark'] .role-chip.active,
[data-theme='dark'] .btn.btn-detail:hover:not(:disabled),
[data-theme='dark'] tr.dash-row:focus-visible .who-avatar {
  color: var(--accent-ink);
}

/* A touch of violet, used only where it carries meaning. */
[data-theme='dark'] .badge.vip {
  background: var(--violet-soft);
  color: var(--violet);
  border-color: color-mix(in srgb, var(--violet) 40%, var(--rule-strong));
}

[data-theme='dark'] .mention-count {
  background: var(--violet);
  color: var(--accent-ink);
}

/* The composer card: a slightly raised surface so it reads as the input target
   without adding another border line to the page. */
[data-theme='dark'] .composer {
  background: var(--surface);
  border-color: var(--rule-strong);
}

[data-theme='dark'] .composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

[data-theme='dark'] .composer-area {
  background: var(--paper);
}

/* Focus visibility stays obvious on a dark surface. */
[data-theme='dark'] :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dark theme keeps the reduced-motion contract. */
@media (prefers-reduced-motion: reduce) {
  .send.stop {
    animation: none;
  }
}

/* ------------------------------- responsive ----------------------------- */

/* Tablet: the header stays a single compact row. */
@media (max-width: 1024px) {
  .topbar {
    padding: 8px 12px;
  }
  .select-btn.compact {
    font-size: 11.5px;
    padding: 5px 8px;
  }
}

/* Phone: the picker row keeps its own line, the hint gives up its space, and
   the send button is pushed to the trailing edge so the composer never feels
   crammed. */
@media (max-width: 640px) {
  .topbar {
    gap: 8px;
    padding: 7px 10px;
  }
  .tb-brand {
    display: none;
  }
  .menu-btn {
    width: 36px;
    height: 36px;
  }
  .composer-area {
    padding: 8px 10px 10px;
  }
  .hint {
    display: none;
  }
  .composer-bar .send {
    margin-left: auto;
  }
  .select-btn.compact .sub {
    display: none;
  }
  .select-btn.compact {
    max-width: 44vw;
  }
}

/* Very small phones: the chips give up their sub-label and share the first row
   with attach and send, so the controls take two rows instead of three. */
@media (max-width: 400px) {
  .menu-btn {
    width: 34px;
    height: 34px;
  }
  .composer-picks {
    flex: 0 1 auto;
    min-width: 0;
  }
  .select-btn.compact {
    max-width: none;
    min-width: 0;
    flex: 0 1 auto;
  }
  .select-btn.compact > span:first-child {
    max-width: 72px;
  }
}

/* Landscape phones: a shorter composer keeps the thread visible. */
@media (max-height: 500px) and (orientation: landscape) {
  .composer textarea {
    max-height: 84px;
    min-height: 20px;
  }
  .topbar {
    padding: 5px 10px;
  }
}

/* Virtual keyboard: while it is open the viewport is short, so the header and
   the composer tighten up and the thread keeps the remaining space. The
   composer itself stays pinned to the bottom of the viewport because the shell
   is a flex column with the scroller taking the free space. */
@supports (height: 100dvh) {
  .app-body,
  .shell {
    height: 100dvh;
  }
}

/* Large screens: the conversation column may breathe, the controls stay close
   to the message they belong to. */
@media (min-width: 1600px) {
  .composer {
    max-width: 860px;
  }
}

/* ==========================================================================
   SECURITY PANEL + CHAT BLOCK
   --------------------------------------------------------------------------
   The muted-account list lives in its own dialog now. The reason is displayed as
   fixed text (it cannot be edited there), the duration is adjustable, and the
   mute itself can be cancelled. The moderation panel keeps the action log.
   ========================================================================== */

/* A read-only field: it has to look settled, not like a disabled input. */
.mm-fixed {
  margin: 8px 0 2px;
  padding: 8px 10px;
  border-left: 2px solid var(--rule-strong);
  border-radius: 0 6px 6px 0;
  background: var(--surface);
}

.mm-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.mm-reason {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* The duration row: the label sits inline with the controls it describes. */
.row-actions .mm-label {
  align-self: center;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11.5px;
}

/* A short explanatory line inside a dialog. */
.dialog-note {
  margin: 0 0 14px;
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

[data-theme='dark'] .dialog-note {
  background: var(--surface-2);
}

[data-theme='dark'] .mm-fixed {
  background: var(--surface-2);
  border-left-color: var(--accent);
}

/* Phone: the duration controls take their own line instead of squeezing. */
@media (max-width: 640px) {
  .row-actions .mm-label {
    flex: 1 1 100%;
  }
  .mm-fixed {
    padding: 8px 9px;
  }
}

/* ==========================================================================
   COMPOSER FIT + CYBER LIGHTS
   --------------------------------------------------------------------------
   The composer tracks the width of the conversation column instead of the
   window: compact and centred on desktop, comfortable on tablet, nearly
   full-bleed on phones (only the side padding is kept). The model and thinking
   pickers are reduced to the same weight as the Web / Deep toggles so the bar
   reads as one row of equal controls.
   ========================================================================== */

/* --- model + thinking pickers: same size as the tool toggles -------------- */

.select-btn.compact {
  padding: 3px 9px;
  border-radius: 999px;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  max-width: 44vw;
}

/* The secondary line ("Model teks", "8-20s") is what made these buttons taller
   and wider than the toggles; the label alone is enough at this size. */
.select-btn.compact .sub {
  display: none;
}

.select-btn.compact .chev {
  width: 9px;
  height: 9px;
}

/* --- composer width: viewport-aware, never window-wide -------------------- */

.composer,
.quota-strip {
  max-width: min(700px, 100%);
}

.composer {
  padding: 7px 7px 5px 11px;
}

.composer textarea {
  min-height: 20px;
}

/* Tablet: a little tighter, still centred. */
@media (max-width: 1024px) {
  .composer,
  .quota-strip {
    max-width: min(660px, 100%);
  }
}

/* Phone: fill the screen minus the side padding so typing space stays roomy. */
@media (max-width: 720px) {
  .composer-area {
    padding: 8px 10px 12px;
  }
  .composer,
  .quota-strip {
    max-width: 100%;
  }
  .composer {
    padding: 6px 6px 4px 10px;
  }
}

/* Large desktop / 2K / 4K: it may breathe, but it never spans the viewport. */
@media (min-width: 1600px) {
  .composer,
  .quota-strip {
    max-width: 820px;
  }
}

@media (min-width: 2100px) {
  .composer,
  .quota-strip {
    max-width: 900px;
  }
}

/* --- send button: compact, proportional to the composer height ------------ */

.send {
  width: 32px;
  height: 32px;
}

@media (pointer: coarse) {
  .send {
    width: 40px;
    height: 40px;
  }
}

/* --- cyberpunk lights ----------------------------------------------------- */

/* A pulsing power light beside the brand: the one always-on neon indicator. */
.tb-brand {
  position: relative;
  padding-left: 15px;
}

.tb-brand::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--accent);
  animation: powerPulse 2.6s ease-in-out infinite;
}

@keyframes powerPulse {
  0%,
  100% {
    opacity: 0.5;
    box-shadow: 0 0 5px 1px color-mix(in srgb, var(--accent) 60%, transparent);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 12px 3px color-mix(in srgb, var(--accent) 70%, transparent);
  }
}

/* The active sidebar row gets a neon edge instead of a flat highlight. */
[data-theme='dark'] .side-item.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent 88%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent),
    0 0 18px -8px var(--accent);
}

/* A live tool (Web / Deep) glows, so "on" is unmistakable in the dark theme. */
[data-theme='dark'] .tool-toggle.on {
  box-shadow: 0 0 12px -4px var(--accent);
}

/* The composer lights up with a hairline bloom when it takes focus. */
[data-theme='dark'] .composer:focus-within {
  box-shadow: 0 0 0 1px var(--accent), 0 0 24px -10px var(--accent);
}

/* The send button carries a faint bloom, brighter while it is pressable. */
[data-theme='dark'] .send:not(:disabled) {
  box-shadow: 0 0 14px -5px var(--accent);
}

[data-theme='dark'] .send.stop {
  box-shadow: 0 0 16px -4px var(--danger);
}

/* A thin neon hairline above the composer keeps the writing area anchored. */
[data-theme='dark'] .composer-area {
  border-top-color: color-mix(in srgb, var(--accent) 24%, var(--rule));
}

@media (prefers-reduced-motion: reduce) {
  .tb-brand::before {
    animation: none;
  }
}

/* ==========================================================================
   CYBER BOOT LOADER (replaces the cloud transition)
   --------------------------------------------------------------------------
   Shown when the account presses "Mulai Chat". A neon grid, a sweeping scan
   line, a rotating ring and a progress bar that fills over the measured
   connection time — fast link, short load.
   ========================================================================== */

.cyber-veil {
  position: fixed;
  inset: 0;
  z-index: 420;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #08131c 0%, #04070d 62%, #02040a 100%);
}

[data-theme='light'] .cyber-veil {
  background: radial-gradient(circle at 50% 42%, #eef3f9 0%, #e2e9f2 62%, #d6deea 100%);
}

.cyber-grid {
  position: absolute;
  inset: -10% -20%;
  background-image: linear-gradient(color-mix(in srgb, var(--accent) 22%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 22%, transparent) 1px, transparent 1px);
  background-size: 44px 44px;
  transform: perspective(420px) rotateX(58deg) translateZ(-60px);
  transform-origin: center 30%;
  opacity: 0.5;
  animation: cyberGridDrift 6s linear infinite;
  mask-image: radial-gradient(circle at 50% 45%, transparent 26%, #000 78%);
}

@keyframes cyberGridDrift {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 44px;
  }
}

.cyber-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--accent) 16%, transparent) 48%,
    color-mix(in srgb, var(--accent) 34%, transparent) 50%,
    color-mix(in srgb, var(--accent) 16%, transparent) 52%,
    transparent 100%
  );
  background-size: 100% 240px;
  animation: cyberScan 2.4s linear infinite;
  mix-blend-mode: screen;
  opacity: 0.75;
}

@keyframes cyberScan {
  from {
    background-position: 0 -240px;
  }
  to {
    background-position: 0 100vh;
  }
}

.cyber-core {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  text-align: center;
}

.cyber-ring {
  position: relative;
  width: 76px;
  height: 76px;
}

.cyber-ring span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.cyber-ring span:nth-child(1) {
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  animation: cyberSpin 1.1s linear infinite;
  box-shadow: 0 0 16px -3px var(--accent);
}

.cyber-ring span:nth-child(2) {
  inset: 11px;
  border-bottom-color: var(--violet);
  border-left-color: var(--violet);
  animation: cyberSpin 1.7s linear infinite reverse;
}

.cyber-ring span:nth-child(3) {
  inset: 24px;
  border-top-color: var(--ok);
  animation: cyberSpin 0.9s linear infinite;
}

@keyframes cyberSpin {
  to {
    transform: rotate(360deg);
  }
}

.cyber-brand {
  font-size: clamp(20px, 2vw + 14px, 30px);
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
}

[data-theme='light'] .cyber-brand {
  color: #0b1b26;
}

.cyber-brand span {
  color: var(--accent);
}

.cyber-bar {
  width: min(320px, 68vw);
  height: 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
}

.cyber-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--violet));
  box-shadow: 0 0 14px 0 var(--accent);
}

.cyber-status {
  margin: 0;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .cyber-grid,
  .cyber-scan,
  .cyber-ring span {
    animation: none;
  }
}

/* ==========================================================================
   BIM AI — JAPANESE CYBERPUNK DESIGN SYSTEM
   --------------------------------------------------------------------------
   One system, every page. The identity is NEAR BLACK + CHARCOAL with VERMILION
   RED as the primary signal and ELECTRIC BLUE as the technology/accent colour.
   Red marks identity, emphasis and destructive weight; blue marks interaction,
   links and live state. Neither is ever used as decoration, and no component
   uses both at full strength at once.

   Everything below is driven by these tokens, so a page can never drift from
   the rest of the shell.
   ========================================================================== */

/* ------------------------------- tokens ---------------------------------- */

:root {
  /* Light mode: warm off-white paper with a warm charcoal ink. */
  --paper: #f4f2ef;
  --surface: #faf9f7;
  --surface-2: #ebe8e3;
  --bg: #faf9f7;
  --ink: #14110f;
  --ink-2: #3a3430;
  --muted: #6b625b;
  --muted-2: #918880;
  --rule: #ddd7cf;
  --rule-strong: #c4bbb0;

  /* Vermilion: the identity colour. */
  --accent: #d1332a;
  --accent-hover: #b82a22;
  --accent-soft: #fbe9e7;
  --accent-ink: #ffffff;

  /* Electric blue: technology and interaction. */
  --neon: #d1332a;
  --neon-deep: #8f1f18;
  --neon-2: #1d6fe0;
  --neon-2-deep: #14509f;
  --neon-2-soft: rgba(29, 111, 224, 0.12);
  --violet: #4a5568;
  --violet-soft: #e7e9ee;
  --magenta: #1d6fe0;
  --toxic: #0e7a5f;
  --amber: #a86a12;
  --red: #c42c48;

  --ok: #0e7a5f;
  --ok-soft: #e2f2ec;
  --warn: #a86a12;
  --warn-soft: #fbf1df;
  --danger: #c42c48;
  --danger-soft: #fbe9ed;

  /* The sidebar stays dark in every theme: it is the machine, not the paper. */
  --sidebar: #0e0c0b;
  --sidebar-2: #1b1817;
  --sidebar-ink: #f2eeea;
  --sidebar-muted: #8b8179;
  --sidebar-rule: #2a2523;

  --glass: rgba(255, 255, 255, 0.76);
  --glass-2: rgba(255, 255, 255, 0.54);
  --glow: rgba(209, 51, 42, 0.2);
  --glow-strong: rgba(8, 123, 255, 0.36);
  --hud: rgba(8, 123, 255, 0.5);

  --radius: 8px;
  --radius-lg: 14px;
  --cut: polygon(11px 0, 100% 0, 100% calc(100% - 11px), calc(100% - 11px) 100%, 0 100%, 0 11px);
  --cut-sm: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);

  --shadow-sm: 0 1px 2px rgba(10, 20, 36, 0.08);
  --shadow-md: 0 10px 30px rgba(10, 20, 36, 0.14);

  /* `system` no longer reaches CSS as a value (JS resolves it), so the light
     tokens above are the base and dark below replaces them wholesale. */
  --font: "Inter", "Plus Jakarta Sans", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", "Rajdhani", "Orbitron", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Share Tech Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;
  /* Japanese faces come from the OS: CSP forbids a webfont CDN, and every
     target platform ships a competent gothic face. */
  --jp: "Yu Gothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Meiryo", "MS PGothic", sans-serif;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-fast: 0.14s;
  --dur: 0.24s;
  --dur-slow: 0.5s;

  --sidebar-w: 272px;
}

/* Dark mode IS the identity: near-black paper, charcoal raised surfaces, and
   the two signal colours used strictly by function. */
[data-theme='dark'],
[data-theme='system'] {
  --paper: #0b0a09;
  --surface: #121110;
  --surface-2: #1a1817;
  --bg: #0b0a09;
  --ink: #f3efeb;
  --ink-2: #c2bab3;
  --muted: #8d837b;
  --muted-2: #6b625c;
  --rule: #241f1d;
  --rule-strong: #383130;

  /* Vermilion carries identity and destructive weight. */
  --accent: #ff5a4d;
  --accent-hover: #ff7a6e;
  --accent-soft: rgba(255, 90, 77, 0.13);
  --accent-ink: #ffffff;

  --neon: #ff5a4d;
  --neon-deep: #b32b21;
  --neon-2: #4d9bff;
  --neon-2-deep: #2b6fd0;
  --neon-2-soft: rgba(77, 155, 255, 0.14);
  --violet: #7d8a9c;
  --violet-soft: rgba(125, 138, 156, 0.14);
  --magenta: #4d9bff;
  --toxic: #35d39a;
  --amber: #ffb443;
  --red: #ff5a4d;

  --ok: #35d39a;
  --ok-soft: rgba(53, 211, 154, 0.12);
  --warn: #ffb443;
  --warn-soft: rgba(255, 180, 67, 0.12);
  --danger: #ff5a4d;
  --danger-soft: rgba(255, 90, 77, 0.13);

  --sidebar: #070606;
  --sidebar-2: #171413;
  --sidebar-ink: #f3efeb;
  --sidebar-muted: #857b73;
  --sidebar-rule: #16223c;

  --glass: rgba(9, 17, 34, 0.62);
  --glass-2: rgba(11, 18, 34, 0.44);
  --glow: rgba(0, 229, 255, 0.18);
  --glow-strong: rgba(0, 229, 255, 0.36);
  --hud: rgba(0, 229, 255, 0.42);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 12px 40px rgba(0, 0, 0, 0.6);
}

/* ------------------------------- base type -------------------------------- */

body {
  font-family: var(--font);
}

h1,
h2,
h3,
h4,
.wordmark,
.tb-brand,
.dialog-head h3,
.panel-inner h1,
.dash-head h1,
.gate-head h1,
.welcome h1,
.auth-intro h1 {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

/* Every countdown, stat figure and identifier reads as a terminal readout. */
.num,
.stat strong,
.kpi strong,
.cd-cell strong,
.meter-label,
.tb-reset,
.tool-count,
.qlevel-chip,
.mr-when,
.dm-time,
.pager-info,
.detail-live-left,
.viewer-counter {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* A HUD label: uppercase mono, hairline neon frame, live dot. */
.hud-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--hud);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 12%, transparent), transparent);
  color: var(--neon);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  clip-path: var(--cut-sm);
}

.hud-tag::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: neonPulse 2.4s var(--ease) infinite;
}

.hud-tag[data-state='offline'] {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 45%, transparent);
}

.hud-tag[data-state='offline']::before {
  animation: none;
  opacity: 0.55;
}

/* --------------------------- environment layer --------------------------- */

/* One fixed decorative layer per page: faint grid, drifting aurora, a slow
   scan sweep and a handful of rising particles. It is `aria-hidden`, takes no
   pointer events and never sits above content. */
.cyber-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.cyber-fx > span {
  position: absolute;
  inset: 0;
  display: block;
}

.fx-grid {
  background-image: linear-gradient(color-mix(in srgb, var(--neon) 9%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--neon) 9%, transparent) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 10%, transparent 78%);
  opacity: 0.75;
  animation: fxGridDrift 22s linear infinite;
}

.fx-aurora {
  background:
    radial-gradient(48% 38% at 12% 4%, color-mix(in srgb, var(--neon) 16%, transparent), transparent 70%),
    radial-gradient(42% 34% at 88% 10%, color-mix(in srgb, var(--violet) 16%, transparent), transparent 72%),
    radial-gradient(60% 46% at 50% 108%, color-mix(in srgb, var(--neon-2) 14%, transparent), transparent 74%);
  filter: blur(10px);
  animation: fxAurora 16s ease-in-out infinite alternate;
}

.fx-scan {
  background: linear-gradient(
    to bottom,
    transparent 0%,
    color-mix(in srgb, var(--neon) 9%, transparent) 46%,
    color-mix(in srgb, var(--neon) 20%, transparent) 50%,
    color-mix(in srgb, var(--neon) 9%, transparent) 54%,
    transparent 100%
  );
  background-size: 100% 300px;
  mix-blend-mode: screen;
  opacity: 0.5;
  animation: fxScan 9s linear infinite;
}

.fx-particles i {
  position: absolute;
  bottom: -8px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--neon);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--neon) 65%, transparent);
  opacity: 0;
  animation: fxParticle 11s linear infinite;
}

.fx-particles i:nth-child(1) { left: 6%;  animation-delay: 0s;    animation-duration: 12s; }
.fx-particles i:nth-child(2) { left: 15%; animation-delay: 1.4s;  animation-duration: 15s; }
.fx-particles i:nth-child(3) { left: 24%; animation-delay: 3.1s;  animation-duration: 13s; }
.fx-particles i:nth-child(4) { left: 33%; animation-delay: 5.6s;  animation-duration: 17s; }
.fx-particles i:nth-child(5) { left: 41%; animation-delay: 2.2s;  animation-duration: 14s; }
.fx-particles i:nth-child(6) { left: 49%; animation-delay: 7.4s;  animation-duration: 16s; }
.fx-particles i:nth-child(7) { left: 57%; animation-delay: 4.3s;  animation-duration: 12s; }
.fx-particles i:nth-child(8) { left: 64%; animation-delay: 6.1s;  animation-duration: 18s; }
.fx-particles i:nth-child(9) { left: 71%; animation-delay: 0.8s;  animation-duration: 13s; }
.fx-particles i:nth-child(10) { left: 78%; animation-delay: 8.2s; animation-duration: 15s; }
.fx-particles i:nth-child(11) { left: 85%; animation-delay: 3.7s; animation-duration: 14s; }
.fx-particles i:nth-child(12) { left: 92%; animation-delay: 5.1s; animation-duration: 16s; }

.fx-particles i:nth-child(2n) {
  background: var(--violet);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--violet) 65%, transparent);
}

@keyframes fxGridDrift {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 46px 46px, 46px 46px; }
}

@keyframes fxAurora {
  from { opacity: 0.75; transform: translate3d(0, 0, 0) scale(1); }
  to   { opacity: 1; transform: translate3d(0, -18px, 0) scale(1.05); }
}

@keyframes fxScan {
  from { background-position: 0 -300px; }
  to   { background-position: 0 100vh; }
}

@keyframes fxParticle {
  0%   { opacity: 0; transform: translateY(0) scale(0.6); }
  12%  { opacity: 0.9; }
  80%  { opacity: 0.5; }
  100% { opacity: 0; transform: translateY(-92vh) scale(1); }
}

@keyframes neonPulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* In light mode the environment is present but far quieter. */
[data-theme='light'] .fx-grid { opacity: 0.5; }
[data-theme='light'] .fx-aurora { opacity: 0.6; }
[data-theme='light'] .fx-scan { opacity: 0.22; }
[data-theme='light'] .fx-particles i { opacity: 0.5; }

/* The shell paints above the decorative layer. */
.shell {
  position: relative;
  z-index: 1;
}

/* ------------------------------- sidebar ---------------------------------- */

[data-theme] .sidebar {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--neon) 5%, transparent), transparent 220px),
    linear-gradient(180deg, var(--sidebar), #03050c 70%);
  border-right: 1px solid var(--sidebar-rule);
  box-shadow: inset -1px 0 0 color-mix(in srgb, var(--neon) 14%, transparent), 6px 0 30px -18px var(--glow-strong);
}

/* The sidebar's own faint circuit grid, so it reads as one device with the page. */
[data-theme] .sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(color-mix(in srgb, var(--neon) 7%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--neon) 7%, transparent) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, #000, transparent 62%);
  opacity: 0.7;
}

[data-theme] .sidebar-head {
  position: relative;
  z-index: 1;
}

[data-theme] .wordmark {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-ink);
  text-shadow: 0 0 18px var(--glow-strong);
}

[data-theme] .wordmark .logo,
[data-theme] .wordmark .mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  clip-path: var(--cut-sm);
  object-fit: cover;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 40%, transparent), 0 0 18px -4px var(--neon);
}

/* Primary action: chamfered cyan→blue with a real glow. */
[data-theme] .new-btn {
  position: relative;
  gap: 9px;
  padding: 10px 12px;
  border: 0;
  clip-path: var(--cut);
  background: linear-gradient(120deg, var(--neon), var(--neon-deep));
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  filter: drop-shadow(0 6px 18px -6px var(--glow-strong));
  transition: filter var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}

[data-theme] .new-btn:hover {
  filter: drop-shadow(0 8px 24px -6px var(--neon));
}

[data-theme] .new-btn:active {
  transform: translateY(1px);
}

/* Nav rows: a left energy bar marks the active view. */
[data-theme] .side-item {
  position: relative;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  color: var(--sidebar-muted);
  font-size: 13.5px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

[data-theme] .side-item:hover {
  background: color-mix(in srgb, var(--neon) 7%, transparent);
  color: var(--sidebar-ink);
}

[data-theme] .side-item.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent 88%);
  border-left-color: var(--neon);
  color: var(--sidebar-ink);
  font-weight: 600;
  box-shadow: inset 12px 0 24px -18px var(--neon);
}

[data-theme] .side-item.active svg {
  color: var(--neon);
  filter: drop-shadow(0 0 6px var(--glow-strong));
}

[data-theme] .side-item .count {
  font-family: var(--mono);
  font-size: 10.5px;
}

/* Section labels read as terminal headings with a hairline that fades out. */
[data-theme] .side-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--sidebar-muted);
}

[data-theme] .side-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--sidebar-rule), transparent);
}

/* History rows: hairline card that lights up on hover. */
[data-theme] .hist,
[data-theme] .thread-row,
[data-theme] .oc-list-item {
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-2);
  background: transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}

[data-theme] .hist:hover,
[data-theme] .thread-row:hover,
[data-theme] .oc-list-item:hover {
  background: color-mix(in srgb, var(--neon) 8%, transparent);
  border-color: color-mix(in srgb, var(--neon) 26%, transparent);
}

[data-theme] .hist.active,
[data-theme] .thread-row.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent 90%);
  border-color: color-mix(in srgb, var(--neon) 34%, transparent);
  color: var(--ink);
}

[data-theme] .history .hist {
  color: var(--sidebar-muted);
}

[data-theme] .history .hist:hover,
[data-theme] .history .hist.active {
  color: var(--sidebar-ink);
}

[data-theme] .history .hist.active {
  background: linear-gradient(90deg, var(--accent-soft), transparent 90%);
  border-color: color-mix(in srgb, var(--neon) 34%, transparent);
}

[data-theme] .side-foot {
  border-top: 1px solid var(--sidebar-rule);
}

[data-theme] .user-row {
  position: relative;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--neon) 5%, transparent);
  transition: border-color var(--dur) var(--ease);
}

[data-theme] .user-row:hover {
  border-color: color-mix(in srgb, var(--neon) 30%, transparent);
}

/* Avatar: chamfered neon-ringed identity badge. */
[data-theme] .avatar {
  border-radius: 9px;
  clip-path: var(--cut-sm);
  background: linear-gradient(140deg, var(--neon), var(--neon-deep));
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 45%, transparent), 0 0 16px -6px var(--neon);
}

[data-theme] .user-row .who strong {
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

[data-theme] .user-row .who small {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--neon);
}

/* -------------------------------- topbar --------------------------------- */

[data-theme] .topbar {
  gap: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--neon) 18%, var(--rule));
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

/* A scan line travels along the header rule, once every few seconds. */
[data-theme] .topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
  background-size: 220px 100%;
  background-repeat: no-repeat;
  opacity: 0.7;
  animation: topbarScan 5.5s linear infinite;
}

@keyframes topbarScan {
  0%   { background-position: -240px 0; }
  100% { background-position: calc(100% + 240px) 0; }
}

[data-theme] .tb-brand {
  padding-left: 15px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-shadow: 0 0 14px var(--glow);
}

[data-theme] .tb-reset {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

[data-theme] .menu-btn,
[data-theme] .theme-toggle,
[data-theme] .icon-btn {
  border-radius: 9px;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

[data-theme] .menu-btn {
  border: 1px solid var(--rule-strong);
  background: var(--glass-2);
  color: var(--ink-2);
}

[data-theme] .menu-btn:hover {
  border-color: var(--neon);
  color: var(--neon);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 30%, transparent), 0 0 18px -6px var(--neon);
}

[data-theme] .theme-toggle {
  border-color: var(--rule-strong);
  background: var(--glass-2);
}

[data-theme] .theme-toggle:hover {
  border-color: var(--neon);
  color: var(--neon);
}

/* Sync chip: the colour carries the meaning (green ok, amber pending, red failed). */
[data-theme] .sync-chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  color: var(--ok);
}

[data-theme] .sync-chip[data-state='saving'],
[data-theme] .sync-chip[data-state='syncing'] {
  background: color-mix(in srgb, var(--neon-2) 12%, transparent);
  border-color: color-mix(in srgb, var(--neon-2) 42%, transparent);
  color: var(--neon-2);
}

[data-theme] .sync-chip[data-state='offline'] {
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 42%, transparent);
  color: var(--warn);
}

[data-theme] .sync-chip[data-state='failed'] {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 42%, transparent);
  color: var(--danger);
}

/* ------------------------------ global chips ----------------------------- */

[data-theme] .chip {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--glass-2);
  color: var(--ink-2);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}

[data-theme] .chip:hover {
  border-color: var(--neon);
  color: var(--neon);
  background: var(--accent-soft);
}

[data-theme] .count,
[data-theme] .mention-count {
  font-family: var(--mono);
  font-weight: 700;
}

[data-theme] .mention-count {
  background: linear-gradient(120deg, var(--neon-2), var(--neon-2-deep));
  color: #fff;
  box-shadow: 0 0 12px -3px var(--neon-2);
}

[data-theme] .badge,
[data-theme] .meta-tag,
[data-theme] .role-badge {
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--glass-2);
  border-color: var(--rule-strong);
  color: var(--muted);
}

/* ------------------------------ holo surfaces ---------------------------- */

/* Every "module" is the same device: translucent dark glass, a hairline frame,
   and a holographic separator along the top edge. */
[data-theme] .stat,
[data-theme] .kpi,
[data-theme] .chart,
[data-theme] .contact-card,
[data-theme] .info-card,
[data-theme] .detail-card,
[data-theme] .upgrade-card,
[data-theme] .feedback-card,
[data-theme] .pw-card,
[data-theme] .memory-card,
[data-theme] .req-card,
[data-theme] .uprole-card,
[data-theme] .thread-pick,
[data-theme] .generated,
[data-theme] .table-box,
[data-theme] .thinking,
[data-theme] .dialog-note,
[data-theme] .mm-fixed,
[data-theme] .account-grid,
[data-theme] .memory-item,
[data-theme] .info-row,
[data-theme] .qlevel {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 4%, var(--glass)), var(--glass-2));
}

[data-theme] .stat::before,
[data-theme] .kpi::before,
[data-theme] .chart::before,
[data-theme] .contact-card::before,
[data-theme] .info-card::before,
[data-theme] .detail-card::before,
[data-theme] .upgrade-card::before,
[data-theme] .feedback-card::before,
[data-theme] .pw-card::before,
[data-theme] .memory-card::before,
[data-theme] .req-card::before,
[data-theme] .uprole-card::before,
[data-theme] .table-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
  opacity: 0.45;
}

/* Cards that respond to the pointer get an illuminated frame, not a lift. */
[data-theme] .contact-card,
[data-theme] .info-card,
[data-theme] .upgrade-card,
[data-theme] .feedback-card,
[data-theme] .memory-card,
[data-theme] .req-card,
[data-theme] .thread-pick,
[data-theme] .qlevel {
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}

[data-theme] .contact-card:hover,
[data-theme] .info-card:hover,
[data-theme] .upgrade-card:hover,
[data-theme] .feedback-card:hover,
[data-theme] .memory-card:hover,
[data-theme] .req-card:hover,
[data-theme] .thread-pick:hover,
[data-theme] .qlevel:hover {
  border-color: color-mix(in srgb, var(--neon) 45%, var(--rule));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 18%, transparent), 0 14px 34px -22px var(--glow-strong);
}

/* A quiet HUD frame on every page body. */
[data-theme] .panel-inner {
  position: relative;
}

[data-theme] .panel-inner::before,
[data-theme] .panel-inner::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  pointer-events: none;
  border: 1px solid var(--hud);
  opacity: 0.8;
}

[data-theme] .panel-inner::before {
  top: 10px;
  left: 6px;
  border-right: 0;
  border-bottom: 0;
}

[data-theme] .panel-inner::after {
  bottom: 18px;
  right: 6px;
  border-left: 0;
  border-top: 0;
}

/* ------------------------------ stats & charts --------------------------- */

[data-theme] .stat,
[data-theme] .kpi {
  padding: 13px 14px;
}

[data-theme] .stat small,
[data-theme] .kpi small {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-theme] .stat strong,
[data-theme] .kpi strong {
  display: block;
  margin-top: 5px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--neon);
  text-shadow: 0 0 22px var(--glow);
}

[data-theme] .stat-note,
[data-theme] .chart-sub {
  font-size: 12px;
  color: var(--muted);
}

[data-theme] .chart h4 {
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--ink-2);
}

[data-theme] .bars .col i {
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--neon-2), var(--neon-2-deep));
  box-shadow: 0 0 14px -4px var(--neon-2);
}

[data-theme] .bars .col i.zero {
  background: var(--rule);
  box-shadow: none;
}

[data-theme] .legend-row .track {
  background: var(--rule);
  border-radius: 999px;
}

[data-theme] .legend-row .track i {
  background: linear-gradient(90deg, var(--neon-2-deep), var(--neon-2));
  box-shadow: 0 0 12px -4px var(--neon-2);
}

[data-theme] .legend-row .val {
  font-family: var(--mono);
  color: var(--ink-2);
}

/* -------------------------------- tables --------------------------------- */

[data-theme] .table-box {
  overflow: auto;
}

[data-theme] table.grid th,
[data-theme] .admin-table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: color-mix(in srgb, var(--neon) 6%, transparent);
  border-bottom: 1px solid var(--rule);
}

[data-theme] table.grid td,
[data-theme] .admin-table td {
  border-bottom: 1px solid var(--rule);
}

[data-theme] table.grid tbody tr,
[data-theme] .admin-table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

[data-theme] table.grid tbody tr:hover,
[data-theme] .admin-table tbody tr:hover {
  background: color-mix(in srgb, var(--neon) 7%, transparent);
}

[data-theme] tr.dash-row:focus-visible {
  outline: 2px solid var(--neon);
  outline-offset: -2px;
}

/* --------------------------- empty states & lede ------------------------- */

[data-theme] .empty {
  color: var(--muted);
}

[data-theme] .empty::before {
  content: '';
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 1px dashed color-mix(in srgb, var(--neon) 40%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 22px -8px var(--neon);
}

[data-theme] .lede {
  color: var(--muted);
  font-size: 13.5px;
}

[data-theme] .panel-inner h1 {
  font-size: clamp(20px, 1.1vw + 16px, 26px);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Date separators read like a system log line. */
[data-theme] .day-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-theme] .day-sep::before,
[data-theme] .day-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--rule-strong), transparent);
}

/* ============================== CHAT SURFACE ============================== */

/* The conversation sits directly on the animated environment: the page's own
   background is transparent so the grid, aurora and particles stay visible. */
[data-theme] .main {
  background: transparent;
}

[data-theme] .main::before,
[data-theme] .main::after {
  display: none;
}

[data-theme] .scroll {
  background: transparent;
}

/* ------------------------------- welcome hero ---------------------------- */

[data-theme] .welcome {
  position: relative;
  padding-top: 8px;
  text-align: center;
}

[data-theme] .welcome-core {
  position: relative;
  width: 108px;
  height: 108px;
  margin: 6px auto 4px;
  display: grid;
  place-items: center;
}

[data-theme] .welcome-core .wc-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  border-top-color: var(--neon);
  border-right-color: color-mix(in srgb, var(--neon) 30%, transparent);
  animation: coreSpin 7s linear infinite;
}

[data-theme] .welcome-core .wc-ring:nth-child(2) {
  inset: 14px;
  border-top-color: transparent;
  border-bottom-color: var(--violet);
  border-left-color: color-mix(in srgb, var(--violet) 30%, transparent);
  animation-duration: 4.6s;
  animation-direction: reverse;
}

[data-theme] .welcome-core .wc-core {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 34%, #fff, var(--neon) 42%, var(--neon-2) 78%);
  box-shadow: 0 0 34px 6px var(--glow-strong), 0 0 80px 18px color-mix(in srgb, var(--neon) 22%, transparent);
  animation: corePulse 3.4s var(--ease) infinite;
}

@keyframes coreSpin {
  to { transform: rotate(360deg); }
}

@keyframes corePulse {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50%      { transform: scale(1.08); opacity: 1; }
}

[data-theme] .welcome-hud {
  margin-bottom: 12px;
}

[data-theme] .welcome h1 {
  font-size: clamp(26px, 2.4vw + 16px, 42px);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: linear-gradient(100deg, var(--ink), var(--neon) 88%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme] .welcome p {
  max-width: 62ch;
  margin: 12px auto 0;
  color: var(--muted);
}

[data-theme] .tiles {
  margin-top: 22px;
}

[data-theme] .tile {
  position: relative;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 5%, var(--glass)), var(--glass-2));
  transition: border-color var(--dur) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease);
}

[data-theme] .tile:hover {
  border-color: color-mix(in srgb, var(--neon) 50%, var(--rule));
  transform: translateY(-2px);
  box-shadow: 0 16px 36px -24px var(--glow-strong);
}

[data-theme] .starters {
  margin-top: 14px;
}

[data-theme] .starters .chip {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* -------------------------------- messages ------------------------------- */

[data-theme] .msg {
  border-bottom: 0;
  padding: 16px 0;
  animation: msgIn var(--dur) var(--ease) both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* The user's own line: a dark holographic panel with a thin cyan edge. */
[data-theme] .msg.user .bubble {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--neon) 32%, var(--rule));
  border-radius: var(--radius-lg) 4px var(--radius-lg) var(--radius-lg);
  background: linear-gradient(160deg, color-mix(in srgb, var(--neon) 9%, var(--surface-2)), var(--surface));
  color: var(--ink);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--neon) 22%, transparent), 0 10px 30px -24px var(--glow-strong);
}

/* The AI answer stays quiet: no panel, no glow, just clean typography. */
[data-theme] .msg.ai .bubble,
[data-theme] .msg-content {
  background: transparent;
  border: 0;
  color: var(--ink-2);
}

[data-theme] .ai-mark {
  position: relative;
  border-radius: 8px;
  clip-path: var(--cut-sm);
  background: linear-gradient(140deg, var(--neon), var(--neon-deep));
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  box-shadow: 0 0 18px -6px var(--neon);
  animation: markPulse 3.2s var(--ease) infinite;
}

@keyframes markPulse {
  0%, 100% { box-shadow: 0 0 18px -8px var(--neon); }
  50%      { box-shadow: 0 0 26px -4px var(--neon); }
}

[data-theme] .ai-head .who {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}

[data-theme] .msg-model {
  font-family: var(--mono);
}

[data-theme] .prose {
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.7;
}

[data-theme] .prose strong {
  color: var(--ink);
}

[data-theme] .prose a {
  color: var(--neon-2);
  text-decoration-color: color-mix(in srgb, var(--neon-2) 50%, transparent);
}

[data-theme] .prose code {
  background: color-mix(in srgb, var(--neon) 12%, transparent);
  color: var(--neon);
  border-radius: 4px;
}

[data-theme] .prose pre {
  background: #04060e;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--neon) 10%, transparent);
}

[data-theme] .prose blockquote {
  border-left: 2px solid var(--neon);
  background: color-mix(in srgb, var(--neon) 7%, transparent);
  color: var(--ink-2);
}

[data-theme] .prose .caret {
  background: var(--neon);
  box-shadow: 0 0 10px var(--neon);
}

/* Message tools appear only when the bubble is hovered/focused. */
[data-theme] .msg-tools .tool {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 6px;
  color: var(--muted);
}

[data-theme] .msg-tools .tool:hover {
  background: color-mix(in srgb, var(--neon) 12%, transparent);
  color: var(--neon);
}

/* ------------------------- AI processing indicator ----------------------- */

[data-theme] .thinking {
  padding: 15px 16px;
  overflow: hidden;
}

/* An energy line travels along the top edge while the model works. */
[data-theme] .thinking::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon), var(--neon-deep), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: scanLine 2.6s linear infinite;
}

@keyframes scanLine {
  from { background-position: -60% 0; }
  to   { background-position: 160% 0; }
}

[data-theme] .ai-orb {
  background: radial-gradient(circle at 38% 34%, #fff, var(--neon) 44%, var(--neon-2));
  box-shadow: 0 0 24px 2px var(--glow-strong);
}

[data-theme] .orbit i {
  border-color: color-mix(in srgb, var(--neon) 55%, transparent);
  border-top-color: var(--neon);
}

[data-theme] .thinking-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--neon);
}

[data-theme] .thinking-scan i {
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
}

[data-theme] .thinking-note {
  font-size: 12px;
  color: var(--muted);
}

[data-theme] .steps {
  gap: 7px;
  font-size: 12.5px;
}

[data-theme] .step-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-2);
}

[data-theme] .step-detail {
  color: var(--muted);
}

[data-theme] .reason {
  border-left: 2px solid color-mix(in srgb, var(--violet) 60%, transparent);
  background: color-mix(in srgb, var(--violet) 6%, transparent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

[data-theme] .reason summary {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--violet);
}

/* Pending "typing" bubble used while the answer streams in. */
[data-theme] .typing-bubble {
  background: var(--glass-2);
  border: 1px solid var(--rule);
}

[data-theme] .typing-bubble i {
  background: var(--neon);
  box-shadow: 0 0 10px var(--neon);
}

/* ------------------------------- attachments ----------------------------- */

[data-theme] .file-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--glass-2);
}

[data-theme] .file-card:hover {
  border-color: color-mix(in srgb, var(--neon) 40%, var(--rule));
}

[data-theme] .img-frame {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: #04060e;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

[data-theme] .img-frame:hover {
  border-color: var(--neon);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 30%, transparent), 0 18px 40px -26px var(--neon);
}

[data-theme] .img-dl {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--glass);
  border: 1px solid var(--rule-strong);
  color: var(--ink-2);
}

[data-theme] .img-dl:hover {
  border-color: var(--neon);
  color: var(--neon);
}

/* Source chips: verifiable citations as HUD pills. */
[data-theme] .src-chip {
  border: 1px solid color-mix(in srgb, var(--neon-2) 35%, var(--rule));
  background: color-mix(in srgb, var(--neon-2) 9%, transparent);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

[data-theme] .src-chip:hover {
  border-color: var(--neon-2);
  color: var(--neon-2);
}

[data-theme] .src-chip .dot {
  background: var(--neon-2);
  box-shadow: 0 0 8px var(--neon-2);
}

[data-theme] .src-more {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

/* ============================== COMPOSER ================================= */

[data-theme] .composer-area {
  border-top: 1px solid color-mix(in srgb, var(--neon) 20%, var(--rule));
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--neon) 5%, var(--paper)) 60%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* The composer is a terminal input: dark glass, thin neon frame, inner light. */
[data-theme] .composer {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--neon) 30%, var(--rule-strong));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--glass), var(--glass-2));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--neon) 20%, transparent);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

[data-theme] .composer:focus-within,
[data-theme] .composer:focus-within {
  border-color: var(--neon);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--neon) 30%, transparent), 0 0 0 1px color-mix(in srgb, var(--neon) 40%, transparent),
    0 0 40px -14px var(--neon);
}

[data-theme] .composer textarea {
  color: var(--ink);
  font-family: var(--font);
}

[data-theme] .composer textarea::placeholder {
  color: var(--muted-2);
}

[data-theme] .att-chip {
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--glass-2);
  font-family: var(--mono);
  font-size: 10.5px;
}

[data-theme] .composer-row {
  border-color: var(--rule);
}

/* Model / thinking pickers: same weight as the tool toggles. */
[data-theme] .select-btn.compact {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--glass-2);
  color: var(--ink-2);
}

[data-theme] .select-btn.compact:hover {
  border-color: var(--neon);
  color: var(--neon);
}

[data-theme] .tool-toggle {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--glass-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

[data-theme] .tool-toggle .dot {
  background: currentColor;
}

[data-theme] .tool-toggle.on {
  border-color: var(--neon);
  background: var(--accent-soft);
  color: var(--neon);
  box-shadow: 0 0 16px -5px var(--neon);
}

[data-theme] .tool-toggle.on .dot {
  box-shadow: 0 0 8px currentColor;
}

[data-theme] .tool-toggle[disabled] {
  opacity: 0.4;
}

[data-theme] .tool-count {
  font-size: 10px;
  color: var(--muted);
}

[data-theme] .tool-toggle.on .tool-count {
  color: var(--neon);
}

[data-theme] .hint {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* Send: a compact vermilion circle that blooms while it is pressable. */
[data-theme] .send {
  border-radius: 50%;
  background: linear-gradient(140deg, var(--neon), var(--neon-deep));
  color: var(--accent-ink);
  box-shadow: 0 0 18px -6px var(--neon);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur-fast) var(--ease), filter var(--dur) var(--ease);
}

[data-theme] .send:hover:not(:disabled) {
  filter: brightness(1.12);
  box-shadow: 0 0 26px -4px var(--neon);
}

[data-theme] .send:active:not(:disabled) {
  transform: scale(0.93);
}

[data-theme] .send:disabled {
  background: var(--rule-strong);
  color: var(--muted-2);
  box-shadow: none;
}

[data-theme] .send.stop {
  background: linear-gradient(140deg, var(--red), var(--neon-deep));
  color: #fff;
  box-shadow: 0 0 22px -5px var(--red);
}

[data-theme] .composer-btn {
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--glass-2);
  color: var(--ink-2);
}

[data-theme] .composer-btn:hover {
  border-color: var(--neon);
  color: var(--neon);
}

[data-theme] .quota-strip span {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--glass-2);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
}

/* ================================ BUTTONS ================================ */

/* Secondary buttons: chamfered outline drawn with an inset fill layer, so the
   diagonal edges of the cut carry a real neon hairline. */
[data-theme] .btn {
  position: relative;
  isolation: isolate;
  gap: 7px;
  padding: 9px 15px;
  border: 0;
  border-radius: 0;
  clip-path: var(--cut-sm);
  background: var(--rule-strong);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), filter var(--dur) var(--ease);
}

[data-theme] .btn::before {
  content: '';
  position: absolute;
  inset: 1px;
  z-index: -1;
  clip-path: var(--cut-sm);
  background: var(--glass);
}

[data-theme] .btn:hover:not(:disabled) {
  background: var(--neon);
  color: var(--neon);
  filter: drop-shadow(0 0 12px -3px var(--glow-strong));
}

[data-theme] .btn:hover:not(:disabled)::before {
  background: var(--surface-2);
  color: var(--ink);
}

[data-theme] .btn:disabled {
  opacity: 0.5;
}

/* Primary: a solid vermilion face with a real bloom. */
[data-theme] .btn-primary {
  background: linear-gradient(120deg, var(--neon), var(--neon-deep));
  color: var(--accent-ink);
  filter: drop-shadow(0 6px 18px -8px var(--glow-strong));
}

[data-theme] .btn-primary::before {
  background: transparent;
}

[data-theme] .btn-primary:hover:not(:disabled) {
  background: linear-gradient(120deg, var(--accent-hover), var(--neon));
  color: var(--accent-ink);
  filter: drop-shadow(0 8px 24px -6px var(--neon));
}

[data-theme] .btn-primary:hover:not(:disabled)::before {
  background: transparent;
}

/* Destructive: a deeper red so it reads heavier than a primary action. */
[data-theme] .btn-danger {
  background: linear-gradient(120deg, var(--red), var(--neon-deep));
  color: #fff;
  filter: drop-shadow(0 6px 18px -9px var(--red));
}

[data-theme] .btn-danger::before {
  background: transparent;
}

[data-theme] .btn-danger:hover:not(:disabled) {
  background: linear-gradient(120deg, var(--red), var(--red));
  color: #fff;
  filter: drop-shadow(0 8px 24px -6px var(--red));
}

[data-theme] .btn-danger:hover:not(:disabled)::before {
  background: transparent;
}

[data-theme] .btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

[data-theme] .btn-quiet,
[data-theme] .text-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-theme] .btn-quiet:hover,
[data-theme] .text-btn:hover {
  color: var(--neon);
}

[data-theme] .row-more,
[data-theme] .more-btn {
  color: var(--muted);
  border-radius: 7px;
}

[data-theme] .row-more:hover,
[data-theme] .more-btn:hover {
  background: color-mix(in srgb, var(--neon) 12%, transparent);
  color: var(--neon);
}

/* ================================ OVERLAYS =============================== */

[data-theme] .overlay {
  background: rgba(2, 5, 12, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

[data-theme='light'] .overlay {
  background: rgba(10, 20, 36, 0.4);
}

[data-theme] .dialog,
[data-theme] .sheet-card {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--neon) 28%, var(--rule-strong));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 5%, var(--surface)), var(--surface));
  box-shadow: var(--shadow-md), 0 0 60px -30px var(--neon);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

[data-theme] .dialog::before,
[data-theme] .sheet-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
}

[data-theme] .dialog-head h3 {
  letter-spacing: 0.03em;
}

[data-theme] .dialog-head p {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

[data-theme] .dialog-close {
  border-radius: 8px;
  color: var(--muted);
}

[data-theme] .dialog-close:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

[data-theme] .dialog-foot {
  border-top: 1px solid var(--rule);
}

/* Popovers (model, thinking, action menus). */
[data-theme] .popover {
  border: 1px solid color-mix(in srgb, var(--neon) 26%, var(--rule-strong));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 5%, var(--surface)), var(--surface));
  box-shadow: var(--shadow-md), 0 0 50px -28px var(--neon);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme] .pop-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-theme] .pop-item {
  border-radius: 8px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

[data-theme] .pop-item:hover {
  background: color-mix(in srgb, var(--neon) 10%, transparent);
}

[data-theme] .pop-item.active {
  background: var(--accent-soft);
  color: var(--neon);
}

[data-theme] .pop-item .txt small {
  color: var(--muted);
}

[data-theme] .am-item:hover,
[data-theme] .hm-item:hover {
  background: color-mix(in srgb, var(--neon) 10%, transparent);
  color: var(--neon);
}

/* --------------------------- forms & controls ---------------------------- */

[data-theme] .field > span {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-theme] .field small {
  font-size: 11.5px;
  color: var(--muted);
}

[data-theme] .input,
[data-theme] .field input,
[data-theme] .field select,
[data-theme] .field textarea,
[data-theme] .dm-form textarea,
[data-theme] .search-field input,
[data-theme] .select-field select {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--glass-2);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

[data-theme] .input:focus,
[data-theme] .field input:focus,
[data-theme] .field select:focus,
[data-theme] .field textarea:focus,
[data-theme] .dm-form textarea:focus,
[data-theme] .select-field select:focus {
  outline: none;
  border-color: var(--neon);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--neon) 16%, transparent);
}

[data-theme] .field input::placeholder,
[data-theme] .field textarea::placeholder,
[data-theme] .dm-form textarea::placeholder {
  color: var(--muted-2);
}

[data-theme] .field input:read-only {
  background: color-mix(in srgb, var(--rule) 30%, transparent);
  color: var(--muted);
}

[data-theme] .switch span {
  background: var(--rule-strong);
}

[data-theme] .switch input:checked + span {
  background: linear-gradient(120deg, var(--neon-2), var(--neon-2-deep));
  box-shadow: 0 0 14px -4px var(--neon-2);
}

[data-theme] .switch input:checked + span::after {
  background: var(--accent-ink);
}

[data-theme] .toggle-row {
  border-top: 1px solid var(--rule);
}

/* Tabs: HUD style, the active one is underlit. */
[data-theme] .tabs {
  border-bottom: 1px solid var(--rule);
}

[data-theme] .tab {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

[data-theme] .tab:hover {
  color: var(--ink-2);
}

[data-theme] .tab.active {
  color: var(--neon);
  border-bottom-color: var(--neon);
  text-shadow: 0 0 12px var(--glow);
}

[data-theme] .role-chip,
[data-theme] .role-seg,
[data-theme] .dur-btn,
[data-theme] .stat-btn {
  border: 1px solid var(--rule-strong);
  border-radius: 7px;
  background: var(--glass-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}

[data-theme] .role-chip:hover,
[data-theme] .role-seg:hover,
[data-theme] .dur-btn:hover,
[data-theme] .stat-btn:hover {
  border-color: var(--neon);
  color: var(--neon);
}

[data-theme] .role-chip.active,
[data-theme] .role-seg.active,
[data-theme] .dur-btn.active,
[data-theme] .stat-btn.active {
  border-color: var(--neon);
  background: var(--accent-soft);
  color: var(--neon);
}

/* --------------------------- notices & toasts ---------------------------- */

[data-theme] .notice {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--glass-2);
  font-size: 12.5px;
}

[data-theme] .notice:not(.hidden) {
  border-left: 2px solid var(--neon);
}

[data-theme] .notice.error {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  border-left-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

[data-theme] .notice.success {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  border-left-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

[data-theme] .notice.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  border-left-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
}

[data-theme] .toasts {
  z-index: 500;
}

[data-theme] .toast {
  border: 1px solid color-mix(in srgb, var(--neon) 30%, var(--rule-strong));
  border-left: 3px solid var(--neon);
  border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 5%, var(--surface)), var(--surface));
  color: var(--ink);
  font-size: 12.5px;
  box-shadow: var(--shadow-md), 0 0 40px -26px var(--neon);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

[data-theme] .toast.success {
  border-left-color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 32%, var(--rule-strong));
}

[data-theme] .toast.error {
  border-left-color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, var(--rule-strong));
}

[data-theme] .toast.warn {
  border-left-color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 32%, var(--rule-strong));
}

/* ------------------------------- pagination ----------------------------- */

[data-theme] .pager {
  font-family: var(--mono);
}

[data-theme] .pager-info {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ============================== DASHBOARD ================================ */

[data-theme] .dash-head h1 {
  letter-spacing: 0.03em;
}

[data-theme] .dash-head p {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

[data-theme] .who-avatar {
  border-radius: 8px;
  clip-path: var(--cut-sm);
  background: linear-gradient(140deg, var(--neon), var(--neon-deep));
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 40%, transparent);
}

[data-theme] tr.dash-row {
  position: relative;
}

[data-theme] tr.dash-row::after {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: transparent;
  transition: background var(--dur) var(--ease);
}

[data-theme] tr.dash-row:hover::after {
  background: var(--neon);
}

[data-theme] .detail-card {
  padding: 16px;
}

[data-theme] .detail-action {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--glass-2);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

[data-theme] .detail-action:hover {
  border-color: var(--neon);
  color: var(--neon);
}

[data-theme] .qlevel-body {
  border-color: var(--rule);
}

[data-theme] .qlevel-chip,
[data-theme] .bonus {
  font-family: var(--mono);
  font-size: 10.5px;
}

[data-theme] .bonus {
  color: var(--ok);
}

[data-theme] .cap-row,
[data-theme] .dur-row {
  border-color: var(--rule);
}

[data-theme] .meter-track {
  background: var(--rule);
  border-radius: 999px;
}

[data-theme] .meter-track i,
[data-theme] .meter i {
  background: linear-gradient(90deg, var(--neon-2-deep), var(--neon-2));
}

[data-theme] .banned-card,
[data-theme] .reset-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--glass-2);
}

/* =============================== COMMUNITY =============================== */

[data-theme] .community-head {
  position: relative;
}

[data-theme] .community-head h1 {
  letter-spacing: 0.03em;
}

[data-theme] .community-scroll {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

[data-theme] .dm {
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--glass);
  transition: border-color var(--dur) var(--ease);
}

[data-theme] .dm:hover {
  border-color: color-mix(in srgb, var(--neon) 34%, var(--rule));
}

[data-theme] .dm.mine {
  border-color: color-mix(in srgb, var(--neon) 38%, var(--rule));
  background: linear-gradient(160deg, color-mix(in srgb, var(--neon) 9%, var(--surface-2)), var(--surface));
}

[data-theme] .dm.from-owner {
  border-color: color-mix(in srgb, var(--violet) 45%, var(--rule));
  background: linear-gradient(160deg, color-mix(in srgb, var(--violet) 10%, var(--surface-2)), var(--surface));
}

[data-theme] .dm-body {
  color: var(--ink-2);
}

[data-theme] .dm-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

[data-theme] .dm-time {
  font-size: 10px;
  letter-spacing: 0.06em;
}

[data-theme] .dm-body.removed {
  color: var(--muted);
}

[data-theme] .mention,
[data-theme] .mention-chip {
  border-radius: 5px;
  background: color-mix(in srgb, var(--neon-2) 14%, transparent);
  color: var(--neon-2);
  font-weight: 600;
}

[data-theme] .mention-me,
[data-theme] .mention.mention-me {
  background: color-mix(in srgb, var(--magenta) 18%, transparent);
  color: var(--magenta);
}

[data-theme] .pin-bar {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--rule));
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
}

[data-theme] .presence,
[data-theme] .presence-cell {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ok);
}

[data-theme] .presence-dot,
[data-theme] .pin-dot {
  box-shadow: 0 0 8px currentColor;
}

[data-theme] .jump-btn {
  border: 1px solid color-mix(in srgb, var(--neon) 40%, var(--rule));
  border-radius: 999px;
  background: var(--glass);
  color: var(--neon);
  font-family: var(--mono);
  font-size: 11px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

[data-theme] .jump-btn:hover {
  background: var(--accent-soft);
}

[data-theme] .mod-row,
[data-theme] .mod-mute {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--glass-2);
}

[data-theme] .mr-action {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warn);
}

[data-theme] .mr-action.ok {
  color: var(--ok);
}

[data-theme] .mr-target,
[data-theme] .mr-who {
  font-weight: 600;
  color: var(--ink);
}

[data-theme] .mm-head strong {
  font-family: var(--font-display);
}

[data-theme] .mm-left {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--warn);
}

[data-theme] .mm-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* ============================ INBOX / OWNER CHAT ========================= */

[data-theme] .dm-list {
  gap: 8px;
}

[data-theme] .oc-head {
  border-bottom: 1px solid var(--rule);
}

[data-theme] .oc-title h1,
[data-theme] .oc-title strong {
  letter-spacing: 0.03em;
}

[data-theme] .oc-list-item {
  padding: 11px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--glass-2);
}

[data-theme] .oc-list-item.unread,
[data-theme] .thread-row.unread {
  border-color: color-mix(in srgb, var(--neon) 45%, var(--rule));
  box-shadow: inset 3px 0 0 var(--neon);
}

[data-theme] .oc-thread-note {
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--rule));
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  font-size: 12.5px;
}

[data-theme] .dm-quote {
  border-left: 2px solid color-mix(in srgb, var(--neon) 60%, transparent);
  background: color-mix(in srgb, var(--neon) 7%, transparent);
  border-radius: 0 6px 6px 0;
}

[data-theme] .composer-reply {
  border: 1px solid color-mix(in srgb, var(--neon) 32%, var(--rule));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--neon) 7%, transparent);
}

[data-theme] .composer-reply .cr-text small {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--neon);
}

[data-theme] .cr-close:hover {
  color: var(--danger);
}

/* =========================== INFO & SETTINGS ============================= */

[data-theme] .info-section h2,
[data-theme] .chart h4 {
  letter-spacing: 0.06em;
}

[data-theme] .info-row {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--glass-2);
  padding: 10px 12px;
}

[data-theme] .info-row strong {
  color: var(--neon);
  font-family: var(--mono);
}

[data-theme] .tier-table th {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

[data-theme] .spec-list li::before {
  color: var(--neon);
}

[data-theme] .memory-card {
  padding: 12px;
}

[data-theme] .mem-head strong {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

[data-theme] .upgrade-option,
[data-theme] .upgrade-option.active {
  border-radius: var(--radius);
}

[data-theme] .upgrade-option {
  border: 1px solid var(--rule);
  background: var(--glass-2);
}

[data-theme] .upgrade-option.active {
  border-color: var(--neon);
  background: var(--accent-soft);
  box-shadow: 0 0 18px -8px var(--neon);
}

[data-theme] .uc-price {
  font-family: var(--mono);
  color: var(--neon);
}

[data-theme] .life-box {
  border: 1px solid color-mix(in srgb, var(--neon) 30%, var(--sidebar-rule));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--neon) 8%, transparent);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--sidebar-ink);
}

/* ============================= WELCOME GATE ============================== */

[data-theme] .welcome-gate {
  background: radial-gradient(ellipse 90% 70% at 50% 0%, #071120 0%, #04060e 60%, #02040a 100%);
}

[data-theme='light'] .welcome-gate {
  background: radial-gradient(ellipse 90% 70% at 50% 0%, #e7edf7 0%, #dde5f2 60%, #d3dcec 100%);
}

[data-theme] .gate-card {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--neon) 34%, var(--rule-strong));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 6%, var(--glass)), var(--glass-2));
  box-shadow: var(--shadow-md), 0 0 90px -40px var(--neon);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme] .gate-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
}

[data-theme] .gate-head {
  border-bottom: 1px solid var(--rule);
}

[data-theme] .gate-logo {
  border-radius: 10px;
  clip-path: var(--cut-sm);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon) 45%, transparent), 0 0 22px -5px var(--neon);
  animation: gateLogoIn 0.7s var(--ease) both;
}

@keyframes gateLogoIn {
  from { opacity: 0; transform: scale(0.82) rotate(-6deg); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}

[data-theme] .gate-kicker,
[data-theme] .gate-label {
  font-family: var(--mono);
  letter-spacing: 0.2em;
  color: var(--neon);
}

[data-theme] .gate-head h1 {
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

[data-theme] .gate-block {
  border-bottom: 1px solid var(--rule);
}

[data-theme] .cd-cell {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--glass-2);
}

[data-theme] .cd-cell strong {
  font-family: var(--mono);
  color: var(--ink);
}

[data-theme] .cd-cell.cd-ms strong {
  color: var(--neon);
  text-shadow: 0 0 16px var(--glow-strong);
}

[data-theme] .cd-cell span {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  color: var(--muted);
}

[data-theme] .gate-expiry {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
}

[data-theme] .gate-role-badge {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  border: 1px solid var(--neon);
  background: var(--accent-soft);
  color: var(--neon);
}

[data-theme] .gate-role-note {
  color: var(--muted);
}

[data-theme] .gate-benefits li {
  color: var(--ink-2);
}

[data-theme] .gate-benefits li::before {
  border-color: var(--ok);
}

/* The intro's feature grid and unlock chips: read-only status, not decoration. */
[data-theme] .gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

[data-theme] .gate-cell {
  padding: 9px 11px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--glass-2);
}

[data-theme] .gate-cell small {
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-theme] .gate-cell strong {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

[data-theme] .gate-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

[data-theme] .gl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--glass-2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

[data-theme] .gl-chip small {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}

[data-theme] .gl-chip.on {
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
  color: var(--ok);
  background: var(--ok-soft);
}

[data-theme] .gl-chip.on small {
  color: color-mix(in srgb, var(--ok) 75%, transparent);
}

[data-theme] .gl-chip.bonus {
  border-color: color-mix(in srgb, var(--violet) 50%, transparent);
  color: var(--violet);
  background: var(--violet-soft);
}

[data-theme] .gl-chip.bonus small {
  color: color-mix(in srgb, var(--violet) 78%, transparent);
}

@media (max-width: 480px) {
  [data-theme] .gate-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The gate action is the first real cyberpunk button a visitor meets. */
[data-theme] .gate-start {
  position: relative;
  border: 0;
  clip-path: var(--cut);
  background: linear-gradient(120deg, var(--neon), var(--neon-deep));
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  filter: drop-shadow(0 10px 30px -10px var(--glow-strong));
  transition: filter var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}

[data-theme] .gate-start:hover:not(:disabled) {
  filter: drop-shadow(0 12px 34px -8px var(--neon)) brightness(1.08);
}

[data-theme] .gate-start:active:not(:disabled) {
  transform: translateY(1px);
}

[data-theme] .gate-hint {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Pressing "Mulai Chat" simply fades the intro away: no fake progress bar. */
[data-theme] .welcome-gate {
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}

[data-theme] .welcome-gate.gate-leaving {
  opacity: 0;
  transform: scale(1.02);
  filter: blur(10px);
  pointer-events: none;
}

/* ========================= SYSTEM ACCESS (LOGIN) ========================= */

/* The auth page is the front door of the terminal: dark environment, glass
   intro column, and an access panel with a real neon frame. */
.auth-page {
  position: relative;
  z-index: 1;
  background: transparent;
}

[data-theme] .auth-intro {
  border-right: 1px solid color-mix(in srgb, var(--neon) 22%, var(--rule));
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 5%, var(--glass)), var(--glass-2));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

[data-theme] .auth-intro h1 {
  letter-spacing: 0.02em;
}

[data-theme] .auth-intro .wordmark {
  color: var(--ink);
  text-shadow: 0 0 20px var(--glow-strong);
}

[data-theme] .auth-intro p,
[data-theme] .auth-intro .lede {
  color: var(--muted);
}

[data-theme] .auth-form-col {
  background: transparent;
}

/* The access panel: chamfered, hairline neon, and it materialises on load. */
[data-theme] .auth-card {
  position: relative;
  padding: 24px 22px;
  border: 1px solid color-mix(in srgb, var(--neon) 32%, var(--rule-strong));
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 6%, var(--glass)), var(--glass-2));
  box-shadow: var(--shadow-md), 0 0 80px -44px var(--neon);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: panelIn 0.5s var(--ease) both;
}

[data-theme] .auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: none; }
}

[data-theme] .auth-card h2 {
  letter-spacing: 0.03em;
}

[data-theme] .pane.active {
  animation: paneIn 0.32s var(--ease) both;
}

@keyframes paneIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

[data-theme] .auth-jump {
  border: 1px solid color-mix(in srgb, var(--neon) 34%, var(--rule));
  border-radius: 999px;
  background: var(--glass-2);
  color: var(--neon);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

[data-theme] .theme-toggle-auth {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--glass);
}

/* ============================= IMAGE VIEWER ============================== */

[data-theme] .viewer-overlay {
  background: rgba(2, 5, 12, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

[data-theme] .viewer-card {
  border: 1px solid color-mix(in srgb, var(--neon) 30%, var(--rule-strong));
  background: linear-gradient(180deg, color-mix(in srgb, var(--neon) 4%, var(--surface)), var(--surface));
  box-shadow: var(--shadow-md), 0 0 70px -34px var(--neon);
}

[data-theme] .viewer-stage {
  background: #04060e;
  border: 1px solid var(--rule);
}

[data-theme] .viewer-bar {
  border-top: 1px solid var(--rule);
}

[data-theme] .viewer-counter,
[data-theme] .viewer-caption {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

[data-theme] .viewer-nav,
[data-theme] .viewer-zoom {
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--glass-2);
  color: var(--ink-2);
}

[data-theme] .viewer-nav:hover,
[data-theme] .viewer-zoom:hover {
  border-color: var(--neon);
  color: var(--neon);
}

/* ========================= BAN & BLOCK OVERLAYS ========================== */

[data-theme] .ban-overlay {
  z-index: 200;
}

[data-theme] .ban-dialog {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--rule-strong));
  box-shadow: var(--shadow-md), 0 0 80px -40px var(--danger);
}

[data-theme] .ban-badge {
  border-radius: 10px;
  clip-path: var(--cut-sm);
  background: linear-gradient(140deg, var(--red), var(--neon-deep));
  color: #fff;
  box-shadow: 0 0 22px -6px var(--red);
}

[data-theme] .ban-hero h3 {
  letter-spacing: 0.04em;
}

[data-theme] .ban-facts dt {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

[data-theme] .ban-facts dd {
  color: var(--ink);
}

[data-theme] .ban-note {
  border-left: 2px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: 0 var(--radius) var(--radius) 0;
}

[data-theme] .reset-hero,
[data-theme] .reset-facts {
  border-color: var(--rule);
}

/* ============================= RESPONSIVE =============================== */

/* Tablet: fewer decorations, same identity. */
@media (max-width: 1024px) {
  [data-theme] .fx-grid {
    opacity: 0.5;
  }
  [data-theme] .fx-particles i:nth-child(n + 7) {
    display: none;
  }
  [data-theme] .panel-inner::before,
  [data-theme] .panel-inner::after {
    display: none;
  }
}

/* Phone: keep the neon accents, drop the expensive backdrop work. */
@media (max-width: 720px) {
  [data-theme] .topbar,
  [data-theme] .composer-area,
  [data-theme] .dialog,
  [data-theme] .popover,
  [data-theme] .auth-card,
  [data-theme] .toast {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  [data-theme] .fx-particles i {
    display: none;
  }
  [data-theme] .fx-scan {
    display: none;
  }
  [data-theme] .stat strong,
  [data-theme] .kpi strong {
    font-size: 20px;
  }
}

/* Very small phones: the hero puts away its ring so the text leads. */
@media (max-width: 400px) {
  [data-theme] .welcome-core {
    width: 82px;
    height: 82px;
  }
  [data-theme] .welcome h1 {
    text-transform: none;
  }
}

/* ======================= REDUCED MOTION & ACCESSIBILITY ================== */

@media (prefers-reduced-motion: reduce) {
  [data-theme] .fx-grid,
  [data-theme] .fx-aurora,
  [data-theme] .fx-scan,
  [data-theme] .fx-particles i,
  [data-theme] .topbar::after,
  [data-theme] .thinking::after,
  [data-theme] .welcome-core .wc-ring,
  [data-theme] .welcome-core .wc-core,
  [data-theme] .ai-mark,
  [data-theme] .gate-logo,
  [data-theme] .auth-card,
  [data-theme] .pane.active,
  [data-theme] .msg,
  [data-theme] .hud-tag::before,
  [data-theme] .send.stop {
    animation: none !important;
  }
  [data-theme] .msg,
  [data-theme] .tile,
  [data-theme] .new-btn,
  [data-theme] .gate-start {
    transition: none;
  }
}

/* A visible keyboard focus ring everywhere, drawn on top of any glow. */
:focus-visible {
  outline: 2px solid var(--neon);
  outline-offset: 2px;
}

[data-theme] .side-item:focus-visible,
[data-theme] .hist:focus-visible {
  outline: 2px solid var(--neon);
  outline-offset: -2px;
}

/* ==========================================================================
   PINNED CHAT COMPOSER
   --------------------------------------------------------------------------
   The community room, the member's private line with the owner, and the owner's
   1-on-1 threads all share one layout: the header stays put, the message list
   is the only scroller, and the writing area sits at the very bottom of the
   visible viewport on PC, tablet and phone.

   `--app-h` is written by app.js from the VISUAL viewport, so a virtual
   keyboard that only shrinks the visual viewport still lifts the composer
   instead of covering it. Without a keyboard open the property is absent and
   the shell falls back to 100dvh.
   ========================================================================== */

@supports (height: 100dvh) {
  .app-body,
  .shell {
    height: var(--app-h, 100dvh);
  }
}

[data-theme] .panel.chat-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* The composer is the last row, so nothing may scroll the panel itself. */
  overscroll-behavior: contain;
}

[data-theme] .panel.chat-panel > .panel-inner {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  padding-bottom: 10px;
}

/* Headings, notices and the pinned bar keep their natural height. */
[data-theme] .panel.chat-panel .community-head,
[data-theme] .panel.chat-panel .oc-head,
[data-theme] .panel.chat-panel > .panel-inner > h1,
[data-theme] .panel.chat-panel > .panel-inner > .lede,
[data-theme] .panel.chat-panel > .panel-inner > .contact-grid,
[data-theme] .panel.chat-panel > .panel-inner > .notice,
[data-theme] .panel.chat-panel > .panel-inner > .pin-bar {
  flex: 0 0 auto;
}

/* The one scroller: whatever holds the messages absorbs the free space. */
[data-theme] .panel.chat-panel .community-scroll,
[data-theme] .panel.chat-panel > .panel-inner > .dm-list,
[data-theme] .panel.chat-panel .oc-list,
[data-theme] .panel.chat-panel .oc-thread {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

[data-theme] .panel.chat-panel .community-scroll,
[data-theme] .panel.chat-panel > .panel-inner > .dm-list,
[data-theme] .panel.chat-panel .oc-list {
  overflow-y: auto;
}

/* The owner's thread is its own column: note on top, list scrolls, form last. */
[data-theme] .panel.chat-panel .oc-thread {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

[data-theme] .panel.chat-panel .oc-thread > .dm-list {
  flex: 1 1 auto;
  min-height: 0;
  /* Beats the base `.oc-thread .dm-list { max-height: 52vh }` cap, otherwise the
     list stops short and the composer floats in the middle of the panel. */
  max-height: none;
  overflow-y: auto;
  margin-bottom: 10px;
}

[data-theme] .panel.chat-panel .oc-thread > .oc-thread-note {
  flex: 0 0 auto;
}

/* The writing area itself never shrinks and never scrolls away. */
[data-theme] .panel.chat-panel .dm-form {  flex: 0 0 auto;
  margin-top: 0;
  background: var(--paper);
}

/* The textarea grows with the message but caps out, so the list keeps room. */
[data-theme] .panel.chat-panel .dm-form textarea {
  max-height: 22vh;
}

/* The jump pill floats over the last message instead of taking a row. */
[data-theme] .panel.chat-panel .jump-btn {
  flex: 0 0 auto;
  align-self: center;
}

/* Tablet and phone: a little more breathing room around the writing area. */
@media (max-width: 1024px) {
  [data-theme] .panel.chat-panel > .panel-inner {
    padding-bottom: 8px;
  }

  /* With the keyboard up the viewport is short, so the decorative top matter of
     a chat panel steps aside and the writing area keeps a usable height. It
     comes straight back the moment the keyboard closes. */
  html.kb-open .panel.chat-panel > .panel-inner > h1,
  html.kb-open .panel.chat-panel > .panel-inner > .lede,
  html.kb-open .panel.chat-panel > .panel-inner > .contact-grid,
  html.kb-open .panel.chat-panel .community-head p,
  html.kb-open .panel.chat-panel .oc-head p,
  html.kb-open .panel.chat-panel .oc-head .input {
    display: none;
  }

  html.kb-open .panel.chat-panel .community-head,
  html.kb-open .panel.chat-panel .oc-head {
    margin-bottom: 6px;
  }
}

@media (max-width: 720px) {
  /* Keep the keyboard-safe area clear on phones with a home gesture bar. */
  [data-theme] .panel.chat-panel .dm-form {
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  [data-theme] .panel.chat-panel .dm-form textarea {
    max-height: 18vh;
  }
}

/* ==========================================================================
   INDUSTRIAL CHROME — RETRO-FUTURISTIC CYBERDECK DETAIL
   --------------------------------------------------------------------------
   The layers above give the system its colour and layout. This one gives it the
   hardware character: a CRT raster over the whole shell, barcode and serial
   markings on the real panels, chamfered/stepped frames, segmented readouts and
   magenta used strictly as the secondary signal colour.

   Nothing here invents data. Every marking is either derived from a real value
   the app already knows, or is a pure pattern that claims nothing.
   ========================================================================== */

/* ------------------------------- CRT raster ------------------------------ */

.fx-crt {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.16) 3px,
    rgba(0, 0, 0, 0) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.55;
}

[data-theme='light'] .fx-crt {
  opacity: 0.22;
}

/* A single soft raster band drifting down the screen, like a CRT refresh. */
.fx-crt::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 140px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.035), transparent);
  animation: crtBand 7.5s linear infinite;
}

@keyframes crtBand {
  from { top: -140px; }
  to   { top: 100%; }
}

/* ------------------------------- barcodes -------------------------------- */

/* A generated barcode: an exact, honest pattern (a serial is a serial, not a
   measurement), used as an industrial edge marking. */
.barcode {
  display: inline-block;
  height: 14px;
  background-image:
    repeating-linear-gradient(
      90deg,
      currentColor 0 1px,
      transparent 1px 3px,
      currentColor 3px 5px,
      transparent 5px 6px,
      currentColor 6px 8px,
      transparent 8px 11px,
      currentColor 11px 12px,
      transparent 12px 14px,
      currentColor 14px 17px,
      transparent 17px 18px
    );
  opacity: 0.5;
}

/* A machine-readable serial line: mono, tracked out, hairline underlined. */
.serial {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
}

/* ------------------------------- panel frames ---------------------------- */

/* An industrial frame: thin border, one accent corner bracket, and a stepped
   notch on the opposite corner. Cheaper than a wrapper and it never affects
   layout because everything is drawn with pseudo-elements. */
.frame {
  position: relative;
}

.frame::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--neon);
  border-left: 1px solid var(--neon);
  pointer-events: none;
}

.frame::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-right: 1px solid var(--magenta);
  border-bottom: 1px solid var(--magenta);
  pointer-events: none;
}

/* A vertical accent rail that grows out of a panel edge. */
.rail {
  position: relative;
  padding-left: 14px;
}

.rail::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--neon), var(--neon-deep) 60%, transparent);
}

/* ------------------------------- readouts -------------------------------- */

/* Segmented readout: discrete blocks instead of a smooth bar, so a partially
   filled meter reads like hardware. */
.seg-meter {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.seg-meter i {
  width: 7px;
  height: 12px;
  background: var(--rule-strong);
  transform: skewX(-12deg);
}

.seg-meter i.on {
  background: var(--neon);
  box-shadow: 0 0 10px -2px var(--neon);
}

.seg-meter i.warn {
  background: var(--warn);
  box-shadow: 0 0 10px -2px var(--warn);
}

/* A live signal trace: pure activity indicator, claims no measurement. */
.signal {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.signal i {
  width: 2px;
  background: currentColor;
  height: 30%;
  animation: signalPulse 1.15s ease-in-out infinite;
}

.signal i:nth-child(2) { animation-delay: 0.14s; }
.signal i:nth-child(3) { animation-delay: 0.28s; }
.signal i:nth-child(4) { animation-delay: 0.42s; }
.signal i:nth-child(5) { animation-delay: 0.56s; }

@keyframes signalPulse {
  0%, 100% { height: 25%; opacity: 0.55; }
  50%      { height: 100%; opacity: 1; }
}

/* ------------------------------- sys strip ------------------------------- */

/* The hero's status line: real role, real model, real thinking level, real
   transport state. Reads like a device's status row. */
[data-theme] .sys-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0;
  margin: 16px auto 0;
  max-width: 640px;
  border: 1px solid var(--rule);
  background: var(--glass-2);
}

[data-theme] .sys-cell {
  flex: 1 1 auto;
  min-width: 96px;
  padding: 7px 12px;
  border-right: 1px solid var(--rule);
  text-align: left;
}

[data-theme] .sys-cell:last-child {
  border-right: 0;
}

[data-theme] .sys-cell small {
  display: block;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-2);
}

[data-theme] .sys-cell strong {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

[data-theme] .sys-cell strong.live {
  color: var(--ok);
}

[data-theme] .sys-cell strong.degraded {
  color: var(--warn);
}

/* --------------------------- topbar / sidebar marks ---------------------- */

/* A magenta hairline under the brand block marks the secondary signal colour,
   and a barcode sits at the sidebar's foot like a device sticker. */
[data-theme='dark'] .topbar,
[data-theme='system'] .topbar {
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--magenta) 14%, transparent);
}

[data-theme] .side-foot .barcode {
  color: var(--sidebar-ink);
  margin-top: 2px;
}

[data-theme] .side-foot .serial {
  color: var(--sidebar-muted);
}

/* --------------------------- magenta as signal --------------------------- */

/* Magenta is reserved for "attention, but not an error": a pending state, an
   escalated notice, the mention badge. Never a whole surface. */
[data-theme] .notice.warn:not(.hidden) {
  border-left-color: var(--magenta);
}

[data-theme] .badge.vip {
  background: color-mix(in srgb, var(--magenta) 16%, transparent);
  color: var(--magenta);
  border-color: color-mix(in srgb, var(--magenta) 42%, transparent);
}

[data-theme] .gl-chip.bonus {
  border-color: color-mix(in srgb, var(--magenta) 50%, transparent);
  color: var(--magenta);
  background: color-mix(in srgb, var(--magenta) 12%, transparent);
}

/* --------------------- scanline on the active surfaces ------------------- */

/* The chat scroller and the dashboard get a very light raster of their own, so
   the "screen" reads as a display rather than a flat page. */
[data-theme] .scroll::after,
[data-theme] .dash-panel-surface::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 3px,
    color-mix(in srgb, var(--neon) 3%, transparent) 3px 4px
  );
  opacity: 0.5;
}

[data-theme] .scroll {
  position: relative;
}

@media (prefers-reduced-motion: reduce) {
  .fx-crt::after,
  .signal i {
    animation: none;
  }
}

/* Phone: the raster bands cost more than they return on a small screen. */
@media (max-width: 720px) {
  .fx-crt {
    opacity: 0.3;
  }
  [data-theme] .scroll::after {
    display: none;
  }
  [data-theme] .sys-cell {
    min-width: 50%;
  }
  [data-theme] .sys-cell:nth-child(2n) {
    border-right: 0;
  }
}

/* ==========================================================================
   JAPANESE TYPOGRAPHIC IDENTITY
   --------------------------------------------------------------------------
   The Japanese script here is a GRAPHIC layer, never a carrier of information:
   every element is aria-hidden, and each term is a real word that accurately
   describes the surface it sits on (人工知能 = artificial intelligence,
   会話 = conversation, 接続 = connection). Nothing is machine-translated filler.
   ========================================================================== */

[data-theme] .jp {
  font-family: var(--jp);
  font-weight: 700;
  line-height: 1;
}

/* Oversized vertical script down the sidebar: the poster mark of the shell. */
[data-theme] .jp-rail {
  position: absolute;
  top: 96px;
  right: 6px;
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: var(--jp);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: color-mix(in srgb, var(--neon) 55%, transparent);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

/* A wide-tracked katakana label, used as a section eyebrow. */
[data-theme] .jp-label {
  font-family: var(--jp);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.42em;
  color: var(--muted-2);
}

/* The hero's oversized ghost glyph: editorial scale, zero information load. */
[data-theme] .jp-ghost {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--jp);
  font-size: clamp(120px, 22vw, 300px);
  font-weight: 900;
  line-height: 0.8;
  letter-spacing: -0.04em;
  color: transparent;
  -webkit-text-stroke: 1px color-mix(in srgb, var(--neon) 16%, transparent);
  pointer-events: none;
  user-select: none;
  z-index: -1;
}

/* A staggered character reveal for the identity mark. */
[data-theme] .jp-reveal > span {
  display: inline-block;
  animation: jpReveal 0.5s var(--ease) both;
}

[data-theme] .jp-reveal > span:nth-child(1) { animation-delay: 0.04s; }
[data-theme] .jp-reveal > span:nth-child(2) { animation-delay: 0.12s; }
[data-theme] .jp-reveal > span:nth-child(3) { animation-delay: 0.2s; }
[data-theme] .jp-reveal > span:nth-child(4) { animation-delay: 0.28s; }

@keyframes jpReveal {
  from { opacity: 0; transform: translateY(6px) scale(1.14); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------- geometric graphics -------------------------- */

/* Diagonal hazard hatching, used as an edge band on identity surfaces. */
.hatch {
  height: 6px;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--neon) 0 2px,
    transparent 2px 7px
  );
  opacity: 0.35;
}

/* Corner coordinates: a technical registration mark. */
.coord {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  color: var(--muted-2);
  text-transform: uppercase;
}

/* The login page's identity poster: a geometric composition of rules and marks. */
[data-theme] .jp-poster {
  position: relative;
  padding: 18px 0 14px;
}

[data-theme] .jp-poster .jp-poster-mark {
  font-family: var(--jp);
  font-size: clamp(38px, 5vw, 62px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--neon);
}

[data-theme] .jp-poster .jp-poster-sub {
  margin-top: 8px;
  font-family: var(--jp);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--muted);
}

[data-theme] .jp-poster::after {
  content: '';
  position: absolute;
  right: 0;
  top: 18px;
  width: 46px;
  height: 46px;
  border-top: 1px solid var(--neon);
  border-right: 1px solid var(--neon);
  opacity: 0.6;
}

@media (max-width: 900px) {
  [data-theme] .jp-rail {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-theme] .jp-reveal > span {
    animation: none;
  }
}

/* Author credit: shown in the sidebar footer and on the login page. */
.side-credit {
  margin: 2px 0 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.85;
}

.brand-credit {
  margin: 14px 0 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ==========================================================================
   CODE BOXES, SMART SCROLL, AND THE WIDE OWNER CHAT
   ========================================================================== */

/* Every code block is a black box: a labelled header with a one-tap copy
   button, then the code on a dark surface regardless of the page theme. */
.code-box {
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0b0d12;
  box-shadow: 0 8px 24px rgba(4, 6, 12, 0.28);
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px 7px 14px;
  background: #14171f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.code-lang {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8c93a3;
  font-weight: 600;
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: #c8cdd8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.code-copy:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.24);
}

.code-copy.copied {
  color: #62f0a6;
  border-color: rgba(98, 240, 166, 0.5);
  background: rgba(98, 240, 166, 0.12);
}

.code-box pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: #0b0d12;
}

.code-box pre code {
  display: block;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  color: #e6e9ef;
  background: none;
  border: 0;
  padding: 0;
  white-space: pre;
  tab-size: 2;
}

/* Smart-scroll jump button: only appears when the reader is not at the bottom. */
.main {
  position: relative;
}

.chat-jump {
  position: absolute;
  right: 20px;
  bottom: 132px;
  z-index: 40;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line, rgba(0, 0, 0, 0.12));
  background: var(--paper, #fff);
  color: var(--ink, #14171f);
  box-shadow: 0 8px 22px rgba(4, 6, 12, 0.22);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.chat-jump:hover {
  transform: translateY(-2px);
}

.chat-jump.hidden {
  display: none;
}

[data-theme='dark'] .chat-jump {
  background: var(--surface, #161a22);
  color: var(--ink, #e6e9ef);
  border-color: var(--line, rgba(255, 255, 255, 0.14));
}

@media (max-width: 720px) {
  .chat-jump {
    right: 14px;
    bottom: 118px;
  }
}

/* Wide owner chat: two panes instead of one narrow column. */
@media (min-width: 1025px) {
  [data-theme] .panel.chat-panel.oc-split > .panel-inner {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 22px;
    row-gap: 10px;
    max-width: 1280px;
    width: 100%;
    align-items: stretch;
  }

  [data-theme] .panel.chat-panel.oc-split .oc-head {
    grid-column: 1 / -1;
    margin-bottom: 4px;
  }

  [data-theme] .panel.chat-panel.oc-split .oc-list {
    grid-column: 1;
    grid-row: 2;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
    border-right: 1px solid var(--line, rgba(0, 0, 0, 0.08));
  }

  [data-theme] .panel.chat-panel.oc-split .oc-thread {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    overflow: hidden;
  }

  [data-theme] .panel.chat-panel.oc-split .oc-thread > .dm-list {
    margin-bottom: 10px;
  }
}

/* ==========================================================================
   COMMUNITY CHAT LAYOUT — phone, tablet and PC
   --------------------------------------------------------------------------
   The community room used to sit inside a tall rounded panel that painted a
   solid dark surface: with only a few messages the area below the last message
   was a large empty black block that pushed the conversation up and read as a
   dead zone. Here the room becomes a real chat surface:
     - the scroller loses its opaque box, so no empty black block is painted;
     - the message list is bottom-anchored, so messages rest just above the
       composer and the free space sits above them, not below;
     - one scroller only (the inner list stops scrolling on its own);
     - spacing and column width are tuned per breakpoint.
   ========================================================================== */

/* One scroller: the room body scrolls, the inner list does not. */
[data-theme] .panel.chat-panel .community-scroll {
  display: flex;
  flex-direction: column;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 4px 2px 10px;
  margin-bottom: 8px;
}

[data-theme] .panel.chat-panel .community-list {
  /* margin-top:auto anchors short conversations to the bottom of the room. */
  margin-top: auto;
  margin-bottom: 0;
  max-height: none;
  overflow: visible;
  padding-right: 4px;
  padding-bottom: 2px;
}

/* The "load older messages" control stays readable at the bottom edge. */
[data-theme] .panel.chat-panel .community-scroll > .load-more {
  margin: 10px auto 0;
}

/* A soft day separator that only spans the reading column, not the full width. */
[data-theme] .panel.chat-panel .community-scroll .day-sep {
  margin: 10px 0 2px;
}

/* PC and large tablets: use the extra width instead of a narrow column. */
@media (min-width: 1025px) {
  [data-theme] .panel.chat-panel:not(.oc-split) > .panel-inner {
    max-width: min(1040px, 92vw);
  }
}

/* Tablet: keep the header compact so the room keeps its height. */
@media (max-width: 1024px) {
  [data-theme] .panel.chat-panel .community-head {
    margin-bottom: 10px;
  }

  [data-theme] .panel.chat-panel .community-head .lede {
    font-size: 12.5px;
  }
}

/* Phone: drop the decorative lede and tighten the paddings so messages get the
   screen. The composers keep a comfortable, keyboard-safe margin. */
@media (max-width: 640px) {
  [data-theme] .panel.chat-panel .community-head .lede {
    display: none;
  }

  [data-theme] .panel.chat-panel .community-head {
    margin-bottom: 8px;
    gap: 8px;
  }

  [data-theme] .panel.chat-panel > .panel-inner {
    padding: 16px 12px 8px;
  }

  [data-theme] .panel.chat-panel .community-scroll {
    padding: 2px 0 6px;
    margin-bottom: 6px;
  }

  [data-theme] .panel.chat-panel .community-list {
    padding-right: 2px;
  }
}

/* ==========================================================================
   BIM AI — DESIGN SYSTEM 2026
   CYBERPUNK · EDITORIAL-TECH · DEVELOPER-TERMINAL
   --------------------------------------------------------------------------
   This is the last layer in the cascade, so it re-skins every surface the
   layers above already positioned. It does three things and nothing else:

     1. Replaces the palette and the type scale. Because it redefines the
        tokens themselves, every older rule that reads a token inherits the new
        identity without being rewritten.
     2. Remaps the legacy neon / glass / glow tokens onto the new signals, so
        the decorated layers above stop fighting the new direction.
     3. Quiets the CRT, aurora and particle effects that this direction rules
        out. Sharp geometry, 1px rules and monospace labels do the work that
        glow used to do.

   Fonts are self-hosted (vendor/fonts/fonts.css) because the app's CSP is
   `font-src 'self' data:` and blocks remote font hosts.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1 · PALETTE
   Dark is the identity: black, charcoal and deep navy with a technical grid.
   Light is the editorial counterpart: warm paper, black type, same signals.
   -------------------------------------------------------------------------- */

:root {
  /* Light — editorial paper */
  --paper: #f2f3f1;
  --surface: #ffffff;
  --surface-2: #e7e9e5;
  --ink: #0b0e13;
  --ink-2: #2c333d;
  --muted: #5c6472;
  --muted-2: #838b98;
  --rule: #d5d9d4;
  --rule-strong: #b6bdb8;

  --accent: #0b6e85;
  --accent-hover: #095a6e;
  --accent-soft: #e2eff2;
  --accent-ink: #ffffff;

  --sidebar: #0b0e13;
  --sidebar-2: #14181f;
  --sidebar-ink: #e7ebf2;
  --sidebar-muted: #7d8593;
  --sidebar-rule: #232934;

  --ok: #1c7a52;
  --ok-soft: #e3f2ea;
  --warn: #8a5a06;
  --warn-soft: #f8eed9;
  --danger: #b52a1c;
  --danger-soft: #fae7e4;

  /* Sharp geometry: the radius scale stays tight on purpose. */
  --radius: 3px;
  --radius-lg: 4px;
  --shadow-sm: 0 1px 0 rgba(11, 14, 19, 0.05);
  --shadow-md: 0 10px 28px -18px rgba(11, 14, 19, 0.35);

  --font: 'Space Grotesk', 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-display: 'Chakra Petch', 'Space Grotesk', 'Segoe UI', Arial, sans-serif;
  --jp: 'Chakra Petch', 'Yu Gothic UI', 'Meiryo', 'Hiragino Sans', 'Noto Sans JP', 'Microsoft YaHei', sans-serif;

  --cut: 10px;
  --cut-sm: 6px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 320ms;

  /* Signal colours available in both themes. */
  --red: #d93a2b;
  --amber: #b4780c;
  --toxic: #1c7a52;
  --accent-2: #1c5fc4;

  /* Legacy token remap — the layers above read these names. */
  --neon: var(--accent);
  --neon-deep: var(--accent-hover);
  --neon-2: var(--accent-2);
  --neon-2-deep: var(--accent-2);
  --neon-2-soft: color-mix(in srgb, var(--accent-2) 10%, transparent);
  --magenta: var(--red);
  --violet: var(--accent-2);
  --violet-soft: color-mix(in srgb, var(--accent-2) 10%, transparent);
  --glass: var(--surface);
  --glass-2: var(--surface-2);
  --glow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
  --glow-strong: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
  --elev-1: 0 1px 0 rgba(11, 14, 19, 0.05);
  --elev-2: 0 6px 18px -14px rgba(11, 14, 19, 0.4);
  --elev-3: 0 14px 34px -22px rgba(11, 14, 19, 0.45);
  --ring: 0 0 0 2px color-mix(in srgb, var(--accent) 42%, transparent);
  --hud: var(--accent);
  --bg: var(--paper);
  --ctl-h: 34px;
}

[data-theme='dark'],
[data-theme='system'] {
  /* Dark — the primary identity. */
  --paper: #07090d;
  --surface: #0d1016;
  --surface-2: #141822;
  --ink: #e9edf4;
  --ink-2: #b3bcc9;
  --muted: #7c8695;
  --muted-2: #59626f;
  --rule: #1b2029;
  --rule-strong: #2b323e;

  --accent: #2fe0ff;
  --accent-hover: #6bebff;
  --accent-soft: #07212a;
  /* Cyan is far too bright for white type, so ink on an accent fill is near
     black. Every accent-filled control must use this, never #fff. */
  --accent-ink: #04161c;

  --sidebar: #05070a;
  --sidebar-2: #0c0f15;
  --sidebar-ink: #e9edf4;
  --sidebar-muted: #7c8695;
  --sidebar-rule: #191d26;

  --ok: #2fd39a;
  --ok-soft: #06231c;
  --warn: #ffb020;
  --warn-soft: #241a04;
  --danger: #ff4a38;
  --danger-soft: #2a100c;

  --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 12px 32px -20px rgba(0, 0, 0, 0.85);

  --red: #ff4a38;
  --amber: #ffb020;
  --toxic: #2fd39a;
  --accent-2: #4d8bff;
  --glow: 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent);
  --glow-strong: 0 0 0 2px color-mix(in srgb, var(--accent) 50%, transparent);
  --elev-1: 0 1px 0 rgba(0, 0, 0, 0.55);
  --elev-2: 0 8px 22px -16px rgba(0, 0, 0, 0.9);
  --elev-3: 0 18px 40px -24px rgba(0, 0, 0, 0.95);
}

/* The light theme keeps a dark rail and dark top bar, so "system" only needs
   the chat surface to stay light — already handled above. */
[data-theme='system'] {
  --paper: #f2f3f1;
  --surface: #ffffff;
  --surface-2: #e7e9e5;
  --ink: #0b0e13;
  --ink-2: #2c333d;
  --muted: #5c6472;
  --muted-2: #838b98;
  --rule: #d5d9d4;
  --rule-strong: #b6bdb8;
  --accent: #0b6e85;
  --accent-hover: #095a6e;
  --accent-soft: #e2eff2;
  --accent-ink: #ffffff;
  --red: #d93a2b;
  --accent-2: #1c5fc4;
  --danger: #b52a1c;
  --danger-soft: #fae7e4;
  --ok: #1c7a52;
  --ok-soft: #e3f2ea;
  --warn: #8a5a06;
  --warn-soft: #f8eed9;
}

/* --------------------------------------------------------------------------
   2 · BASE TYPE
   Chakra Petch carries the display voice, Space Grotesk the reading voice,
   JetBrains Mono every technical label, number and identifier.
   -------------------------------------------------------------------------- */

body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  letter-spacing: 0.002em;
  background: var(--paper);
  color: var(--ink);
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

h1 {
  letter-spacing: -0.02em;
}

/* Monospace is opt-in through `.--mono` helpers, but every place that already
   reads --mono now resolves to JetBrains Mono. */

code,
kbd,
samp,
pre {
  font-family: var(--mono);
  font-feature-settings: 'liga' 1, 'calt' 1;
}

::selection {
  background: color-mix(in srgb, var(--accent) 34%, transparent);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--rule-strong) 90%, transparent);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 55%, var(--rule-strong));
  background-clip: content-box;
}

/* --------------------------------------------------------------------------
   3 · TECHNICAL TEXTURE
   The grid is the one ambient graphic. It is masked to the top of the page and
   drawn in the accent at very low strength, so it reads as structure rather
   than decoration.
   -------------------------------------------------------------------------- */

.cyber-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.fx-grid {
  background-image: linear-gradient(color-mix(in srgb, var(--accent) 14%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 14%, transparent) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 90% 62% at 50% 0%, #000 6%, transparent 76%);
  -webkit-mask-image: radial-gradient(ellipse 90% 62% at 50% 0%, #000 6%, transparent 76%);
  opacity: 0.4;
  animation: none;
}

/* Ruled-out effects: no aurora, no CRT raster, no floating particles, no scan
   sweep. The direction asks for restraint, and these were the three loudest
   things in the old build. */
.fx-aurora,
.fx-crt,
.fx-particles,
.fx-scan {
  display: none !important;
}

/* A single diagonal rule field gives the pages their cut. */
.diag-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.diag-field i {
  position: absolute;
  display: block;
  background: color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Long thin diagonals, drawn as skewed 1px bars. */
.diag-field i.l {
  width: 1px;
  height: 160%;
  top: -30%;
  transform-origin: top center;
}

.diag-field i.l1 { left: 12%; transform: rotate(18deg); opacity: 0.5; }
.diag-field i.l2 { left: 34%; transform: rotate(18deg); opacity: 0.28; }
.diag-field i.l3 { left: 58%; transform: rotate(18deg); opacity: 0.18; }
.diag-field i.l4 { right: 16%; transform: rotate(18deg); opacity: 0.32; }
.diag-field i.l5 { right: 6%; transform: rotate(18deg); opacity: 0.5; }

/* Solid chips that carry the vermilion accent. */
.diag-field i.b {
  width: 2px;
  height: 42px;
  background: var(--red);
  opacity: 0.75;
}

.diag-field i.b1 { left: 22%; top: 12%; }
.diag-field i.b2 { left: 22%; top: 12%; transform: translateY(58px); opacity: 0.35; }
.diag-field i.b3 { right: 28%; bottom: 16%; }
.diag-field i.b4 { right: 28%; bottom: 16%; transform: translateY(-58px); opacity: 0.35; }

/* --------------------------------------------------------------------------
   4 · TECHNICAL LABEL
   One reusable micro-label: uppercase, monospaced, wide-tracked, with a lead
   tick. Used by every section head instead of a decorative divider.
   -------------------------------------------------------------------------- */

.sec-label,
.tech-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1;
}

.sec-label::before,
.tech-label::before {
  content: '';
  width: 14px;
  height: 1px;
  background: var(--accent);
  flex: none;
}

/* Corner ticks: two opposite corners drawn with pseudo-elements. Cheaper than
   four gradients and it never interferes with the element's own border. */
.ticks {
  position: relative;
}

.ticks::before,
.ticks::after {
  content: '';
  position: absolute;
  width: 9px;
  height: 9px;
  pointer-events: none;
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  border-style: solid;
  border-width: 0;
}

.ticks::before {
  top: -1px;
  left: -1px;
  border-top-width: 1px;
  border-left-width: 1px;
}

.ticks::after {
  right: -1px;
  bottom: -1px;
  border-bottom-width: 1px;
  border-right-width: 1px;
}

/* --------------------------------------------------------------------------
   5 · CONTROLS
   Flat fills, 1px rules, tight radii. The accent fill always pairs with
   --accent-ink so text never lands white-on-cyan.
   -------------------------------------------------------------------------- */

.btn {
  font-family: var(--font);
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: var(--radius);
  border-color: var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--ink);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}

.btn-quiet,
.btn-ghost {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink-2);
}

.btn-quiet:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.btn.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--rule));
  color: var(--danger);
  background: transparent;
}

.btn.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Form fields: mono-ish labels, hairline borders, accent focus. */
.field > span {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
.input {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-family: var(--font);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
  outline: none;
}

.field input::placeholder,
.field textarea::placeholder,
.input::placeholder {
  color: var(--muted-2);
}

/* Chips / tags read as machine labels. */
.chip,
.meta-tag {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius);
}

.chip {
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink-2);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: 2px;
}

/* Notices: a signal bar on the left, no rounded card. */
.notice {
  border-radius: var(--radius);
  border-width: 1px;
  border-left-width: 3px;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   6 · LANDING / AUTH
   An editorial spread: a dark hero column carrying the identity and the
   diagonal artwork, and a technical panel carrying the forms.
   -------------------------------------------------------------------------- */

.auth-page {
  position: relative;
  grid-template-columns: minmax(0, 1fr) minmax(0, 500px);
  background: var(--paper);
  isolation: isolate;
}

.auth-page .diag-field {
  z-index: 0;
}

.auth-intro {
  position: relative;
  z-index: 1;
  padding: 48px 56px 44px;
  gap: 30px;
  border-right: 1px solid var(--rule);
  background: transparent;
}

/* The soft cloud/orb/spark decoration is replaced by the rule field, so it is
   switched off rather than restyled. */
.decor-cloud,
.decor-orb,
.spark {
  display: none !important;
}

.decor-lines {
  opacity: 0.35;
}

/* Hero graphic: a sharp navy plate with the kanji set as artwork, plus a
   diagonal hatch. It is the page's one loud element and it claims nothing. */
.jp-poster {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 132px;
  padding: 20px 22px;
  background: #0a0d13;
  border: 1px solid var(--rule-strong);
  overflow: hidden;
}

.jp-poster-mark {
  font-family: var(--jp);
  font-size: clamp(38px, 6vw, 62px);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 0.06em;
  color: #eef3fa;
  position: relative;
  z-index: 1;
}

.jp-poster-mark::after {
  /* The vermilion mark from the reference artwork. */
  content: '';
  position: absolute;
  left: -14px;
  bottom: 4px;
  width: 4px;
  height: 42%;
  background: var(--red);
}

.jp-poster-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #7c8695;
  position: relative;
  z-index: 1;
}

.jp-poster .hatch {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    color-mix(in srgb, var(--accent) 46%, transparent) 0 1px,
    transparent 1px 11px
  );
  mask-image: linear-gradient(100deg, transparent 34%, #000 100%);
  -webkit-mask-image: linear-gradient(100deg, transparent 34%, #000 100%);
  opacity: 0.5;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.wordmark .logo {
  border-radius: 3px;
}

/* The headline is the identity statement: big, tight, editorial. */
.auth-intro h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.6vw, 46px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.025em;
  max-width: 18ch;
  margin: 0;
}

.auth-intro .lede {
  max-width: 60ch;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.68;
}

/* Model roster: numbered technical rows, not a bulleted list. */
.spec-list {
  gap: 0;
  padding: 0;
  border-top: 1px solid var(--rule);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spec-list li {
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
  align-items: baseline;
}

.spec-list li:nth-child(odd) {
  padding-right: 22px;
}

.spec-list .num {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--accent);
  padding-top: 0;
  flex: none;
}

/* Reasoning-tier table: a real data table with monospace heads. */
.tier-table {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.tier-table th,
.tier-table td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--rule);
}

.tier-table th {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--muted);
  border-bottom-color: var(--rule-strong);
}

.tier-table td:first-child {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  padding-right: 16px;
}

.tier-table td:nth-child(2) {
  color: var(--ink-2);
  white-space: nowrap;
}

.tier-table tbody tr:hover td {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.contact-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.contact-inline a {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.contact-inline a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.brand-credit {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.auth-jump {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  align-self: flex-start;
}

/* The form column is the technical panel. */
.auth-form-col {
  position: relative;
  z-index: 1;
  padding: 48px 44px;
  border-left: 1px solid var(--rule);
  background: var(--surface);
}

.auth-card {
  max-width: 396px;
  position: relative;
}

.pane h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.pane .sub {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}

.auth-form-col .field {
  margin-bottom: 14px;
}

.auth-form-col .field input {
  height: 42px;
  padding: 0 12px;
}

.text-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.foot-switch {
  font-size: 12.5px;
  color: var(--muted);
}

.rule-split {
  position: relative;
  text-align: center;
}

.rule-split::before,
.rule-split::after {
  background: var(--rule);
  height: 1px;
}

.meter-track {
  background: var(--surface-2);
  border-radius: 0;
  height: 3px;
}

.meter-track i {
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 0;
}

.meter-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.theme-toggle {
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle-auth {
  position: absolute;
  top: 22px;
  right: 24px;
  z-index: 3;
}

/* ==========================================================================
   BIM AI — IDENTITY PASS 2 · TERMINAL · 日本語 · MOTION
   --------------------------------------------------------------------------
   Pass 1 replaced the palette and the type scale. This pass adds the character:
   the terminal chrome, the Japanese marks, the motion vocabulary, and the
   per-surface treatment for chat, community, tables and the auth panes.

   Three rules hold the whole thing together:
     1. Every mark is either a real value the app already knows, or a pure
        pattern that claims nothing. No invented data, ever.
     2. Motion is short (120–420ms), one property per element, and completely
        switched off under prefers-reduced-motion.
     3. Nothing is drawn in a colour that fails contrast on its own surface.
   ========================================================================== */

/* --------------------------------------------------------------------------
   7 · MARKDOWN TABLES
   The renderer now emits real <table> elements, so they are styled as a
   readout: hairline rules, monospace headers, tabular figures, and a scroll
   wrapper so a wide table never breaks the bubble on a phone.
   -------------------------------------------------------------------------- */

.table-scroll {
  margin: 12px 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--rule);
  background: var(--surface);
  /* A thin accent rail marks it as a data block, not a paragraph. */
  border-left: 2px solid color-mix(in srgb, var(--accent) 55%, var(--rule));
}

.prose .table-scroll,
.ai-body .table-scroll {
  margin: 12px 0;
}

table.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: transparent;
}

table.md-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  border: 0;
  border-bottom: 1px solid var(--rule-strong);
  padding: 9px 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-2);
  text-align: left;
  white-space: nowrap;
}

table.md-table tbody td {
  border: 0;
  border-bottom: 1px solid var(--rule);
  padding: 9px 12px;
  color: var(--ink);
  vertical-align: top;
}

table.md-table tbody tr:last-child td {
  border-bottom: 0;
}

table.md-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

table.md-table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

table.md-table tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}

table.md-table td.ta-right,
table.md-table th.ta-right {
  text-align: right;
}

table.md-table td.ta-center,
table.md-table th.ta-center {
  text-align: center;
}

table.md-table code {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   8 · TERMINAL CHROME
   Reusable hardware-ish primitives. `chamfer` cuts one corner, `brk` wraps a
   label in the ASCII brackets a terminal prints, `rail` is the vertical
   monospace spine used on the sidebar and panels.
   -------------------------------------------------------------------------- */

.chamfer {
  clip-path: polygon(0 0, calc(100% - var(--cut-sm)) 0, 100% var(--cut-sm), 100% 100%, 0 100%);
}

/* A prompt marker: the "$" that starts a shell line, used on section heads. */
.prompt-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.prompt-line::before {
  content: '$';
  color: var(--accent);
  font-weight: 700;
}

.caret {
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.15em;
  background: var(--accent);
  animation: bxBlink 1.05s steps(1, end) infinite;
}

@keyframes bxBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* A real scanline sweep, applied only to elements that opt in. Two lines wide
   and very low contrast, so it reads as texture rather than noise. */
.scanlines {
  position: relative;
}

.scanlines::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    color-mix(in srgb, var(--accent) 7%, transparent) 0 1px,
    transparent 1px 4px
  );
  opacity: 0.5;
}

/* --------------------------------------------------------------------------
   9 · 日本語 ACCENTS
   The Japanese layer is structural, not decorative: a vertical spine on the
   rail, one watermark, and the vermilion seal. Text is set in the JP stack so
   the glyphs actually render.
   -------------------------------------------------------------------------- */

.kanji-mark {
  font-family: var(--jp);
  font-weight: 700;
  color: color-mix(in srgb, var(--accent) 30%, var(--muted));
  letter-spacing: 0.1em;
  user-select: none;
}

/* The watermark: large, low-contrast, behind everything, clipped to its box. */
.kanji-water {
  position: absolute;
  right: -0.1em;
  bottom: -0.24em;
  font-family: var(--jp);
  font-size: clamp(56px, 9vw, 104px);
  font-weight: 700;
  line-height: 0.8;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--accent) 13%, transparent);
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* The vermilion seal: a filled square with a CJK mark, as on a printed page. */
.seal {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  background: var(--red);
  color: #fff;
  font-family: var(--jp);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  border-radius: 2px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 45%, transparent);
}

/* Bracket label: 「 」 around a technical tag. */
.brk::before { content: '「'; opacity: 0.6; }
.brk::after { content: '」'; opacity: 0.6; }

/* The vertical spine text on the sidebar rail. */
.jp-rail {
  font-family: var(--jp);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent) 45%, var(--sidebar-muted));
  writing-mode: vertical-rl;
  text-orientation: upright;
  user-select: none;
}

/* --------------------------------------------------------------------------
   10 · MOTION
   One vocabulary, used everywhere. Everything is transform/opacity only, so
   the compositor does the work and nothing reflows.
   -------------------------------------------------------------------------- */

@keyframes bxRise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes bxFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes bxWipe {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes bxPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

@keyframes bxPing {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  100% { box-shadow: 0 0 0 7px transparent; }
}

@keyframes bxDrift {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 64px 64px, 64px 64px; }
}

@keyframes bxSweep {
  from { transform: translateX(-120%) skewX(-18deg); }
  to   { transform: translateX(320%) skewX(-18deg); }
}

/* The page assembles once, on load. */
.auth-page,
.shell {
  animation: bxFade 320ms var(--ease-out) both;
}

/* Panes and sections arrive from the left, the way a terminal prints. */
.pane.active,
.panel-inner > h1,
.welcome-core {
  animation: bxWipe 380ms var(--ease-out) both;
}

/* The conversation is rebuilt from scratch on every sync, so a blanket rise on
   .msg would replay on every poll and make the whole thread flicker. The class
   is therefore added by app.js once per genuinely new answer, next to the
   word-by-word reveal, and never survives a re-render. */
.msg.fresh {
  animation: bxRise 300ms var(--ease-out) both;
}

/* A backstop: the newest answer must never stay invisible if app.js's reveal
   never runs. app.js adds .revealed when it finishes, so this only fills the
   gap it leaves. */
.prose.typing {
  animation: bxFade 200ms var(--ease-out) both;
}

/* The live grid drifts, so the background is never fully static. */
.fx-grid {
  animation: bxDrift 32s linear infinite;
}

/* Accent sweeps: a single highlight crossing a surface on hover. Applied to
   primary buttons and the new-chat control only — restraint is the point. */
.btn-primary,
.new-btn {
  position: relative;
  overflow: hidden;
}

.btn-primary::after,
.new-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 34%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--accent-ink) 22%, transparent),
    transparent
  );
  transform: translateX(-120%) skewX(-18deg);
  pointer-events: none;
}

.btn-primary:hover:not(:disabled)::after,
.new-btn:hover:not(:disabled)::after {
  animation: bxSweep 620ms var(--ease-out);
}

/* Status dots pulse; a connected feed breathes, it does not blink. */
.hud-tag[data-state='online']::before,
.tool-toggle .dot {
  animation: bxPulse 2.4s ease-in-out infinite;
}

/* A copied code block pings once, confirming the copy without a toast. */
.code-copy.copied {
  animation: bxPing 520ms var(--ease-out);
}

/* The thinking orb keeps its own rotation; this only adds the halo. */
.ai-orb {
  animation: bxPulse 1.9s ease-in-out infinite;
}

/* Loading bars shimmer instead of sitting still. */
.qrow .track i,
.bar i {
  background-size: 200% 100%;
  animation: bxShimmer 2.2s linear infinite;
}

@keyframes bxShimmer {
  from { background-position: 0 0; }
  to   { background-position: -200% 0; }
}

/* Reduced motion switches the whole vocabulary off. app.js also checks this
   for the word-by-word reveal, so both layers agree. */
@media (prefers-reduced-motion: reduce) {
  .auth-page,
  .shell,
  .pane.active,
  .panel-inner > h1,
  .welcome-core,
  .msg.fresh,
  .fx-grid,
  .ai-orb,
  .hud-tag[data-state='online']::before,
  .tool-toggle .dot,
  .qrow .track i,
  .bar i,
  .caret,
  .btn-primary::after,
  .new-btn::after {
    animation: none !important;
  }

  .btn-primary::after,
  .new-btn::after {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   11 · CHAT SURFACE
   The conversation is the product, so it gets the calmest treatment: no
   texture behind the text, one accent rail on the assistant, tight vertical
   rhythm, and a composer that reads as a terminal input line.
   -------------------------------------------------------------------------- */

.thread {
  padding-bottom: 8px;
}

.msg {
  position: relative;
}

/* The assistant side carries the identity: an accent rail and a small mark. */
.msg.ai .ai-body {
  position: relative;
  padding-left: 14px;
}

.msg.ai .ai-body::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 2px;
  background: linear-gradient(
    to bottom,
    color-mix(in srgb, var(--accent) 80%, transparent),
    color-mix(in srgb, var(--accent-2) 30%, transparent)
  );
}

.ai-head .who {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* The user's own message: a filled plate with a cut corner, no bubble tail. */
.msg.user .bubble,
.msg.user .user-col {
  position: relative;
}

.msg.user .bubble {
  border-radius: var(--radius);
  border-right: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
}

/* Meta tags on an answer read as machine chips. */
.msg .meta-tag {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  border-color: color-mix(in srgb, var(--accent) 26%, var(--rule));
  color: var(--muted);
}

/* The action row only asserts itself on hover or focus, so a long thread stays
   quiet. The buttons remain reachable by keyboard. */
.msg-tools {
  opacity: 0.55;
  transition: opacity var(--dur-base) var(--ease);
}

.msg:hover .msg-tools,
.msg:focus-within .msg-tools {
  opacity: 1;
}

@media (pointer: coarse) {
  .msg-tools {
    opacity: 1;
  }
}

/* The thinking panel is a readout, not a card. */
.thinking {
  border-left: 2px solid color-mix(in srgb, var(--accent) 60%, var(--rule));
  border-radius: 0;
}

.thinking-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.thinking-sources a {
  font-family: var(--mono);
  font-size: 11px;
}

/* Code blocks: the developer surface. A title bar, a language tag, and a copy
   button, on a true black plate so code is unmistakably code. */
.code-box {
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  overflow: hidden;
  background: #05070a;
}

[data-theme='dark'] .code-box,
[data-theme='system'] .code-box {
  background: #05070a;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 11px;
  border-bottom: 1px solid #1c2230;
  background: #0b0f16;
}

.code-lang {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7f8b9c;
}

.code-lang::before {
  content: '▍';
  margin-right: 6px;
  color: var(--accent);
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b96a6;
  background: transparent;
  border: 1px solid #232b39;
  border-radius: 2px;
  padding: 3px 8px;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.code-copy:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.code-box pre {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 13px 14px;
  background: transparent;
}

.code-box pre code {
  color: #d3dae5;
  font-size: 12.5px;
  line-height: 1.65;
}

/* --------------------------------------------------------------------------
   12 · COMPOSER
   The writing area is a terminal prompt: a caret marker, a hairline box that
   lights up on focus, and tools that read as switches.
   -------------------------------------------------------------------------- */

.composer {
  border-radius: var(--radius);
  border-color: var(--rule-strong);
  background: var(--surface);
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.tool-toggle {
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.tool-toggle.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--accent);
}

.tool-toggle .dot {
  background: var(--muted-2);
}

.tool-toggle.on .dot {
  background: var(--accent);
}

.select-btn {
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   13 · COMMUNITY
   A room, not a dashboard: the day separators become ticked rules, messages
   get a left rail when they are the reader's own, and the pinned bar is a
   slim strip.
   -------------------------------------------------------------------------- */

.day-sep {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.day-sep::before,
.day-sep::after {
  background: var(--rule);
}

.dm {
  border-radius: var(--radius);
  border-color: var(--rule);
}

.dm.mine {
  border-left: 2px solid var(--accent);
}

.dm.from-owner {
  border-left: 2px solid var(--red);
}

.dm.highlight {
  animation: bxPing 900ms var(--ease-out) 2;
}

.dm-body {
  overflow-wrap: anywhere;
}

.pin-bar {
  font-family: var(--mono);
  font-size: 11px;
  border-radius: var(--radius);
  border-left: 2px solid var(--accent);
}

.load-more {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mention,
.mention.all {
  font-family: var(--mono);
  font-size: 0.94em;
  padding: 0 3px;
  border-radius: 2px;
}

/* --------------------------------------------------------------------------
   14 · AUTH PANES (register + reset)
   The two secondary panes inherit the login treatment; only the specifics are
   repeated here so all three read as one system.
   -------------------------------------------------------------------------- */

.pane h2 {
  position: relative;
  padding-left: 0;
}

.notice.error {
  border-left-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.notice.success {
  border-left-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok);
}

.notice.warn {
  border-left-color: var(--warn);
  background: var(--warn-soft);
  color: var(--warn);
}

.input-wrap .eye {
  border-radius: 2px;
  color: var(--muted);
}

.input-wrap .eye:hover {
  color: var(--accent);
}

.tier-table tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

/* The auth intro gets the watermark and the seal, both aria-hidden artwork. */
.auth-intro {
  position: relative;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   15 · LIGHT AND SYSTEM
   Light is not a dimmed dark theme: it is the editorial paper version of the
   same system. The rules below keep the identity intact while making sure
   every element still has real contrast on a light ground.
   -------------------------------------------------------------------------- */

[data-theme='light'] .code-box,
[data-theme='light'] .code-box pre {
  background: #0b0f16;
}

[data-theme='light'] .code-box pre code {
  color: #d3dae5;
}

[data-theme='light'] .table-scroll {
  background: var(--surface);
}

[data-theme='light'] .fx-grid {
  opacity: 0.5;
}

/* In light mode the accent rail and the plate must not wash out, so the
   assistant rail is drawn in the darker accent and the seals kept solid. */
[data-theme='light'] .msg.ai .ai-body::before {
  background: linear-gradient(
    to bottom,
    var(--accent),
    color-mix(in srgb, var(--accent-2) 55%, transparent)
  );
}

[data-theme='light'] .kanji-water {
  color: color-mix(in srgb, var(--accent) 10%, transparent);
}

[data-theme='light'] .dm.mine {
  border-left-color: var(--accent);
}

/* "system" keeps a light reading surface with the dark rail, so the chat
   treatments follow light while the sidebar keeps its own palette. */
[data-theme='system'] .msg.ai .ai-body::before {
  background: linear-gradient(
    to bottom,
    var(--accent),
    color-mix(in srgb, var(--accent-2) 55%, transparent)
  );
}

[data-theme='system'] .code-box,
[data-theme='system'] .code-box pre {
  background: #05070a;
}

/* --------------------------------------------------------------------------
   16 · RESPONSIVE
   Three breakpoints, each changing the layout rather than shrinking it.
   -------------------------------------------------------------------------- */

/* PC: a little more air, and the rail can hold the vertical spine. */
@media (min-width: 1440px) {
  .thread {
    max-width: min(1080px, 92%);
    margin: 0 auto;
  }

  .table-scroll {
    margin: 14px 0;
  }
}

/* Tablet: tighten the reading column and let tables use the width they have. */
@media (max-width: 1024px) {
  .msg.ai .ai-body {
    padding-left: 12px;
  }

  .kanji-water {
    font-size: clamp(44px, 8vw, 72px);
  }

  .code-box pre {
    padding: 12px;
  }
}

/* Phone: the chrome steps back so the conversation keeps the screen. */
@media (max-width: 640px) {
  .msg.ai .ai-body {
    padding-left: 10px;
  }

  .msg-tools {
    /* Touch devices keep the tools visible, but they do not need to be loud. */
    gap: 6px;
  }

  table.md-table {
    font-size: 12.5px;
  }

  table.md-table thead th,
  table.md-table tbody td {
    padding: 8px 10px;
  }

  .table-scroll {
    margin: 10px 0;
    border-left-width: 2px;
  }

  .jp-rail,
  .kanji-water {
    display: none;
  }

  .code-bar {
    padding: 6px 9px;
  }

  .auth-intro h1 {
    font-size: clamp(26px, 7.4vw, 34px);
  }
}

/* Short viewports (landscape phone): the pinned composers must still fit. */
@media (max-height: 480px) and (orientation: landscape) {
  .auth-intro {
    min-height: auto;
    padding-top: 28px;
    padding-bottom: 28px;
  }

  .jp-poster {
    min-height: 96px;
  }
}

/* --------------------------------------------------------------------------
   17 · THE SEAL AND THE GHOST GLYPH
   Two small pieces of finished detail: the vermilion seal sits beside the
   wordmark, and the welcome's oversized kanji breathes very slowly instead of
   sitting frozen.
   -------------------------------------------------------------------------- */

.wordmark .seal {
  margin-left: 9px;
  margin-top: -2px;
}

/* The ghost glyph already carries translate(-50%, -50%), so the animation has
   to keep that transform rather than replace it. */
[data-theme] .jp-ghost {
  animation: bxGhost 16s ease-in-out infinite alternate;
}

@keyframes bxGhost {
  from {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.035);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-theme] .jp-ghost {
    animation: none !important;
  }
}

/* A very small guard: any element that opts into the scanline texture must not
   put it on top of text. The rule keeps the overlay behind the content. */
.scanlines > * {
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   CODE PREVIEW
   Runs a message's code in an opaque-origin sandbox. The chrome stays in the
   app's own design language so it reads as part of the chat, while the frame
   itself is a black plate with no access to this document.
   ========================================================================== */

.code-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.code-preview {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #8b96a6;
  background: transparent;
  border: 1px solid #232b39;
  border-radius: 2px;
  padding: 3px 8px;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.code-preview:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.preview-overlay {
  z-index: 120;
  background: rgba(3, 5, 9, 0.82);
  padding: 16px;
}

.preview-card {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  height: min(88vh, 900px);
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  background: #05070a;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.preview-card.is-full {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  z-index: 130;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid #1c2230;
  background: #0b0f16;
  flex: 0 0 auto;
}

.preview-title {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #9aa6b6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.preview-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid #1c2230;
  background: #080b11;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

.preview-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6f7a8a;
}

.preview-size.is-on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

.preview-note {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: #6f7a8a;
}

.preview-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 12px;
  overflow: auto;
  background:
    linear-gradient(#0a0d13, #0a0d13) padding-box,
    repeating-linear-gradient(45deg, #0d1119 0 8px, #0b0f16 8px 16px) border-box;
}

.preview-frame {
  display: block;
  height: 100%;
  max-width: 100%;
  border: 1px solid #1c2230;
  border-radius: 4px;
  background: #ffffff;
  transition: width var(--dur-base) var(--ease);
}

.preview-log {
  flex: 0 0 auto;
  max-height: 32%;
  display: flex;
  flex-direction: column;
  border-top: 1px solid #1c2230;
  background: #070a0f;
}

.preview-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6f7a8a;
  border-bottom: 1px solid #141922;
}

.preview-log-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 12px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  color: #b9c2cf;
}

.preview-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.preview-line.is-error {
  color: #ff7b72;
}

@media (max-width: 720px) {
  .preview-overlay {
    padding: 8px;
  }

  .preview-card {
    height: calc(100svh - 16px);
  }

  .preview-note {
    display: none;
  }

  .preview-tools .btn {
    padding-inline: 8px;
  }
}












