@font-face {
  font-family: "Unbounded";
  src: url("/assets/fonts/unbounded-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

:root {
  --paper: #f1f3f0;
  --paper-bright: #fafbf8;
  --paper-deep: #e3e7e3;
  --ink: #171b22;
  --ink-soft: #596167;
  --rule: #aeb5b8;
  --rule-dark: #727b83;
  --cobalt: #174fc9;
  --cobalt-dark: #103a94;
  --cobalt-wash: #dbe5ff;
  --mint: #dcefe3;
  --mint-ink: #165d3c;
  --amber: #efb326;
  --rose: #f6dcd6;
  --vermilion: #c83927;
  --on-dark: #fff;
}

button, a, input, select, textarea {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(23, 79, 201, .18);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
html.auth-pending body { visibility: hidden; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 27, 34, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 27, 34, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 40px, 40px 100%;
  font-family: "Segoe UI Variable", Aptos, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: var(--on-dark);
  background: var(--ink);
  transform: translateY(-140%);
}
.skip-link:focus { transform: none; }

.profile-shell { min-height: 100vh; }
.utility-button,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--ink);
  padding: 0 14px;
  background: var(--paper-bright);
  color: var(--ink);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 760;
  text-decoration: none;
  text-transform: uppercase;
}
.utility-button:hover,
.utility-button:focus-visible { color: var(--on-dark); background: var(--ink); }
.primary-action { min-height: 46px; color: var(--on-dark); background: var(--cobalt); border-color: var(--cobalt); }
.primary-action:hover,
.primary-action:focus-visible { background: var(--cobalt-dark); }

.profile-status {
  min-height: 25px;
  border-bottom: 1px solid var(--rule-dark);
  padding: 5px 18px;
  color: var(--cobalt-dark);
  background: var(--cobalt-wash);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
}
.profile-status[data-tone="error"] { color: #791f17; background: var(--rose); }
.profile-status[data-tone="success"] { color: var(--mint-ink); background: var(--mint); }

.profile-workspace {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 34px 28px 64px;
}
.profile-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 28px;
  align-items: end;
  margin-bottom: 26px;
}
.eyebrow,
.section-number {
  margin: 0 0 7px;
  color: var(--cobalt-dark);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.profile-heading h1,
.profile-heading h2,
.section-heading h2,
.save-section h2,
.history-heading h2 {
  margin: 0;
  font-family: "Unbounded", "Segoe UI Variable", sans-serif;
  letter-spacing: -0.045em;
}
.profile-heading h1 { max-width: 850px; font-size: clamp(28px, 4vw, 54px); line-height: 0.98; }
.profile-heading h1, .section-heading h2, .save-section h2 { text-wrap: balance; }
.profile-heading > div > p:last-child { max-width: 780px; margin: 14px 0 0; color: var(--ink-soft); line-height: 1.55; }
.niche-switch { display: grid; gap: 7px; }
.niche-switch span,
.field > span {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}
.niche-switch select,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--rule-dark);
  border-radius: 0;
  padding: 11px 12px;
  color: var(--ink);
  background: var(--paper-bright);
}
.field textarea { resize: vertical; line-height: 1.48; }
.niche-switch select:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible,
.lane input:focus-visible {
  outline: 3px solid var(--cobalt-wash);
  border-color: var(--cobalt);
}

.profile-guard {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
  border: 1px solid var(--cobalt);
  padding: 18px;
  background: linear-gradient(90deg, var(--cobalt-wash), var(--paper-bright) 62%);
}
.guard-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--on-dark);
  background: var(--cobalt);
  font-size: 28px;
}
.profile-guard h2 { margin: 0 0 4px; font-size: 16px; }
.profile-guard p { max-width: 680px; margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.guard-facts { display: flex; gap: 22px; }
.guard-facts span { min-width: 94px; color: var(--ink-soft); font-size: 10px; line-height: 1.35; }
.guard-facts strong { display: block; color: var(--cobalt-dark); font-family: "Unbounded", sans-serif; font-size: 18px; }

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}
.profile-editor { display: grid; gap: 20px; min-width: 0; }
.editor-section {
  border: 1px solid var(--rule-dark);
  padding: 24px;
  background: rgba(250, 251, 248, 0.95);
}
.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.section-heading h2,
.save-section h2 { font-size: clamp(18px, 2vw, 27px); line-height: 1.05; }
.section-heading > span,
.section-heading > output {
  padding: 5px 8px;
  border: 1px solid var(--rule-dark);
  color: var(--cobalt-dark);
  background: var(--paper);
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  font-weight: 760;
}
.section-heading > output[data-invalid="true"] { color: #791f17; border-color: var(--vermilion); background: var(--rose); }
.section-intro { max-width: 720px; margin: -8px 0 20px; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.field + .field-wide,
.field-pair + .field-wide { margin-top: 16px; }
.field small { color: var(--ink-soft); font-size: 10px; font-weight: 400; text-transform: none; }
.field-danger textarea { border-top: 3px solid var(--vermilion); }

.lane-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.lane {
  display: grid;
  min-height: 146px;
  align-content: space-between;
  border: 1px solid var(--rule-dark);
  padding: 13px;
  background: var(--paper);
}
.lane > span { font-size: 11px; font-weight: 750; }
.lane strong { display: flex; align-items: baseline; gap: 4px; font-family: "Unbounded", sans-serif; font-size: 18px; }
.lane input { width: 70px; border: 0; border-bottom: 2px solid currentColor; padding: 2px 0; background: transparent; font-family: inherit; font-size: 28px; font-weight: 760; }
.lane small { color: var(--ink-soft); font-size: 9px; line-height: 1.4; }
.lane-core { color: var(--cobalt-dark); border-color: var(--cobalt); background: var(--cobalt-wash); }
.lane-wild { border-color: #b37b00; background: #fff1c9; }

.editor-details { padding: 0; }
.editor-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  cursor: pointer;
  list-style: none;
}
.editor-details summary::-webkit-details-marker { display: none; }
.editor-details summary span { font-family: "Unbounded", sans-serif; font-size: 15px; }
.editor-details summary b { margin-right: 12px; color: var(--cobalt-dark); font-family: "Cascadia Mono", monospace; font-size: 10px; }
.editor-details summary small { color: var(--ink-soft); font-size: 10px; }
.editor-details[open] summary { border-bottom: 1px solid var(--rule); }
.details-content { padding: 22px 24px 24px; }

.save-section { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(190px, 0.8fr) minmax(190px, 0.8fr); gap: 18px; align-items: end; border-color: var(--cobalt); }
.save-section > div:first-child p:last-child { max-width: 420px; margin: 8px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.save-actions { display: grid; grid-column: 1 / -1; grid-template-columns: 1fr auto; align-items: center; gap: 16px; border-top: 1px solid var(--rule); padding-top: 16px; }
.save-actions p { margin: 0; color: var(--ink-soft); font-size: 11px; }

.profile-history {
  position: sticky;
  top: 18px;
  border: 1px solid var(--rule-dark);
  background: var(--paper-bright);
}
.history-heading { padding: 20px; border-bottom: 1px solid var(--rule-dark); }
.history-heading h2 { font-size: 22px; }
.history-heading > p:last-child { margin: 8px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.45; }
.history-list { max-height: 500px; overflow: auto; }
.history-item { display: grid; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--rule); }
.history-item[data-active="true"] { box-shadow: inset 4px 0 0 var(--cobalt); background: var(--cobalt-wash); }
.history-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-meta strong { font-family: "Unbounded", sans-serif; font-size: 12px; }
.history-meta span { color: var(--ink-soft); font-family: "Cascadia Mono", monospace; font-size: 8px; }
.history-item p { margin: 0; font-size: 11px; line-height: 1.45; }
.history-item small { color: var(--ink-soft); font-size: 9px; }
.history-item button { justify-self: start; min-height: 32px; border: 1px solid var(--rule-dark); padding: 0 9px; background: var(--paper-bright); font-family: "Cascadia Mono", monospace; font-size: 9px; font-weight: 720; }
.history-item button:hover,
.history-item button:focus-visible { color: var(--on-dark); background: var(--ink); }
.coverage-panel { padding: 18px 20px; border-top: 1px solid var(--rule-dark); background: var(--paper-bright); }
.coverage-panel > span { color: var(--cobalt-dark); font-family: "Cascadia Mono", monospace; font-size: 9px; font-weight: 760; text-transform: uppercase; }
.coverage-panel h3 { margin: 7px 0 12px; font-size: 15px; }
.coverage-grid { border-top: 1px solid var(--rule); }
.coverage-row { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 8px 0; border-bottom: 1px dotted var(--rule-dark); }
.coverage-row strong { font-size: 10px; }
.coverage-row span { color: var(--cobalt-dark); font: 9px "Cascadia Mono", monospace; }
.coverage-row small { grid-column: 1 / -1; color: var(--ink-soft); font-size: 9px; }
.profile-diff { margin-top: 13px; }
.profile-diff summary { cursor: pointer; color: var(--cobalt-dark); font: 760 9px "Cascadia Mono", monospace; text-transform: uppercase; }
.profile-diff p { display: grid; gap: 3px; margin: 8px 0 0; padding-top: 8px; border-top: 1px dotted var(--rule); font-size: 9px; line-height: 1.4; }
.profile-diff p span { color: var(--ink-soft); overflow-wrap: anywhere; }
.memory-card { padding: 20px; border-top: 4px solid var(--ink); background: var(--paper); }
.memory-card > span { color: var(--cobalt-dark); font-family: "Cascadia Mono", monospace; font-size: 9px; font-weight: 760; text-transform: uppercase; }
.memory-card h3 { margin: 7px 0; font-size: 15px; }
.memory-card p { margin: 0; color: var(--ink-soft); font-size: 10px; line-height: 1.5; }

@media (max-width: 1050px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-history { position: static; display: grid; grid-template-columns: 220px 1fr 280px 240px; }
  .history-heading { border-right: 1px solid var(--rule-dark); border-bottom: 0; }
  .history-list { display: flex; max-height: none; overflow-x: auto; }
  .history-item { min-width: 230px; border-right: 1px solid var(--rule); border-bottom: 0; }
  .coverage-panel { border-top: 0; border-left: 1px solid var(--rule-dark); }
  .memory-card { border-top: 0; border-left: 4px solid var(--ink); }
}

@media (max-width: 760px) {
  body { background-size: 100% 32px, 32px 100%; }
  .profile-workspace { padding: 24px 14px 48px; }
  .profile-heading { grid-template-columns: 1fr; gap: 18px; }
  .profile-heading h1 { font-size: 32px; }
  .profile-guard { grid-template-columns: 44px 1fr; padding: 14px; }
  .guard-mark { width: 44px; height: 44px; }
  .guard-facts { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); padding-top: 12px; }
  .editor-section { padding: 18px; }
  .field-pair { grid-template-columns: 1fr; }
  .field-pair .field + .field { margin-top: 0; }
  .lane-grid { grid-template-columns: 1fr 1fr; }
  .lane { min-height: 126px; }
  .save-section { grid-template-columns: 1fr; }
  .save-actions { grid-column: auto; grid-template-columns: 1fr; }
  .primary-action { width: 100%; }
  .profile-history { display: block; }
  .history-heading { border-right: 0; border-bottom: 1px solid var(--rule-dark); }
  .history-list { display: block; }
  .history-item { min-width: 0; border-right: 0; border-bottom: 1px solid var(--rule); }
  .coverage-panel { border-top: 1px solid var(--rule-dark); border-left: 0; }
  .memory-card { border-top: 4px solid var(--ink); border-left: 0; }
}

@media (max-width: 430px) {
  .product-actions .utility-button:first-child { display: none; }
  .profile-status { padding-inline: 10px; }
  .profile-workspace { padding-inline: 10px; }
  .profile-heading h1 { font-size: 27px; }
  .profile-heading > div > p:last-child { font-size: 12px; }
  .profile-guard { grid-template-columns: 1fr; }
  .guard-mark { display: none; }
  .guard-facts { grid-column: auto; gap: 8px; }
  .guard-facts span { min-width: 0; }
  .editor-section { padding: 15px; }
  .section-heading { gap: 8px; }
  .section-heading h2,
  .save-section h2 { font-size: 18px; }
  .lane-grid { gap: 7px; }
  .lane { min-height: 120px; padding: 11px; }
  .lane input { width: 55px; font-size: 24px; }
  .editor-details summary { align-items: start; padding: 16px; }
  .editor-details summary small { max-width: 130px; text-align: right; }
  .details-content { padding: 16px; }
}

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