:root {
  --ink: #14201c;
  --muted: #5a6962;
  --forest: #12251f;
  --forest-soft: #1d3a31;
  --paper: #f5f3ec;
  --card: #fffefa;
  --line: #d7d9d0;
  --accent: #b9f66b;
  --accent-dark: #355c11;
  --blue: #c8e6ff;
  --danger: #a93434;
  --danger-bg: #fff0ee;
  --success: #1c6545;
  --warning: #8a5b0c;
  --shadow: 0 18px 48px rgba(18, 37, 31, 0.08);
  --radius: 18px;
  font-family: Inter, "Noto Sans Thai", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 84% 8%, rgba(185, 246, 107, 0.2), transparent 22rem),
    var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

button,
input,
textarea,
[tabindex] {
  outline-offset: 3px;
}

:focus-visible {
  outline: 3px solid #2d71c4;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  color: white;
  background: var(--forest);
  border-radius: 8px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0.85rem clamp(1rem, 4vw, 4rem);
  color: #f8fff7;
  background: var(--forest);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-block,
.card-heading,
.subheading-row,
.button-row {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 0.8rem;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--forest);
  background: var(--accent);
  border-radius: 50%;
  font-weight: 900;
}

.eyebrow,
.card-kicker,
.response-label {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-header .eyebrow {
  color: var(--accent);
}

h1 {
  margin: 0.08rem 0 0;
  font-size: 1.12rem;
  line-height: 1.1;
}

h1 span {
  color: #b9c7c1;
  font-weight: 500;
}

.environment-badge,
.mode-pill,
.connection-state,
.read-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.4rem 0.65rem;
  color: #dbe5e1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}

.environment-badge span {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.75fr);
  gap: 3rem;
  align-items: end;
  margin-bottom: 2.4rem;
}

.hero .eyebrow,
.card-kicker {
  color: var(--accent-dark);
}

.hero h2 {
  max-width: 780px;
  margin: 0.35rem 0 0;
  font-size: clamp(2.25rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero h2 span {
  color: var(--success);
}

.hero > p {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  font-size: 1rem;
  line-height: 1.7;
}

.tab-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.tab-button {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.8rem;
  min-height: 76px;
  padding: 0.9rem 1rem;
  color: var(--muted);
  text-align: left;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
}

.tab-button small {
  grid-column: 2;
  font-weight: 500;
}

.tab-index {
  grid-row: span 2;
  color: var(--success);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.tab-button[aria-selected="true"] {
  color: white;
  background: var(--forest);
  border-color: var(--forest);
  box-shadow: var(--shadow);
}

.tab-button[aria-selected="true"] small {
  color: #c4d1cc;
}

.tab-button[aria-selected="true"] .tab-index {
  color: var(--accent);
}

.tab-panel {
  animation: reveal 180ms ease-out;
}

.panel-grid {
  display: grid;
  gap: 1rem;
}

.public-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(20rem, 0.65fr);
  align-items: start;
}

.side-stack,
.operator-workspace {
  display: grid;
  gap: 1rem;
}

.card {
  padding: clamp(1rem, 2.5vw, 1.6rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 18px rgba(18, 37, 31, 0.035);
}

.card-feature {
  min-height: 490px;
  border-top: 5px solid var(--accent);
}

.card-heading {
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.card-heading.compact {
  align-items: flex-start;
}

.card h3 {
  margin: 0.16rem 0 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

.card h4 {
  margin: 0;
  font-size: 1rem;
}

.mode-pill,
.connection-state,
.read-badge {
  flex: 0 0 auto;
  color: var(--forest-soft);
  background: #eef6e4;
  border-color: #d4e7bd;
}

.fixture-pill {
  color: #294e71;
  background: #eaf5ff;
  border-color: #c8e2f7;
}

.card-intro,
.field-hint,
.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.card-intro {
  margin: 0 0 1.2rem;
}

form {
  display: grid;
  gap: 0.62rem;
}

label {
  margin-top: 0.35rem;
  font-size: 0.86rem;
  font-weight: 750;
}

input,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.72rem 0.82rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid #adb8b3;
  border-radius: 9px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(28, 101, 69, 0.12);
}

input:disabled,
textarea:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-footer,
.lookup-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.35rem;
}

.field-hint {
  margin: 0;
  font-size: 0.78rem;
}

.button {
  min-height: 44px;
  padding: 0.68rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 120ms ease, background-color 120ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button-primary {
  color: var(--forest);
  background: var(--accent);
  border-color: #9bdb4f;
}

.button-primary:hover {
  background: #c9ff86;
}

.button-secondary {
  color: #fff;
  background: var(--forest-soft);
  border-color: var(--forest-soft);
}

.button-quiet {
  color: var(--forest-soft);
  background: transparent;
  border-color: #aab6b1;
}

.button-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #e2aaa4;
}

.full-width {
  width: 100%;
  margin-top: 0.45rem;
}

.response-box {
  margin-top: 1.2rem;
  padding: 1rem;
  background: #eef6e4;
  border-left: 4px solid var(--success);
  border-radius: 8px;
}

.response-box p:last-child {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.response-label {
  color: var(--success);
}

.status-message {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.status-message[data-state="pending"] {
  color: #365f93;
}

.status-message[data-state="success"] {
  color: var(--success);
}

.status-message[data-state="error"] {
  color: var(--danger);
  font-weight: 700;
}

.status-list,
.lead-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-list li,
.lead-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e4e5df;
}

.status-list li:last-child,
.lead-list li:last-child {
  border-bottom: 0;
}

.status-label {
  font-weight: 800;
}

.status-value {
  color: var(--success);
  font-weight: 800;
}

.status-freshness,
.lead-summary {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.8rem;
}

.empty-state {
  margin: 0.8rem 0 0;
  font-size: 0.86rem;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.75rem;
  color: #6c4a0b;
  background: #fff5d9;
  border: 1px solid #ead292;
  border-radius: 8px;
  font-size: 0.84rem;
  line-height: 1.5;
}

.consent-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 0.65rem;
  align-items: start;
  margin: 0.55rem 0;
  font-weight: 600;
  line-height: 1.45;
}

.consent-row input {
  width: 20px;
  min-height: 20px;
  margin: 0.1rem 0 0;
}

.internal-layout {
  display: grid;
  grid-template-columns: minmax(17rem, 0.36fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.connection-card {
  position: sticky;
  top: 1rem;
}

.connection-state[data-connected="true"] {
  color: var(--success);
  background: #eaf7ef;
}

.button-row {
  gap: 0.65rem;
  margin-top: 0.45rem;
}

.button-row.wrap {
  flex-wrap: wrap;
}

.session-summary,
.inline-facts,
.detail-list {
  display: grid;
  gap: 0;
  margin: 1rem 0 0;
  border-top: 1px solid var(--line);
}

.session-summary div,
.inline-facts div,
.detail-list div {
  display: grid;
  grid-template-columns: minmax(6rem, 0.34fr) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.58rem 0;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 700;
}

.operator-workspace[aria-disabled="true"] {
  filter: saturate(0.72);
}

.verifier-row {
  width: fit-content;
}

.lookup-form {
  display: grid;
  grid-template-columns: 1fr auto;
}

.lookup-form > div {
  display: grid;
  gap: 0.5rem;
}

.work-details {
  margin-top: 1rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
}

.result-section {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 2px solid var(--forest);
}

.subheading-row {
  justify-content: space-between;
  gap: 1rem;
}

.result-section pre {
  max-height: 360px;
  overflow: auto;
  margin: 0.8rem 0 1rem;
  padding: 1rem;
  color: #e7f0ec;
  background: #17231f;
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.review-box {
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
  background: #f2f4ef;
  border-radius: 10px;
}

.lead-list li {
  grid-template-columns: minmax(0, 1fr) auto;
}

.lead-list strong,
.lead-list span {
  overflow-wrap: anywhere;
}

footer {
  padding: 1.3rem 1rem;
  color: #b9c7c1;
  text-align: center;
  background: var(--forest);
  font-size: 0.78rem;
}

footer p {
  margin: 0;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 880px) {
  .hero,
  .public-grid,
  .internal-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    gap: 1.25rem;
  }

  .connection-card {
    position: static;
  }
}

@media (max-width: 560px) {
  .site-header {
    align-items: flex-start;
  }

  .environment-badge {
    max-width: 9.5rem;
    line-height: 1.25;
  }

  .shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 2rem;
  }

  .tab-list {
    grid-template-columns: 1fr;
  }

  .form-footer,
  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .form-footer .button,
  .button-row .button {
    width: 100%;
  }

  .lookup-form {
    grid-template-columns: 1fr;
  }

  .card-heading:not(.compact) {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-summary div,
  .inline-facts div,
  .detail-list div {
    grid-template-columns: 1fr;
    gap: 0.18rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
