:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f5f5f4;
  --text: #18181b;
  --muted: #71717a;
  --soft: #a1a1aa;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --primary: #164e63;
  --primary-hover: #0e7490;
  --danger: #b42318;
  --success: #16794c;
  --warning: #9a6700;
  --code-bg: #f8fafc;
  --shadow: 0 18px 48px rgba(24, 24, 27, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Aptos", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

button:hover,
.button:hover {
  border-color: var(--text);
}

button.primary,
.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

button.primary:hover,
.button.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

button.danger {
  border-color: #f2b8b5;
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

:focus-visible {
  outline: 3px solid rgba(14, 116, 144, 0.28);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 1000;
  transform: translateY(-160%);
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 72px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 250, 250, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
}

.main-nav a[aria-current="page"],
.main-nav a:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 180px;
  color: var(--muted);
  font-size: 14px;
}

.app-shell {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 32px;
  font-weight: 650;
}

h2 {
  font-size: 22px;
  font-weight: 650;
}

h3 {
  font-size: 17px;
  font-weight: 650;
}

.lede {
  max-width: 720px;
  margin: 10px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 20px 0;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.field.grow {
  flex: 1 1 280px;
}

label,
.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel-head,
.panel-body {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.stack {
  display: grid;
  gap: 16px;
}

.list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
}

.list-row:first-child {
  border-top: 0;
}

.list-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.badge.success {
  border-color: #b7e4cc;
  background: #effaf4;
  color: var(--success);
}

.badge.danger {
  border-color: #f2b8b5;
  background: #fff4f2;
  color: var(--danger);
}

.badge.warning {
  border-color: #f6d58d;
  background: #fff8e5;
  color: var(--warning);
}

.statement {
  color: var(--text);
  white-space: pre-wrap;
}

.editor-shell {
  min-height: 420px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--code-bg);
  overflow: hidden;
}

#code-editor {
  width: 100%;
  height: 420px;
}

#code-editor[contenteditable="true"] {
  padding: 14px;
  overflow: auto;
  white-space: pre;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.sample-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sample-grid pre {
  min-height: 64px;
  margin: 6px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code-bg);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.empty,
.error-box {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.error-box {
  border-color: #f2b8b5;
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(520px, calc(100% - 32px));
  transform: translate(-50%, 120px);
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast[data-open="true"] {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 8px;
    padding: 12px 18px;
  }

  .main-nav,
  .session-bar {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .app-shell {
    width: min(100% - 28px, 1280px);
    padding-top: 18px;
  }

  .page-head,
  .layout-two {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .sample-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
