.ad-reference { margin-top: var(--space-3); color: var(--ink-soft); font-size: .85rem; }
.ad-reference summary { width: fit-content; cursor: pointer; padding: .3rem 0; }
.ad-reference summary:hover { color: var(--ink); }
.ad-reference summary:focus-visible, #ad-format:focus-visible, .reference-footnote a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 3px; }
.reference-body { padding-top: var(--space-3); }
#ad-format { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-button); padding: .45rem 2rem .45rem .65rem; max-width: 100%; }
.reference-limits { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; margin: 1rem 0 .75rem; }
.reference-limits div { display: flex; align-items: baseline; gap: .5rem; }
.reference-limits dt, .reference-limits dd { margin: 0; }
.reference-limits dd { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.reference-tip { font-size: .8rem; line-height: 1.5; margin: .5rem 0; }
.reference-footnote { font-size: .72rem; line-height: 1.5; margin: .35rem 0 0; }
.reference-footnote a { text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.reference-language-note { opacity: .9; }
.reference-scope { font-size: .72rem; margin: .85rem 0 .5rem; line-height: 1.5; }
.reference-limits { margin-top: 0; }
.reference-tip strong { color: var(--ink); font-weight: 600; }
.reference-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem 1rem; }
.examples-toggle { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; padding: .3rem 0; }
.examples-toggle input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }
.examples-toggle input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.reference-examples { margin-top: 1rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.example-list { margin: 0; display: grid; gap: .85rem; }
.example-list dt { font-size: .72rem; margin: 0 0 .25rem; }
.example-list dd { margin: 0; color: var(--ink); line-height: 1.5; font-size: .85rem; overflow-wrap: anywhere; }

.header-copy .header-copyright { font-size: .7rem; line-height: 1.4; margin: .15rem 0 .25rem; color: var(--ink-soft); }

.reference-qualifier { font-size: .72rem; font-weight: 400; color: var(--ink-soft); }

/* A restrained warm yellow accent, with readable text in both themes. */
:root {
  --accent: #f4cc55;
  --accent-soft: rgba(244, 204, 85, .10);
  --accent-strong: rgba(244, 204, 85, .22);
  --line-strong: rgba(244, 204, 85, .32);
  --accent-ink: #f4cc55;
}
:root[data-theme=light] {
  --accent: #d9a91d;
  --accent-soft: rgba(244, 204, 85, .16);
  --accent-strong: rgba(217, 169, 29, .24);
  --line-strong: rgba(153, 112, 13, .35);
  --accent-ink: #80600e;
}
body { background: radial-gradient(circle at top left, rgba(244, 204, 85, .035), transparent 22rem), linear-gradient(180deg, var(--background-soft) 0%, var(--background) 100%); }
::selection { background: rgba(244, 204, 85, .3); }
#paste-button { background: #f4cc55; border-color: #f4cc55; color: #25200f; }
#paste-button:hover, #paste-button:focus-visible { background: #ffda6a; border-color: #ffda6a; }
.theme-toggle:hover, .theme-toggle:focus-visible, .utility-button:hover, .utility-button:focus-visible { box-shadow: 0 6px 18px rgba(244, 204, 85, .08); }
.utility-button:focus-visible, .theme-toggle:focus-visible, textarea:focus-visible { outline-color: var(--accent-strong); }
.editor-frame { background: var(--surface); }
.metric-card-emphasis .metric-value, .ad-reference summary::marker { color: var(--accent-ink); }

.header-copy h1 { font-size: clamp(2rem, 3vw, 2.6rem); line-height: 1.1; }
.header-copy h1 .brand-accent { color: var(--accent-ink); }

/* Full-width brand band keeps the title distinct from the workspace. */
.page-shell { padding-top: 0; }
.app-header {
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  padding: .85rem max(1.05rem, calc((100vw - 1166px) / 2));
  background: #f4cc55;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  --ink: #25200f;
  --ink-soft: #51441e;
  --accent: #25200f;
  --accent-soft: rgba(37, 32, 15, .06);
  --accent-strong: rgba(37, 32, 15, .35);
  --line-strong: rgba(37, 32, 15, .32);
}
.header-copy h1 .brand-accent { color: inherit; }
.app-header .theme-toggle:hover, .app-header .theme-toggle:focus-visible { box-shadow: none; background: rgba(37, 32, 15, .1); }

.ad-reference { margin-top: 1rem; }
.ad-reference summary {
  width: 100%;
  padding: .8rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-button);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.4;
}
.ad-reference summary:hover { color: var(--accent-ink); background: var(--accent-strong); }

.writing-column { display: grid; gap: var(--space-4); min-width: 0; }
.reference-panel {
  margin-top: 0;
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
}
.reference-panel h2 { margin: 0; color: var(--accent-ink); font-size: 1.1rem; font-weight: 650; line-height: 1.3; }
.reference-panel .reference-body { padding-top: 1rem; }

/* Keep the three editor actions together at every viewport width. */
.editor-panel .action-row { flex-wrap: nowrap; }
.editor-panel .action-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: auto;
  gap: .5rem;
}
.editor-panel .utility-button {
  min-width: 0;
  min-height: 36px;
  padding: .4rem .85rem;
  line-height: 1.25;
}
@media (max-width: 720px) {
  .editor-panel .action-group { width: 100%; margin-left: 0; }
  .editor-panel .utility-button { min-height: 44px; padding: .6rem .4rem; }
}

.site-footer { margin-top: 1.25rem; padding: .25rem 0; color: var(--ink-soft); font-size: .72rem; line-height: 1.5; text-align: center; }

/* Give the reference tool its own full-width band below the workspace. */
.reference-band {
  width: 100vw;
  margin: 1.5rem calc(50% - 50vw) 0;
  padding: 1.5rem max(1rem, calc((100vw - 1200px) / 2));
  display: grid;
  grid-template-columns: minmax(14rem, .8fr) minmax(0, 2fr);
  gap: 2rem;
  align-items: start;
  background: color-mix(in srgb, var(--surface) 94%, var(--accent));
  border: 0;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  box-shadow: none;
}
.reference-band h2 { font-size: 1.25rem; line-height: 1.35; }
.reference-band .reference-body { padding-top: 0; min-width: 0; }
.reference-band .reference-limits { margin-bottom: 0; }
@media (max-width: 720px) {
  .reference-band { grid-template-columns: minmax(0, 1fr); gap: 1rem; padding-block: 1.25rem; }
}

.reference-band { font-size: 1rem; }
.reference-band h2 { font-size: 1.4rem; }
.reference-band .reference-scope { font-size: .9rem; }
.reference-band .reference-limits { font-size: 1.05rem; gap: .85rem 1.75rem; }
.reference-band .reference-limits dd { font-size: 1.1rem; }
.reference-band .reference-tip, .reference-band .example-list dd { font-size: 1rem; }
.reference-band .reference-footnote, .reference-band .reference-qualifier, .reference-band .example-list dt { font-size: .875rem; }

/* Keep the everyday workspace and reference controls within the first screen. */
.editor-frame, textarea { min-height: 280px; }
.metrics-panel .panel-header { min-height: 0; margin-bottom: .65rem; }
.metric-grid-primary { gap: .5rem; }
.metric-card { padding: .65rem .75rem; }
.metric-value { font-size: 1.8rem; line-height: 1.15; margin-top: .25rem; }
.metric-grid-secondary { gap: .5rem; }
.detail-card { padding: .55rem .65rem; }
.detail-value { font-size: 1.2rem; line-height: 1.2; margin-top: .25rem; }
.reference-band { margin-top: 1rem; padding-block: 1.1rem; }
.site-footer { margin-top: .65rem; }
@media (max-width: 980px) {
  .tool-layout { gap: .75rem; }
  .editor-panel, .metrics-panel { padding: .75rem; }
  .editor-frame, textarea { min-height: 130px; }
  textarea { padding: .65rem .75rem; }
  .metric-grid-primary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
  .metric-grid-secondary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
  .metric-card { padding: .5rem; }
  .metric-label { font-size: .62rem; letter-spacing: .06em; }
  .metric-value { font-size: 1.35rem; }
  .detail-card { padding: .4rem .5rem; }
  .detail-value { font-size: 1rem; }
  .metrics-subsection { margin-top: .5rem; }
  .metrics-panel .panel-header h2 { font-size: 1rem; }
  .reference-band { gap: .65rem; padding-block: 1rem; }
  .reference-band h2 { font-size: 1.2rem; }
  .reference-band .reference-body { min-width: 0; }
  .reference-band .reference-limits { gap: .55rem 1rem; font-size: .95rem; }
  .reference-band .reference-limits dd { font-size: 1rem; }
  .reference-band .reference-scope { margin-block: .65rem .4rem; font-size: .82rem; }
}
@media (max-width: 720px) {
  .reference-band .reference-controls { flex-wrap: nowrap; gap: .65rem; }
  .reference-band #ad-format { flex: 1 1 auto; min-width: 0; width: 0; }
  .reference-band .examples-toggle { flex: 0 0 auto; white-space: nowrap; }
}

/* On desktop, use the available screen instead of compressing the workspace. */
@media (min-width: 981px) {
  .page-shell {
    --desktop-gutter: clamp(1.5rem, 3vw, 4rem);
    width: calc(100% - var(--desktop-gutter) * 2);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: .75rem;
  }
  .app-header { flex-shrink: 0; padding-inline: calc(var(--desktop-gutter) + 1rem); }
  .tool-layout { flex: 1; align-items: stretch; }
  .writing-column { align-items: stretch; }
  .editor-panel { display: flex; flex-direction: column; }
  .editor-panel .panel-header { flex-shrink: 0; }
  .editor-frame { flex: 1; display: flex; }
  textarea { flex: 1; display: block; }
  .metrics-panel { display: flex; flex-direction: column; }
  .metric-grid-primary { flex: 1; gap: .75rem; }
  .metric-card { padding: .8rem .9rem; }
  .metric-value { font-size: clamp(1.8rem, 2.2vw, 2.5rem); }
  .detail-card { padding: .65rem .75rem; }
  .detail-value { font-size: 1.35rem; }
  .reference-band { flex-shrink: 0; padding-inline: var(--desktop-gutter); }
  .site-footer { flex-shrink: 0; }
}

/* Optional reference tool: collapsed until the writer chooses to open it. */
.reference-band:not(.is-open) { display: block; padding-block: .65rem; }
.reference-body[hidden] { display: none !important; }
.reference-toggle {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.reference-toggle-icon { width: 1em; flex-shrink: 0; text-align: center; font-weight: 400; }
.reference-toggle:hover { color: var(--ink); }
.reference-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 3px; }
