:root {
  color-scheme: light;
  --paper: #f2ecdf;
  --paper-raised: #faf6ed;
  --paper-deep: #e3dac8;
  --ink: #201d19;
  --ink-muted: #6e665d;
  --rule: #bdb19f;
  --oxblood: #501b24;
  --oxblood-bright: #742a37;
  --green: #1f4a3b;
  --warning: #8a571d;
  --danger: #8d2434;
  --shadow: 0 18px 50px rgb(44 31 18 / 10%);
  font-family: "Libre Franklin", "Franklin Gothic Medium", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgb(80 27 36 / 3%) 1px, transparent 1px) 0 0 / 100% 28px,
    var(--paper);
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }

.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;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: var(--paper-raised);
  background: var(--oxblood);
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.masthead {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 13px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--ink);
  background: rgb(242 236 223 / 94%);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  color: var(--paper-raised);
  background: var(--oxblood);
  border-radius: 3px;
  font-family: "Spline Sans Mono", monospace;
  font-size: 22px;
  font-weight: 600;
}
.brand strong {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.brand small,
.section-kicker,
.provider-stamp,
.count-stamp,
.status-badge,
.domain-entry-status,
.record-type {
  font-family: "Spline Sans Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.brand small { color: var(--ink-muted); font-size: 10px; }

.masthead-actions,
.toolbar-actions,
.section-heading-row,
.dialog-actions,
.dialog-heading {
  display: flex;
  align-items: center;
}
.masthead-actions { gap: 14px; }
.provider-stamp {
  padding: 5px 8px;
  color: var(--green);
  border: 1px solid currentColor;
  font-size: 9px;
  font-weight: 600;
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible,
.text-button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.domain-entry:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--oxblood), transparent 58%);
  outline-offset: 2px;
}
.button:disabled { cursor: wait; opacity: .58; }
.button-primary { color: var(--paper-raised); background: var(--oxblood); border-color: var(--oxblood); }
.button-primary:hover:not(:disabled) { background: var(--oxblood-bright); }
.button-secondary { background: transparent; }
.button-danger { color: white; background: var(--danger); border-color: var(--danger); }

.app-shell {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  min-height: calc(100vh - 79px);
}

.portfolio-panel {
  padding: 34px 24px 48px clamp(18px, 4vw, 56px);
  border-right: 1px solid var(--rule);
  background: rgb(250 246 237 / 45%);
}
.section-kicker {
  margin-bottom: 7px;
  color: var(--oxblood);
  font-size: 9px;
  font-weight: 600;
}
.danger-kicker { color: var(--danger); }
.section-heading-row { justify-content: space-between; gap: 12px; }
.section-heading-row h1,
.section-heading-row h3,
.domain-header h2,
.empty-state h2,
.dialog-heading h2 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -.045em;
}
.section-heading-row h1 { font-size: clamp(29px, 3vw, 42px); }
.section-heading-row h3 { font-size: 27px; }
.section-heading-row.compact { justify-content: flex-start; }
.count-stamp {
  min-width: 28px;
  padding: 4px 6px;
  border: 1px solid var(--rule);
  text-align: center;
  font-size: 10px;
}

.portfolio-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 24px 0 18px;
  border-block: 1px solid var(--rule);
}
.portfolio-stats div { padding: 12px 0; }
.portfolio-stats div + div { padding-left: 14px; border-left: 1px solid var(--rule); }
.portfolio-stats dt { color: var(--ink-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.portfolio-stats dd { margin: 3px 0 0; font-family: "Spline Sans Mono", monospace; font-size: 20px; font-weight: 600; }

.search-field { display: block; }
.search-field input,
dialog input,
dialog select,
dialog textarea {
  width: 100%;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 2px;
}
.search-field input { height: 42px; padding: 9px 12px; }
.domain-list { display: grid; gap: 7px; margin-top: 14px; }
.domain-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 8px;
  width: 100%;
  padding: 13px 12px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-bottom-color: var(--rule);
  cursor: pointer;
}
.domain-entry:hover { background: rgb(255 255 255 / 35%); }
.domain-entry.selected {
  background: var(--paper-raised);
  border-color: var(--ink);
  box-shadow: 4px 4px 0 var(--paper-deep);
}
.domain-entry-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; }
.domain-entry-status { align-self: center; font-size: 8px; }
.domain-entry-expiry { grid-column: 1 / -1; color: var(--ink-muted); font-size: 10px; }
.status-active { color: var(--green); }
.status-expired, .status-failed, .status-suspended, .status-deleted { color: var(--danger); }
.status-pending_setup, .status-pending_verification, .status-requested { color: var(--warning); }

.domain-workspace { min-width: 0; padding: clamp(32px, 5vw, 72px); }
.loading-panel,
.empty-state {
  display: grid;
  min-height: 55vh;
  place-content: center;
  text-align: center;
}
.loading-panel p,
.empty-state p { max-width: 460px; color: var(--ink-muted); }
.loading-rule {
  width: 96px;
  height: 2px;
  margin: auto;
  background: linear-gradient(90deg, var(--rule) 0 35%, var(--oxblood) 35% 65%, var(--rule) 65%);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .35; transform: scaleX(.75); } }
.empty-sigil { color: var(--oxblood); font-family: serif; font-size: 56px; }
.empty-state h2 { font-size: 34px; }

.domain-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.domain-header h2 { overflow-wrap: anywhere; font-size: clamp(34px, 5vw, 68px); line-height: .98; }
.domain-message { max-width: 720px; color: var(--warning); }
.status-badge { flex: 0 0 auto; padding: 6px 9px; border: 1px solid currentColor; font-size: 9px; }

.domain-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 42px 0 58px;
  border-block: 1px solid var(--ink);
}
.domain-facts > div { min-width: 0; padding: 15px 16px 18px 0; }
.domain-facts > div + div { padding-left: 16px; border-left: 1px solid var(--rule); }
.domain-facts dt { margin-bottom: 8px; color: var(--ink-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.domain-facts dd { margin: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.domain-facts code { display: block; font-family: "Spline Sans Mono", monospace; font-size: 10px; font-weight: 400; }

.dns-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.toolbar-actions { gap: 10px; }
.record-search { width: min(250px, 28vw); }
.table-frame { overflow-x: auto; border: 1px solid var(--ink); background: rgb(250 246 237 / 65%); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 12px; color: var(--ink-muted); text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: 9px; }
td { padding: 13px 12px; border-top: 1px solid var(--rule); vertical-align: top; }
th:nth-child(1) { width: 16%; }
th:nth-child(2) { width: 8%; }
th:nth-child(3) { width: 49%; }
th:nth-child(4) { width: 8%; }
th:last-child { width: 19%; }
.record-name,
.record-values code,
.mono,
.confirmation-code {
  font-family: "Spline Sans Mono", monospace;
  font-size: 11px;
}
.record-values code { display: block; max-width: 620px; overflow-wrap: anywhere; white-space: pre-wrap; }
.record-values small { color: var(--warning); }
.record-type { display: inline-block; padding: 3px 5px; border: 1px solid var(--rule); font-size: 8px; }
.row-actions { text-align: right; white-space: nowrap; }
.text-button { padding: 3px 5px; background: none; border: 0; cursor: pointer; font-size: 11px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.text-button:disabled { color: var(--ink-muted); cursor: default; text-decoration: none; }
.danger-text { color: var(--danger); }
.table-empty { padding: 28px; text-align: center; }
.empty-copy { color: var(--ink-muted); font-size: 12px; }
.safety-note { margin: 13px 0 0; color: var(--ink-muted); font-size: 11px; }

dialog {
  width: min(620px, calc(100vw - 28px));
  padding: 0;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid var(--ink);
  border-radius: 3px;
  box-shadow: 0 30px 80px rgb(20 14 8 / 28%);
}
dialog::backdrop { background: rgb(20 15 11 / 55%); backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 18px; padding: 26px; }
.dialog-heading { align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { font-size: 31px; }
.icon-button { width: 35px; height: 35px; font-size: 24px; line-height: 1; background: transparent; border: 1px solid var(--rule); cursor: pointer; }
.dialog-copy { margin: -7px 0 0; color: var(--ink-muted); font-size: 12px; }
.form-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: 1fr 1fr; }
dialog label { display: grid; gap: 7px; font-size: 12px; font-weight: 600; }
dialog label small { color: var(--ink-muted); font-weight: 400; }
dialog input, dialog select, dialog textarea { padding: 10px 11px; }
dialog textarea { resize: vertical; font-family: "Spline Sans Mono", monospace; font-size: 11px; }
dialog input:read-only, dialog select:disabled { color: var(--ink-muted); background: var(--paper-deep); }
.dialog-actions { justify-content: flex-end; gap: 9px; padding-top: 5px; border-top: 1px solid var(--rule); }
.confirmation-code { display: block; padding: 12px; color: var(--danger); background: var(--paper-deep); overflow-wrap: anywhere; user-select: all; }

.toast {
  position: fixed;
  z-index: 30;
  right: 22px;
  bottom: 22px;
  width: min(390px, calc(100vw - 44px));
  padding: 13px 15px;
  color: white;
  background: var(--danger);
  border: 1px solid rgb(255 255 255 / 45%);
  box-shadow: 0 12px 40px rgb(20 14 8 / 28%);
  font-size: 12px;
}
.toast[data-tone="success"] { background: var(--green); }

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px 18px;
  place-items: center;
}
.auth-card {
  width: min(520px, 100%);
  padding: clamp(28px, 6vw, 52px);
  text-align: center;
  background: var(--paper-raised);
  border: 1px solid var(--ink);
  border-top: 6px solid var(--oxblood);
  border-radius: 3px;
  box-shadow: var(--shadow);
}
.auth-brand {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 24px;
  color: var(--paper-raised);
  background: var(--oxblood);
  place-items: center;
  font-family: "Spline Sans Mono", monospace;
  font-size: 28px;
  font-weight: 600;
}
.auth-card h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 48px);
  line-height: 1;
  letter-spacing: -.05em;
}
.auth-card p {
  margin: 18px auto 24px;
  color: var(--ink-muted);
  line-height: 1.55;
}
.auth-card > small {
  display: block;
  max-width: 390px;
  margin: 24px auto 0;
  color: var(--ink-muted);
  font-size: 10px;
  line-height: 1.5;
}
.clerk-sign-in { display: grid; justify-content: center; }
.auth-user-button { display: grid; margin: 0 auto; place-items: center; }
.auth-card > .button { margin-top: 2px; }
#user-button { display: grid; min-width: 32px; place-items: center; }

[hidden] { display: none !important; }

@media (max-width: 930px) {
  .app-shell { grid-template-columns: 1fr; }
  .portfolio-panel { padding-right: clamp(18px, 4vw, 56px); border-right: 0; border-bottom: 1px solid var(--rule); }
  .domain-list { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .domain-facts { grid-template-columns: repeat(2, 1fr); }
  .domain-facts > div:nth-child(3) { border-left: 0; }
  .domain-facts > div:nth-child(n + 3) { border-top: 1px solid var(--rule); }
}

@media (max-width: 680px) {
  .masthead { position: static; padding: 12px 16px; }
  .provider-stamp { display: none; }
  .masthead-actions .button { padding: 8px 10px; font-size: 11px; }
  .brand small { display: none; }
  .domain-workspace { padding: 32px 16px 50px; }
  .domain-header, .dns-toolbar { align-items: flex-start; flex-direction: column; }
  .domain-facts { grid-template-columns: 1fr; margin-block: 30px 42px; }
  .domain-facts > div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--rule); }
  .toolbar-actions { width: 100%; }
  .record-search { flex: 1; width: auto; }
  .table-frame { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  table, tbody { display: block; }
  thead { display: none; }
  tr { display: grid; gap: 8px; margin-bottom: 12px; padding: 14px; border: 1px solid var(--ink); background: var(--paper-raised); }
  td { display: grid; grid-template-columns: 70px 1fr; padding: 0; border: 0; }
  td::before { content: attr(data-label); color: var(--ink-muted); font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
  .row-actions { display: flex; justify-content: flex-end; text-align: left; }
  .row-actions::before { display: none; }
  .two-columns { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0b1713;
    --paper-raised: #101f19;
    --paper-deep: #172b22;
    --ink: #edb967;
    --ink-muted: #9d9b72;
    --rule: #355544;
    --oxblood: #d58c32;
    --oxblood-bright: #e6a64f;
    --green: #74c98d;
    --warning: #edb967;
    --danger: #e8796f;
    --shadow: 0 18px 55px rgb(0 0 0 / 34%);
  }
  body { background: linear-gradient(rgb(116 201 141 / 4%) 1px, transparent 1px) 0 0 / 100% 28px, var(--paper); }
  .masthead { background: rgb(11 23 19 / 94%); }
  .brand-mark, .button-primary { color: #0b1713; }
  .domain-entry.selected { box-shadow: 4px 4px 0 #284336; }
  .button-danger, .toast { color: #0b1713; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
