:root {
  color-scheme: light;
  --page: #e8eceb;
  --surface: #f7f9f8;
  --surface-strong: #ffffff;
  --context: #18211f;
  --context-soft: #26312e;
  --text: #17201e;
  --muted: #5c6865;
  --line: #cdd5d2;
  --accent: #167c68;
  --accent-hover: #116554;
  --accent-soft: #d9ede8;
  --danger: #a33a3a;
  --focus: #0e8069;
  --radius-panel: 18px;
  --radius-control: 10px;
  --shadow: 0 24px 70px rgba(30, 48, 43, 0.13);
  font-family: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; background: var(--page); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 16%, rgba(22, 124, 104, 0.08), transparent 28rem),
    var(--page);
}

button, input { font: inherit; }
button { cursor: pointer; }

.shell {
  width: min(1180px, calc(100% - 48px));
  min-height: calc(100dvh - 48px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: minmax(340px, 0.88fr) minmax(460px, 1.12fr);
  overflow: hidden;
  border: 1px solid rgba(65, 84, 78, 0.18);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.context-panel {
  display: flex;
  min-height: calc(100dvh - 48px);
  flex-direction: column;
  padding: 44px;
  color: #edf3f1;
  background:
    radial-gradient(circle at 15% 100%, rgba(58, 161, 137, 0.22), transparent 23rem),
    linear-gradient(145deg, var(--context-soft), var(--context));
}

.brand {
  display: inline-flex;
  align-items: center;
  width: max-content;
  gap: 12px;
  color: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(237, 243, 241, 0.45);
  border-radius: 9px;
  color: #f4faf8;
  font-size: 14px;
}

.context-copy { margin: auto 0; }

.eyebrow {
  margin: 0 0 18px;
  color: #9fd2c5;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.context-copy h1 {
  max-width: 520px;
  margin: 0;
  font-size: clamp(36px, 3.2vw, 46px);
  font-weight: 620;
  letter-spacing: -0.055em;
  line-height: 1.03;
}

.lead {
  max-width: 440px;
  margin: 24px 0 0;
  color: #bac8c4;
  font-size: 16px;
  line-height: 1.7;
}

.capability-list {
  display: grid;
  gap: 17px;
  padding-top: 28px;
  border-top: 1px solid rgba(237, 243, 241, 0.14);
}

.capability-list div {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  font-size: 13px;
  line-height: 1.5;
}

.capability-list strong { color: #eef4f2; font-weight: 620; }
.capability-list span { color: #a7b7b2; }

.work-panel {
  min-width: 0;
  padding: clamp(32px, 5vw, 70px);
  background: var(--surface);
}

.loading-view, .auth-view {
  width: min(100%, 430px);
  margin: auto;
}

.loading-view { padding-top: 12vh; }

.panel-header p, .dashboard-header p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.panel-header h2, .dashboard-header h2 {
  margin: 0;
  font-size: clamp(29px, 3vw, 40px);
  font-weight: 650;
  letter-spacing: -0.04em;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 38px 0 30px;
  padding: 4px;
  border-radius: var(--radius-control);
  background: var(--page);
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 650;
}

.tab.active {
  color: var(--text);
  background: var(--surface-strong);
  box-shadow: 0 2px 10px rgba(31, 52, 46, 0.08);
}

.form-stack { display: grid; gap: 20px; }

.field { display: grid; gap: 8px; }
.field > span { font-size: 14px; font-weight: 650; }
.field small { color: var(--muted); font-size: 12px; line-height: 1.5; }

.field input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  outline: 0;
  color: var(--text);
  background: var(--surface-strong);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(14, 128, 105, 0.16);
}

.primary-button, .secondary-button, .text-button {
  border-radius: var(--radius-control);
  font-weight: 700;
  transition: transform 120ms ease, background-color 160ms ease, border-color 160ms ease;
}

.primary-button {
  min-height: 50px;
  border: 1px solid var(--accent);
  color: #f8fbfa;
  background: var(--accent);
}

.primary-button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary-button:active, .secondary-button:active, .text-button:active { transform: translateY(1px); }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: 0.62; }
.primary-button.compact { min-height: 42px; padding: 0 18px; }

.secondary-button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface-strong);
}

.text-button {
  padding: 7px 2px;
  border: 0;
  color: var(--accent);
  background: transparent;
}

.form-error {
  min-height: 20px;
  margin: -6px 0 0;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.dashboard-view { width: 100%; }

.dashboard-header, .section-heading, .account-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.account-summary {
  align-items: center;
  margin-top: 38px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.account-summary h3, .binding-section h3, .messages-section h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.account-summary p, .section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.summary-values { display: flex; gap: clamp(28px, 5vw, 56px); }
.summary-values div { display: grid; gap: 6px; text-align: right; }
.summary-values span { color: var(--muted); font-size: 12px; }
.summary-values strong { font-size: 18px; font-variant-numeric: tabular-nums; }

.binding-section, .messages-section { padding-top: 34px; }
.binding-action { padding-top: 22px; }

.state-label {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 7px;
  color: var(--muted);
  background: var(--page);
  font-size: 12px;
  font-weight: 700;
}

.state-label.bound { color: #0e5f50; background: var(--accent-soft); }

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 22px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-strong);
}

.code-box > div { display: grid; gap: 6px; min-width: 0; }
.code-box span, .code-box small { color: var(--muted); font-size: 12px; }
.code-box code { overflow-wrap: anywhere; color: var(--text); font-size: 17px; font-weight: 700; }

.messages-section { margin-top: 12px; }
.messages-list { margin-top: 18px; }

.message-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.message-type { color: var(--accent); font-size: 12px; font-weight: 750; }
.message-main { min-width: 0; }
.message-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.message-main p { display: -webkit-box; overflow: hidden; margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.message-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.empty-state {
  margin-top: 20px;
  padding: 30px 0;
  color: var(--muted);
}

.empty-state strong { color: var(--text); }
.empty-state p { max-width: 360px; margin: 8px 0 0; font-size: 13px; line-height: 1.6; }

.skeleton {
  border-radius: 7px;
  background: linear-gradient(100deg, var(--page) 20%, var(--surface-strong) 45%, var(--page) 70%);
  background-size: 220% 100%;
}

.skeleton-title { width: 58%; height: 38px; }
.skeleton-line { width: 82%; height: 16px; margin-top: 18px; }
.skeleton-block { height: 210px; margin-top: 38px; }
.skeleton-row { height: 72px; margin-top: 1px; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 48px));
  padding: 13px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-control);
  color: #eef4f2;
  background: var(--context);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s ease-in-out infinite; }
  .auth-view, .dashboard-view { animation: enter 300ms ease-out both; }
}

@keyframes shimmer { to { background-position-x: -220%; } }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #111715;
    --surface: #18201e;
    --surface-strong: #202927;
    --text: #e8eeec;
    --muted: #a0aca8;
    --line: #35413e;
    --accent: #52b69e;
    --accent-hover: #63c7ae;
    --accent-soft: #1f493f;
    --danger: #f38f8f;
    --focus: #62c8ae;
    --shadow: 0 24px 70px rgba(3, 9, 7, 0.36);
  }
  .primary-button { color: #10201c; }
  .state-label.bound { color: #a9e4d5; }
}

@media (max-width: 820px) {
  .shell {
    width: 100%;
    min-height: 100dvh;
    margin: 0;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
  }
  .context-panel { min-height: auto; padding: 24px 20px 30px; }
  .context-copy { margin: 54px 0 30px; }
  .context-copy h1 { max-width: 570px; font-size: clamp(34px, 11vw, 48px); }
  .lead { margin-top: 18px; }
  .capability-list { display: none; }
  .work-panel { padding: 34px 20px 56px; }
  .loading-view { padding-top: 32px; }
}

@media (max-width: 540px) {
  .dashboard-header, .account-summary { align-items: flex-start; }
  .account-summary { display: grid; }
  .summary-values { width: 100%; justify-content: space-between; }
  .summary-values div { text-align: left; }
  .section-heading { gap: 14px; }
  .code-box { align-items: stretch; flex-direction: column; }
  .message-row { grid-template-columns: 64px minmax(0, 1fr); }
  .message-time { display: none; }
}
