:root {
  color-scheme: light;
  --text: #111111;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --background: #ffffff;
  --surface: #f6f7f8;
  --surface-strong: #eef2f7;
  --border: #e2e5ea;
  --accent: #3b5bff;
  --accent-hover: #2d47db;
  --accent-soft: #edf0ff;
  --success: #176b3a;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must always win, even against later component rules
   that set an explicit display value (e.g. .empty-state uses display: grid,
   which would otherwise override the UA `[hidden] { display: none }`). */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
  line-height: 1.6;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  /* Extra top padding clears the fixed site header (~3.25rem tall). */
  padding: 4.25rem 1.25rem 1.5rem;
}

/* ==========================================================================
   Fixed site header
   ========================================================================== */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--background);
  border-bottom: 1px solid var(--border);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 880px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
}

.site-wordmark {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-wordmark:hover {
  color: var(--accent);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav-link {
  font-size: 1rem;
  color: var(--accent);
  text-decoration: none;
}

.site-nav-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0.4rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
}

.nav-toggle-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .nav-toggle {
    display: flex;
  }

  .site-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(17, 17, 17, 0.06);
  }

  .site-nav:not(.site-nav--open) {
    display: none;
  }

  .site-nav-link {
    width: 100%;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
  }
}

.hero {
  max-width: 720px;
  padding: 0 0 1.5rem;
}

.eyebrow {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.1;
}

h1 {
  max-width: none;
  margin: 0;
  font-size: clamp(1.6rem, 3.2vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.6rem);
  font-weight: 700;
}

h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

/* Home hero tagline (#123): a smaller italic subline beneath the bold
   headline (#site-title). */
.tagline {
  max-width: 720px;
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.5;
}

/* Home vs Edit visibility (#121), driven by main[data-mode]. */
[data-mode="home"] .hero-edit {
  display: none;
}

[data-mode="edit"] .hero-home {
  display: none;
}

/* Edit-mode title: compact, in place of the big home byline. */
#edit-title {
  font-size: 1.4rem;
}

.tagline .link {
  margin-left: 0.25rem;
}

.actions,
/* ==========================================================================
   Link-style buttons (design tone: quiet, minimalist)
   ========================================================================== */

.link {
  display: inline-block;
  padding: 0.2rem 0;
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  cursor: pointer;
}

.link:hover {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
}

.link.muted {
  color: var(--muted);
}

.link.muted:hover {
  color: var(--text);
}

.link:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.sep {
  color: var(--muted-2);
  font-size: 0.9rem;
  user-select: none;
}

.editor-panel {
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(17, 17, 17, 0.04);
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

/* Editor action nav (#123): plain link buttons, no dividers or middot.
   Add section  Copy Markdown  Download   [Clear pushed right] */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
}

/* Clear is the one destructive action: pushed to the far right so it is not
   flush against Download (misclick guard), without needing a divider. */
.editor-toolbar .clear-action {
  margin-left: auto;
}

/* Fixed bottom status gutter (#122): always present on Home and Edit. Gray
   bar with black monospace text. Because it is permanent, changing the text
   never causes layout shift. */
.status-gutter {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  padding: 0.4rem 1.25rem;
  background: #e5e7eb;
  border-top: 1px solid rgba(0, 0, 0, 0.12);
}

.status-gutter .save-status {
  color: #000;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Keep page content clear of the fixed gutter. */
body {
  padding-bottom: 2.5rem;
}

.canonical-editor {
  max-width: none;
  margin: 0;
}

.field-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

label {
  margin-bottom: 0.5rem;
  font-weight: 800;
}

textarea {
  /* Auto-height: the textarea grows to fit its content and the PAGE scrolls,
     so Edit and Read share one coordinate space. JS sets the exact height on
     input (see autoGrowEditor). min-height keeps an empty editor usable. */
  min-height: 12rem;
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  color: var(--text);
  background: var(--background);
  font: 0.95rem/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  resize: none;
  overflow: hidden;
}

.help-text,
.save-status {
  color: var(--muted);
  font-size: 0.95rem;
}

.help-text {
  margin: 0 0 0.6rem;
}

.preview-card {
  max-width: 880px;
  min-width: 0;
  margin: 1rem auto 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: var(--background);
}

.preview-content {
  /* Grows with content; the page scrolls, matching the auto-height editor so
     the gutter can measure both views identically. */
  padding-right: 0.25rem;
}

.preview-content h1,
.preview-content h2,
.preview-content h3 {
  margin: 1rem 0 0.5rem;
}

.preview-content h1:first-child,
.preview-content h2:first-child,
.preview-content h3:first-child {
  margin-top: 0;
}

.preview-content ul {
  padding-left: 1.25rem;
}

.preview-content code {
  padding: 0.1rem 0.25rem;
  border-radius: 0.25rem;
  background: var(--surface-strong);
}

.save-status {
  color: var(--success);
}

.workflow-list {
  margin: 0.75rem 0;
  padding-left: 1.4rem;
  font-size: 0.95rem;
}

.workflow-list li {
  margin-bottom: 0.35rem;
}

/* -------------------------------------------------------------------------
   "Generate a profile" page (#75)
   Profile-type selector + full read-only prompt readout with top & bottom
   Copy buttons. Constrained to the same 880px content column as the editor.
   ------------------------------------------------------------------------- */

.prompt-page {
  width: min(880px, 100%);
  margin: 0 auto;
}

.type-selector {
  margin: 0 0 1.25rem;
}

.type-selector-label {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: var(--text);
}

.type-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.type-option {
  padding: 0.45rem 0.9rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.type-option:hover {
  border-color: var(--accent);
}

.type-option--active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 600;
}

.type-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.type-selector-hint {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Empty-state "Load a template" picker: a quiet label above a row of
   profile-type pills (reusing .type-options / .type-option). */
.template-loader {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.template-loader-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.prompt-readout {
  margin: 0.5rem 0 0;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface);
  overflow: hidden;
}

.prompt-readout-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: var(--background);
}

.prompt-readout-bar--top {
  border-bottom: 1px solid var(--border);
}

.prompt-readout-bar--bottom {
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.prompt-readout-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Full readout — no scroll box. The entire prompt is visible; the page scrolls,
   not the block. Monospace so it reads as a copyable artifact. */
.prompt-readout-body {
  margin: 0;
  padding: 1rem 1.1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.prompt-readout-body:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.prompt-status {
  margin: 0.75rem 0 0;
  min-height: 1.2em;
}

.prompt-privacy {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.prompt-usage-tips {
  margin: 1.25rem 0 1.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border, #d0d7de);
  border-radius: 6px;
  background: var(--surface-muted, #f6f8fa);
}

.prompt-usage-tips > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  list-style: revert;
}

.prompt-usage-tips > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.prompt-usage-tips-body {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.prompt-usage-tips-body p {
  margin: 0.5rem 0;
}

.prompt-usage-tips-body p:first-child {
  margin-top: 0;
}

.prompt-usage-tips-body p:last-child {
  margin-bottom: 0;
}

.prompt-usage-tips-body strong {
  color: var(--text);
}

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

footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  color: var(--text);
  font-size: 1rem;
  text-align: left;
}

.site-footer {
  padding-top: 1.5rem;
}

/* ==========================================================================
   Learn page
   ========================================================================== */

.learn-body {
  max-width: 68ch;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
}

.learn-body h2 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.15rem;
}

.learn-body p {
  margin: 0.5rem 0;
}

.learn-body ul,
.learn-body ol {
  margin: 0.5rem 0;
  padding-left: 1.4rem;
}

.learn-body li {
  margin-bottom: 0.25rem;
}

.site-footer .footer-meta {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-size: 1rem;
}

.site-footer .footer-note {
  margin: 0 0 0.35rem;
  color: var(--text);
  font-size: 1rem;
}

.site-footer .footer-meta a,
.site-footer .footer-contact a {
  color: var(--accent);
}

.site-footer .footer-contact {
  margin: 0;
  font-size: 1rem;
}

.site-footer .footer-contact a {
  color: var(--accent);
}

@media (max-width: 820px) {
  .page {
    padding-top: 3.75rem;
  }

  .hero {
    padding-bottom: 1.25rem;
  }

  h1 {
    max-width: none;
    font-size: 1.6rem;
  }

  .tagline {
    font-size: 0.95rem;
  }

  .editor-heading {
    display: block;
  }

  .editor-toolbar {
    justify-content: flex-start;
    margin-top: 1rem;
  }

  textarea {
    min-height: 12rem;
  }
}

/* ==========================================================================
   Editor surface: Edit / Read mode toggle
   ========================================================================== */

.mode-toggle {
  display: inline-flex;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--background);
  padding: 0.15rem;
}

.mode-button {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.45rem;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.mode-button:hover {
  color: var(--text);
}

.mode-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mode-button[aria-selected="true"] {
  color: var(--background);
  background: var(--text);
}

.mode-button[aria-selected="true"]:hover {
  color: var(--background);
}

.mode-panel[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------------
   Teleport gutter (#83)
   A quiet left-margin affordance: hovering a block lights a narrow vertical
   bar in the margin; clicking it switches Edit<->Read and lands on the same
   block. Block-level granularity. Positioned relative to the mode-panel so
   the bar can sit just left of the 880px content column. -------------------- */
.mode-panel {
  position: relative;
}

.editor-gutter {
  position: absolute;
  top: 0;
  left: -1.25rem;
  width: 1rem;
  height: 100%;
  /* Above the panel content so bars are hoverable/clickable, but the column
     itself is transparent and does not block text selection to its right. */
  pointer-events: none;
  z-index: 2;
}

/* One focusable bar per block, absolutely positioned by app.js (top/height in
   px). Invisible until hovered/focused so the margin stays quiet. */
.gutter-bar {
  position: absolute;
  left: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  transition: background-color 0.12s ease;
}

.gutter-bar:hover,
.gutter-bar:focus-visible,
.gutter-bar.is-active {
  background: var(--accent);
}

.gutter-bar:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* On coarse-pointer / narrow screens the left margin isn't available; hide the
   gutter and fall back to the header Edit|Read toggle only. */
@media (max-width: 960px) {
  .editor-gutter {
    display: none;
  }
}

/* Read-mode type ramp
   Deliberately tight in PR A: the goal is a document that reads at a glance,
   not a splash page. Body sits at 0.95rem so headings only nudge up slightly. */
.preview-content {
  font-size: 0.95rem;
  line-height: 1.5;
}

.preview-content h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0;
  max-width: none;
  margin: 1.25rem 0 0.5rem;
}

.preview-content h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 1rem 0 0.4rem;
}

.preview-content h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.85rem 0 0.35rem;
}

.preview-content p {
  margin: 0.5rem 0;
}

.preview-content ul,
.preview-content ol {
  margin: 0.4rem 0;
}

/* ==========================================================================
   Empty state
   ========================================================================== */

.empty-state {
  display: grid;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border: 1px dashed var(--border);
  border-radius: 0.85rem;
  background: var(--background);
}

.empty-state-primary {
  text-align: left;
}

.empty-state-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.empty-state-hint {
  margin: 0.25rem 0 0.6rem;
  color: var(--text);
  font-size: 1rem;
}

.empty-state-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 1.25rem;
}

.empty-state-secondary {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--surface);
}

.empty-state-secondary-title {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.empty-state-secondary-hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.empty-state-secondary-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

/* ==========================================================================
   Restore-or-clear banner
   ========================================================================== */

.restore-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid #c9d4ff;
  border-radius: 0.6rem;
  background: var(--accent-soft);
  color: #18223f;
  font-size: 0.9rem;
}

.restore-banner-text {
  margin: 0;
  font-weight: 600;
}

.restore-banner-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.metadata-card {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: var(--surface, #f7f8fb);
}

.metadata-card[hidden] {
  display: none;
}

.metadata-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.metadata-card dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.85rem;
  margin: 0;
  font-size: 0.95rem;
}

.metadata-card dt {
  font-weight: 700;
  color: var(--muted);
}

.metadata-card dd.metadata-value {
  margin: 0;
  color: var(--muted);
  word-break: break-word;
}
