/* Shared Field Guide polish: focused typography, theme switch, zoomable diagrams. */

html[data-theme="dark"] {
  color-scheme: dark;
}

:root {
  --fg-code-ink: #a64608;
  --fg-code-bg: #fff6ef;
  --fg-code-border: #efcfbd;
}

html[data-theme="dark"] {
  --fg-code-ink: #ffad72;
  --fg-code-bg: rgba(249, 116, 21, 0.12);
  --fg-code-border: rgba(249, 116, 21, 0.34);
}

.fp h1,
.fp .subtitle,
.page-title,
.chapter-num,
.chapter-title {
  font-weight: 500 !important;
}

.fp h1 em {
  font-weight: 500;
}

body code {
  color: var(--fg-code-ink) !important;
  background: var(--fg-code-bg) !important;
  border: 1px solid var(--fg-code-border) !important;
  border-radius: 4px !important;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.fg-theme-toggle {
  appearance: none;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  transition: color .15s, background .15s;
}

.fg-theme-toggle:hover {
  color: var(--ink);
  background: var(--line-2);
}

.fg-theme-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.fg-theme-toggle-mark {
  width: 13px;
  height: 13px;
  border: 1.2px solid currentColor;
  border-radius: 50%;
  background: linear-gradient(90deg, currentColor 0 50%, transparent 50% 100%);
}

[data-theme="dark"] .fg-theme-toggle-mark {
  background: linear-gradient(90deg, transparent 0 50%, currentColor 50% 100%);
}

.running-header .rh-left {
  grid-column: 1;
}

.running-header .rh-center {
  grid-column: 2;
}

.running-header .rh-right {
  grid-column: 3;
}

.running-header .rh-left > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.st-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid #0a0a0a;
  border-radius: 0;
  background: #0a0a0a;
  color: #ffffff;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1;
  text-transform: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}

.st-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.st-btn:focus-visible,
.st-close:focus-visible,
.st-field input:focus-visible,
.st-submit:focus-visible,
.st-close-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

.st-btn .arr,
.st-submit .arr {
  display: inline-block;
  font-family: var(--font-serif);
  font-size: 14px;
  font-style: italic;
  letter-spacing: 0;
  transition: transform .15s;
}

.st-btn:hover .arr,
.st-submit:hover .arr {
  transform: translateX(3px);
}

.st-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  background: rgba(10, 10, 10, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.st-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.st-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: clamp(36px, 5vw, 56px) clamp(28px, 4vw, 48px);
  border: 1px solid #0a0a0a;
  background: #ffffff;
  color: #0a0a0a;
  font-family: var(--font-sans);
  opacity: 0;
  transform: translateY(8px);
  transition: transform .25s cubic-bezier(0.25, 0.10, 0.25, 1.00), opacity .25s ease;
}

.st-modal.open .st-card {
  opacity: 1;
  transform: translateY(0);
}

.st-close {
  appearance: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #404040;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 22px;
  line-height: 1;
  transition: color .15s;
}

.st-close:hover {
  color: #0a0a0a;
}

.st-eyebrow {
  margin-bottom: 18px;
  color: #737373;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  line-height: 1.2;
  text-transform: uppercase;
}

.st-title {
  margin: 0 0 12px;
  color: #0a0a0a;
  font-family: var(--font-serif);
  font-size: clamp(40px, 5vw, 54px);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.03;
  text-wrap: balance;
  text-transform: none;
}

.st-title em {
  font-style: italic;
}

.st-sub {
  margin: 0 0 28px;
  color: #262626;
  font-family: var(--font-sans);
  font-size: 16px;
  letter-spacing: 0;
  line-height: 1.55;
  text-transform: none;
}

.st-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.st-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.st-field label {
  color: #404040;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  line-height: 1;
  text-transform: uppercase;
}

.st-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e8e8e8;
  border-radius: 0;
  background: #ffffff;
  color: #0a0a0a;
  font-family: var(--font-sans);
  font-size: 15px;
  font-style: normal;
  letter-spacing: 0;
  line-height: 1.55;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.st-field input::placeholder {
  color: #a3a3a3;
}

.st-field input:focus {
  border-color: #0a0a0a;
  box-shadow: inset 0 0 0 1px #0a0a0a;
}

.st-hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

.st-submit {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  padding: 13px 18px;
  border: 1px solid #0a0a0a;
  border-radius: 0;
  background: #0a0a0a;
  color: #ffffff;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  text-transform: none;
  transition: background .15s, border-color .15s, color .15s;
}

.st-submit:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.st-submit:disabled {
  cursor: default;
  opacity: 0.6;
}

.st-foot {
  margin: 12px 0 0;
  color: #737373;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1.5;
  text-align: center;
  text-transform: none;
}

.st-error {
  margin: 4px 0 0;
  color: #b3261e;
  font-family: var(--font-sans);
  font-size: 12.5px;
  letter-spacing: 0;
  line-height: 1.45;
  text-transform: none;
}

.st-done {
  padding: 8px 0;
  text-align: center;
}

.st-done-mark {
  margin-bottom: 20px;
  color: #a3a3a3;
  font-family: var(--font-serif);
  font-size: 22px;
  letter-spacing: 0.6em;
}

.st-done h3 {
  margin: 0 0 12px;
  color: #0a0a0a;
  font-family: var(--font-serif);
  font-size: 26px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.12;
  text-transform: none;
}

.st-done p {
  margin: 0 0 24px;
  color: #262626;
  font-family: var(--font-sans);
  font-size: 14px;
  letter-spacing: 0;
  line-height: 1.55;
  text-transform: none;
}

.st-done strong {
  font-family: var(--font-mono);
  font-weight: 400;
}

.st-close-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border: 1px solid #0a0a0a;
  border-radius: 0;
  background: transparent;
  color: #0a0a0a;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.st-close-btn:hover {
  background: #0a0a0a;
  color: #ffffff;
}

@media (max-width: 1080px) {
  .running-header .rh-left > span {
    display: none;
  }
}

@media (max-width: 860px) {
  .running-header .rh-center {
    display: none;
  }
}

.fg-wordmark {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  line-height: 0;
}

.fg-wordmark img {
  display: block;
  width: auto;
  height: 100%;
}

.fg-logo-dark {
  display: none !important;
}

[data-theme="dark"] .fg-logo-light {
  display: none !important;
}

[data-theme="dark"] .fg-logo-dark {
  display: block !important;
}

.fg-wordmark-header {
  width: 78px;
  height: 12px;
}

.fp .imprint .pub.fg-wordmark,
.fg-wordmark-imprint {
  width: 112px;
  height: 17px;
  margin: 0 auto 12px;
}

.fg-footer-brand {
  align-items: center;
}

.fg-wordmark-footer {
  width: 92px;
  height: 14px;
}

.field label,
.tool-form .field label,
.contact-frame .field label {
  font-family: var(--font-mono);
  letter-spacing: 0.20em;
  text-transform: uppercase;
}

.field input,
.field textarea,
.field select,
.tool-form .field input,
.tool-form .field textarea,
.tool-form .field select,
.contact-frame .field input,
.contact-frame .field textarea,
.contact-frame .field select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 15px;
  font-style: normal;
  letter-spacing: 0;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
  outline: none;
  box-shadow: inset 0 0 0 0 var(--ink);
  transition: border-color .15s, box-shadow .15s;
}

.field input::placeholder,
.field textarea::placeholder,
.tool-form .field input::placeholder,
.tool-form .field textarea::placeholder,
.contact-frame .field input::placeholder,
.contact-frame .field textarea::placeholder {
  font-style: normal;
  color: var(--mute-2);
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.tool-form .field input:focus,
.tool-form .field textarea:focus,
.tool-form .field select:focus,
.contact-frame .field input:focus,
.contact-frame .field textarea:focus,
.contact-frame .field select:focus {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.field-help,
.tool-form .field-help {
  font-family: var(--font-sans);
  font-style: normal;
  letter-spacing: 0;
}

.chip,
.tool-form .chip {
  font-family: var(--font-sans);
  font-weight: 400;
  background: var(--paper);
  border-radius: 3px;
}

.chip.on,
.tool-form .chip.on {
  background: var(--ink);
  color: var(--paper);
}

.stage-buttons {
  display: inline-flex;
  gap: 0;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;
}

.stage-buttons button {
  width: 36px;
  height: 32px;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

.stage-buttons button:first-child {
  border-left: 0;
}

.stage-buttons button.on {
  background: var(--ink);
  color: var(--paper);
}

.diagram-zoomable {
  position: relative;
  cursor: zoom-in;
  transition: box-shadow .15s ease;
}

.diagram-zoomable:hover {
  box-shadow: 0 0 0 1px var(--ink);
}

.zoom-hint {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  user-select: none;
}

.zoom-hint svg {
  width: 10px;
  height: 10px;
}

.diagram-zoomable:hover .zoom-hint {
  opacity: 1;
}

.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
  background: rgba(10, 10, 10, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.zoom-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.zoom-overlay .pane {
  position: relative;
  width: min(1280px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: clamp(32px, 4vw, 64px);
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: default;
}

.zoom-overlay .pane > .zoom-content > .clone {
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  aspect-ratio: auto !important;
}

.zoom-overlay .pane > .zoom-content > .clone svg {
  width: 100%;
  height: auto;
  max-height: 78vh;
}

.zoom-overlay .pane > .zoom-content > .clone .cap,
.zoom-overlay .pane > .zoom-content > .caption-after {
  margin-top: 24px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mute);
  text-align: left;
}

.zoom-overlay .pane > .zoom-content > .caption-after.serif {
  margin-top: 16px;
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
  letter-spacing: -0.005em;
  text-transform: none;
  color: var(--mute);
  text-align: center;
}

.zoom-overlay .pane > .zoom-content > .caption-after .ti {
  margin-right: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
}

.zoom-overlay .close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 20px;
  line-height: 1;
  transition: background .15s, color .15s, border-color .15s;
}

.zoom-overlay .close:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.zoom-overlay .esc-hint {
  position: absolute;
  top: -28px;
  right: 0;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 720px) {
  .running-header {
    gap: 12px;
  }

  .rh-left,
  .rh-right {
    gap: 12px;
  }

  .running-header .rh-left > span {
    display: none;
  }

  .st-btn {
    padding: 7px 11px;
    font-size: 11.5px;
  }

  .st-modal {
    align-items: center;
    padding: 18px;
  }

  .st-card {
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 36px 28px;
  }

  .st-title {
    font-size: clamp(34px, 11vw, 44px);
  }

  .st-sub {
    font-size: 15px;
  }

  .zoom-overlay {
    padding: 2vh 2vw;
  }

  .zoom-overlay .esc-hint {
    display: none;
  }
}
