:root {
  --ink: #10212d;
  --muted: #586a75;
  --surface: #ffffff;
  --page: #f5f8f6;
  --line: #d8e3df;
  --line-strong: #bfd0ca;
  --navy: #0c2a3c;
  --teal: #0d6b66;
  --teal-strong: #084f4d;
  --mint: #e9f7f1;
  --mint-strong: #2a9d77;
  --amber: #8a5d14;
  --amber-soft: #fff6df;
  --blue: #245e94;
  --blue-soft: #edf5fb;
  --paper: #fbfdfb;
  --shadow: 0 18px 44px rgba(17, 38, 47, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(180deg, #fbfdfb 0%, var(--page) 54%, #f8faf7 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(244px, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 10px 44px;
  background: linear-gradient(90deg, var(--navy), #08202e);
  color: #fff;
  box-shadow: 0 12px 24px rgba(7, 28, 42, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  font-size: 22px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  min-width: 44px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(184, 236, 213, 0.58);
  border-radius: 6px;
  color: #8fe1c1;
  font-size: 14px;
  letter-spacing: 0;
}

.main-nav {
  display: flex;
  justify-content: center;
  gap: 30px;
  font-weight: 750;
}

.main-nav a,
.header-action {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.main-nav a:hover {
  color: #a6e7cf;
}

.header-action {
  justify-self: end;
  padding: 0 18px;
  border: 1px solid #73c7ac;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font-weight: 800;
}

.header-action:hover {
  background: rgba(143, 225, 193, 0.14);
}

.page-shell {
  width: min(1420px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 18px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 350px);
  align-items: center;
  gap: 30px;
  margin-bottom: 18px;
}

.hero-copy h1 {
  margin: 0;
  color: #0a2334;
  font-size: clamp(40px, 4.8vw, 62px);
  line-height: 1.05;
}

.hero-copy p {
  max-width: 860px;
  margin: 10px 0 0;
  color: #435762;
  font-size: 20px;
  line-height: 1.35;
}

.hero-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 16px;
  border: 1px solid #e2c97e;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #4d380c;
}

.hero-note p {
  margin: 0;
  line-height: 1.4;
}

.note-mark {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: #f0d77f;
  color: #4f3909;
  font-size: 14px;
  font-weight: 900;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(560px, 1fr) minmax(450px, 0.96fr);
  gap: 16px;
}

.tool-panel,
.result-panel,
.content-card,
.source-guide-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.tool-panel,
.result-panel {
  padding: 18px;
}

.panel-kicker {
  margin-bottom: 12px;
  font-weight: 850;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
}

.source-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: #fff;
  color: #233742;
  font-weight: 800;
}

.source-tab:last-child {
  border-right: 0;
}

.source-tab span {
  display: inline-grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: var(--teal-strong);
  font-size: 12px;
}

.source-tab.is-active {
  background: var(--mint);
  color: var(--teal-strong);
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.reference-row {
  display: grid;
  grid-template-columns: 150px 94px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}

.reference-row label,
.field-group label,
.access-toggle {
  color: #162d3a;
  font-weight: 800;
}

.reference-row input {
  min-height: 40px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.reference-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
}

.field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

.field-group {
  min-width: 0;
}

.field-group.is-wide {
  grid-column: 1 / -1;
}

.optional {
  color: var(--muted);
  font-weight: 650;
}

.field-group input {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

.hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.28;
}

.form-footer {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(230px, 272px);
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

.access-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.access-toggle input {
  width: 22px;
  height: 22px;
  accent-color: var(--teal);
}

.ghost-button,
.generate-button,
.text-button {
  border-radius: 6px;
  font-weight: 850;
}

.ghost-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  background: transparent;
  color: var(--blue);
}

.ghost-button:hover {
  background: var(--blue-soft);
}

.generate-button {
  min-height: 46px;
  border: 0;
  background: linear-gradient(180deg, #128478, #075a58);
  color: #fff;
  box-shadow: 0 12px 22px rgba(10, 91, 84, 0.22);
}

.generate-button:hover {
  background: linear-gradient(180deg, #0b746b, #064c4b);
}

.result-heading,
.in-text-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.result-heading h2,
.in-text-heading h3,
.review-list h3,
.section-heading h2,
.source-guide-panel h2,
.detail-panel h2,
.detail-panel h3 {
  margin: 0;
  color: #0b2636;
}

.result-actions {
  display: flex;
  justify-content: end;
  gap: 12px;
  flex-wrap: wrap;
}

.text-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #91cdbb;
  background: #fff;
  color: var(--teal-strong);
}

.text-button:hover {
  background: var(--mint);
}

.citation-output,
.superscript-output {
  border-radius: 6px;
  font-size: 19px;
  line-height: 1.55;
}

.citation-output {
  min-height: 150px;
  margin-top: 12px;
  padding: 20px 18px;
  border: 1px solid #a8d7c8;
  background: linear-gradient(145deg, #fff, #f2fbf7);
}

.citation-output p {
  margin: 0;
}

.citation-output em {
  font-style: italic;
}

.divider {
  height: 1px;
  margin: 18px 0 14px;
  background: var(--line);
}

.superscript-output {
  min-height: 52px;
  margin-top: 8px;
  padding: 10px 16px;
  border: 1px solid #a9cbe5;
  background: var(--blue-soft);
}

.superscript-output sup {
  color: var(--teal-strong);
  font-size: 22px;
  font-weight: 900;
}

.review-zone {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 272px);
  gap: 18px;
  align-items: end;
  margin-top: 22px;
}

.review-list {
  display: grid;
  gap: 6px;
}

.review-list h3 {
  margin-bottom: 2px;
  font-size: 16px;
}

.review-list label {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: #263b46;
  line-height: 1.25;
}

.review-list input {
  margin-top: 3px;
  accent-color: var(--teal);
}

.important-note {
  padding: 16px;
  border: 1px solid #e5c56d;
  border-radius: 6px;
  background: var(--amber-soft);
  color: #4c370c;
}

.important-note p {
  margin: 8px 0 0;
  line-height: 1.36;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.86fr) minmax(340px, 1.1fr) minmax(320px, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.content-card,
.source-guide-panel,
.detail-panel {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading span {
  display: inline-grid;
  min-width: 42px;
  height: 28px;
  place-items: center;
  border-radius: 7px;
  background: var(--mint);
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 850;
}

.section-heading h2 {
  font-size: 18px;
}

.steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  min-height: 28px;
  padding-left: 36px;
  line-height: 1.35;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.guide-copy {
  margin: 18px 0 0;
  color: #40525c;
  line-height: 1.55;
}

.example-table {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.example-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  border-top: 1px solid var(--line);
}

.example-row:first-child {
  border-top: 0;
}

.example-row > span,
.example-row > p {
  margin: 0;
  padding: 9px 12px;
}

.example-row > span {
  color: #19313d;
  font-weight: 850;
}

.example-head {
  background: #f4f8f6;
}

.example-row p {
  color: #273b46;
  line-height: 1.35;
}

.faq-list {
  display: grid;
  gap: 8px;
}

.faq-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  text-align: left;
}

.faq-item[aria-expanded="true"] .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  display: none;
  margin-top: -8px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
  background: #fbfdfb;
  color: #40525c;
  line-height: 1.5;
}

.faq-answer.is-open {
  display: block;
}

.source-guide-panel,
.detail-panel {
  margin-top: 16px;
}

.source-guide-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.source-guide-grid article,
.detail-grid article {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
}

.source-guide-grid h3,
.detail-grid h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.source-guide-grid p,
.detail-grid p,
.detail-footnote {
  margin: 0;
  color: #40525c;
  line-height: 1.55;
}

.detail-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-footnote {
  margin-top: 14px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(320px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 7px;
  background: #10212d;
  color: #fff;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.field-group input:focus,
.reference-row input:focus,
.source-tab:focus-visible,
.text-button:focus-visible,
.generate-button:focus-visible,
.ghost-button:focus-visible,
.faq-item:focus-visible,
.header-action:focus-visible {
  outline: 3px solid rgba(36, 94, 148, 0.24);
  outline-offset: 2px;
}

@media (max-width: 1180px) {
  .workspace,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    order: 2;
  }

  .source-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .site-header {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 18px;
    position: static;
  }

  .main-nav {
    justify-content: start;
    flex-wrap: wrap;
    gap: 16px;
  }

  .header-action {
    justify-self: start;
  }

  .page-shell {
    width: min(100% - 28px, 720px);
    padding-top: 14px;
  }

  .hero,
  .review-zone,
  .detail-grid,
  .source-guide-grid {
    grid-template-columns: 1fr;
  }

  .field-list,
  .form-footer,
  .reference-row {
    grid-template-columns: 1fr;
  }

  .source-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .source-tab {
    border-bottom: 1px solid var(--line-strong);
  }

  .hero-copy h1 {
    font-size: 40px;
  }

  .hero-copy p {
    font-size: 18px;
  }
}

@media (max-width: 520px) {
  .brand {
    font-size: 20px;
  }

  .source-tabs {
    grid-template-columns: 1fr;
  }

  .source-tab {
    justify-content: flex-start;
    padding: 0 12px;
    border-right: 0;
  }

  .tool-panel,
  .result-panel,
  .content-card,
  .source-guide-panel,
  .detail-panel {
    padding: 16px;
  }

  .result-heading,
  .in-text-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-actions {
    justify-content: start;
  }

  .example-row {
    grid-template-columns: 1fr;
  }

  .example-row > span {
    padding-bottom: 0;
  }
}
