:root {
  color-scheme: dark;
  --proxy-paper: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--rf-background); color: var(--rf-text); font: 14px/1.5 var(--rf-font); }
h1, h2, p { margin-top: 0; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.4px; line-height: 1.3; margin-bottom: 20px; }
button, input, select, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
button { border: 1px solid transparent; border-radius: var(--rf-radius-control); background: var(--rf-accent); color: var(--rf-field); font-size: 13px; font-weight: 600; min-height: 44px; padding: 10px 15px; transition: background .15s, border-color .15s, color .15s; }
button:hover:not(:disabled) { background: var(--rf-accent-hover); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: var(--rf-surface); border-color: var(--rf-control-border); color: var(--rf-text); }
button.secondary:hover:not(:disabled) { background: var(--rf-hover); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--rf-focus); outline-offset: 3px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--rf-accent-text); outline-offset: 2px; }
input, select, textarea { width: 100%; min-width: 0; border: 1px solid var(--rf-control-border); border-radius: var(--rf-radius-control); background: var(--rf-field); color: var(--rf-text); padding: 9px 12px; min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--rf-muted); opacity: .85; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[aria-invalid=true] { border-color: var(--rf-accent-text); }
textarea { resize: vertical; display: block; }
input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--rf-accent); }
label { display: block; }
label, summary { overflow-wrap: anywhere; }
[hidden] { display: none !important; }
::selection { background: var(--rf-accent); color: var(--rf-field); }

/* Suite chrome is shared; only Proxy's language controls and alignment live here. */
.rf-suite-header { padding: 16px max(28px, calc((100% - 1180px) / 2)); }
.header-actions { gap: 24px; }
.rf-suite-switcher > summary { min-height: 44px; }
.language-switcher { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.language-switcher > span { font-size: 10px; color: var(--rf-muted); }
.ui-languages { display: flex; gap: 4px; }
.ui-languages button { display: flex; align-items: center; justify-content: center; padding: 5px; min-width: 44px; min-height: 44px; border: 2px solid transparent; background: transparent; }
.ui-languages button[aria-pressed=true] { border-color: var(--rf-accent); background: var(--rf-accent-soft); }
.ui-languages button:hover:not(:disabled) { background: var(--rf-hover); }
.ui-languages img { display: block; border-radius: 2px; }
.skip-link { position: fixed; top: -100px; left: 15px; z-index: 150; padding: 12px 16px; border-radius: var(--rf-radius-control); background: var(--rf-accent); color: var(--rf-field); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 12px; }

.wrapper { max-width: 1236px; margin: auto; padding: 48px 28px 24px; }
.content { display: flex; flex-direction: column; gap: 22px; }
.intro { margin-bottom: 6px; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 10px; font-weight: 650; letter-spacing: 1.6px; color: var(--rf-muted); }
.eyebrow > span { flex: 0 0 6px; height: 6px; border-radius: 50%; background: var(--rf-accent); }
.intro h1 { font-size: clamp(30px, 3vw, 42px); font-weight: 550; letter-spacing: -1.8px; margin: 12px 0 13px; line-height: 1.2; }
.intro-description { margin: 0; max-width: 670px; color: var(--rf-muted); font-size: 14px; line-height: 1.7; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 22px; align-items: start; scroll-margin-top: 20px; }
.panel { background: var(--rf-surface); border: 1px solid var(--rf-line); border-radius: var(--rf-radius-panel); padding: 27px; min-width: 0; box-shadow: 0 3px 6px var(--rf-shadow); }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.section-heading h2 { margin: 0; }
.decklist-heading { margin-bottom: 20px; }
.decklist label, .settings label { font-size: 12px; font-weight: 600; }
.decklist label { margin-bottom: 8px; }
.decklist textarea { font: 14px/1.7 ui-monospace, monospace; min-height: 168px; padding: 12px; }
.hint { font-size: 12px; line-height: 1.6; color: var(--rf-muted); margin: 10px 0 16px; }
.file-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.decklist .file-picker { margin-bottom: 0; }
.file-picker button { font-size: 12px; padding: 8px 12px; }
.file-picker span { font-size: 12px; overflow-wrap: anywhere; color: var(--rf-muted); }
.primary-settings, .grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, 160px); gap: 12px; align-items: center; }
.primary-settings { border-top: 1px solid var(--rf-line); padding-top: 18px; margin-top: 18px; }
.primary-settings label { margin: 0; }
.btn { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn > button:first-child { flex-grow: 1; }
#generate.rf-action-primary { min-height: 44px; }
#status { margin: 12px 0 0; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
progress { width: 100%; height: 6px; margin-top: 16px; accent-color: var(--rf-accent); }
.error, #edit-error { color: var(--rf-accent-text); }
#status.error, #edit-error:not(:empty) { border: 1px solid var(--rf-error-border); border-radius: var(--rf-radius-control); background: var(--rf-error-surface); padding: 10px 12px; }
.advanced, .howto { border-top: 1px solid var(--rf-line); padding-top: 14px; margin-top: 18px; }
summary { font-weight: 600; min-height: 44px; line-height: 1.5; padding: 10px 0; }
.advanced summary { font-size: 12px; color: var(--rf-muted); }
.advanced[open] summary { color: var(--rf-text); }
.advanced .grid { margin: 8px 0; }
.print-note { border-top: 1px solid var(--rf-line); padding-top: 15px; margin: 0; font-size: 12px; color: var(--rf-muted); line-height: 1.6; }
.howto p { font-size: 13px; line-height: 1.7; margin: 12px 0; }
.howto pre { white-space: pre-wrap; color: var(--rf-accent-text); font-size: 13px; padding: 12px; border: 1px solid var(--rf-line); border-radius: var(--rf-radius-control); background: var(--rf-field); }

.quick-guide.panel { position: relative; padding: 18px 22px; background: var(--rf-surface-inset); box-shadow: none; }
.quick-guide h2 { font-size: 14px; letter-spacing: -.2px; margin: 0 0 14px; padding-right: 210px; }
.guide-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 24px; margin: 0; padding: 0; list-style: none; }
.guide-steps li { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 12px; line-height: 1.6; color: var(--rf-muted); }
.step-number { display: flex; align-items: center; justify-content: center; flex: 0 0 28px; height: 28px; border: 1px solid var(--rf-line); border-radius: 8px; background: var(--rf-surface); color: var(--rf-accent-text); font-size: 11px; font-weight: 600; }
.quick-guide .howto { margin: 0; padding: 0; border: 0; }
.quick-guide .howto[open] { border-top: 1px solid var(--rf-line); margin-top: 14px; padding-top: 4px; }
.quick-guide .howto summary { position: absolute; top: 8px; right: 22px; font-size: 12px; padding: 10px 0; color: var(--rf-accent-text); }

.view-controls { display: flex; gap: 8px; }
.view-controls button { font-size: 12px; padding: 8px 14px; }
.view-controls button[aria-pressed=true] { border-color: var(--rf-accent-line); color: var(--rf-accent-text); background: var(--rf-accent-soft); }
.notice { padding: 12px 14px; border: 1px solid var(--rf-accent-line); border-radius: var(--rf-radius-control); background: var(--rf-accent-soft); color: var(--rf-accent-text); font-size: 12px; line-height: 1.6; }
#preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; }
#preview figure { margin: 0; min-width: 0; text-align: center; }
#preview figure img { display: block; width: 100%; max-width: 240px; height: auto; margin: auto; box-shadow: 0 4px 16px var(--rf-shadow); cursor: zoom-in; border-radius: 2px; }
#preview figcaption { margin: 12px 0; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
#preview button { font-size: 12px; padding: 8px 12px; }
.is-stale #preview, .is-stale #paper-preview { opacity: .5; }
.download-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; scroll-margin-top: 16px; }
.download-actions p { font-size: 12px; margin: 0; color: var(--rf-muted); }
.download-shortcut { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); right: 16px; z-index: 5; padding: 10px 16px; min-height: 44px; border-radius: 24px; background: var(--rf-accent); color: var(--rf-field); text-decoration: none; font-size: 12px; font-weight: 600; box-shadow: 0 4px 20px var(--rf-shadow); }
.download-shortcut:hover { background: var(--rf-accent-hover); }

/* The white sheet and its image coordinates represent the actual print layout. */
#paper-preview { position: relative; background: var(--proxy-paper); margin: 24px auto 16px; width: 100%; max-width: 560px; box-shadow: 0 4px 20px var(--rf-shadow); overflow: hidden; }
#paper-preview img { position: absolute; display: block; height: auto; }
.page-navigation { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-navigation button { font-size: 12px; padding: 8px 12px; }
#page-number { font-size: 12px; color: var(--rf-muted); }
/* Keep renderer internals outside the scope of all interface image styles. */
.render-host { position: fixed; left: -10000px; top: 0; pointer-events: none; }
.render-host img { display: none; }

footer { text-align: center; font-size: 11px; color: var(--rf-muted); padding: 26px 20px 76px; border-top: 1px solid var(--rf-line); }
.footer-data { margin: 0; line-height: 1.8; }
.footer-data > span { display: inline-block; }
.footer-data a { color: var(--rf-text); text-underline-offset: 3px; }
.footer-data a:hover { color: var(--rf-accent-text); }

dialog { padding: 0; border: 1px solid var(--rf-control-border); border-radius: var(--rf-radius-panel); background: var(--rf-surface); color: var(--rf-text); width: min(1000px, calc(100% - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: hidden; box-shadow: 0 15px 90px var(--rf-shadow); }
dialog::backdrop { background: var(--rf-backdrop); backdrop-filter: blur(3px); }
dialog[open] { display: flex; flex-direction: column; }
#editor-form { display: flex; flex-direction: column; min-height: 0; width: 100%; max-height: inherit; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--rf-line); flex-shrink: 0; }
.dialog-header h2 { margin: 0; font-size: 20px; font-weight: 550; letter-spacing: -.6px; overflow-wrap: anywhere; }
.icon-button { font-size: 24px; padding: 0; min-width: 44px; min-height: 44px; line-height: 1; }
.decklist-clear { display: flex; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; }
.decklist-clear svg { display: block; pointer-events: none; }
.editor-body { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 24px; padding: 20px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.editor-fields > label, .editor-grid label { font-size: 12px; font-weight: 600; }
.editor-fields > input, .editor-fields > select, .editor-fields > textarea, #pendulum-fields input, #pendulum-fields textarea { margin: 6px 0 14px; }
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: center; margin: 6px 0 14px; }
.editor-grid input, .editor-grid select { margin: 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
.editor-preview { align-self: start; position: sticky; top: 0; border: 1px solid var(--rf-line); border-radius: 10px; background: var(--rf-surface-inset); padding: 10px 12px; }
.editor-preview summary { font-size: 12px; color: var(--rf-muted); }
.editor-preview img { display: block; width: 100%; max-width: 300px; height: auto; margin: 12px auto; box-shadow: 0 4px 16px var(--rf-shadow); }
.dialog-footer { padding: 12px 20px 16px; border-top: 1px solid var(--rf-line); flex-shrink: 0; background: var(--rf-surface); }
.dialog-footer p { margin: 0; font-size: 12px; line-height: 1.6; }
.dialog-footer p:not(:empty) { margin-bottom: 10px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions button { flex: 1; }
.editor-fields .file-picker { margin-bottom: 0; }
#zoom { width: min(760px, calc(100% - 24px)); }
.zoom-body { overflow: auto; padding: 12px; min-height: 0; overscroll-behavior: contain; }
.zoom-body img { display: block; width: 100%; max-width: 697px; height: auto; margin: auto; }

@media (max-width: 1040px) {
  .header-actions { gap: 16px; }
  .workspace { gap: 18px; }
  .panel { padding: 22px; }
}
@media (max-width: 760px) {
  .rf-suite-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 14px 20px; gap: 10px 12px; }
  .rf-brand { grid-column: 1; grid-row: 1; }
  .header-actions { display: contents; }
  .rf-suite-switcher { grid-column: 2; grid-row: 1; }
  .language-switcher { grid-column: 1 / -1; grid-row: 2; flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
  .wrapper { padding: 33px 20px 20px; }
  .intro { margin-bottom: 2px; }
  .intro h1 { font-size: 34px; }
  .intro-description { font-size: 13px; }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .content { gap: 18px; }
  .panel { padding: 22px; }
  .decklist textarea { min-height: 128px; height: 144px; }
  input, select, textarea, .decklist textarea { font-size: 16px; }
  #preview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  #preview button { width: 100%; padding: 8px; }
  .view-controls { width: 100%; }
  .view-controls button { flex: 1; }
  .download-actions { align-items: stretch; flex-direction: column; }
  .download-actions button { width: 100%; }
  .editor-body { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .editor-preview { position: static; }
  .dialog-header { padding: 12px 16px; }
  .dialog-footer { padding: 12px 16px max(12px, env(safe-area-inset-bottom)); }
  .primary-settings, .grid { grid-template-columns: minmax(0, 1fr) minmax(100px, 145px); }
  .page-navigation { gap: 8px; }
  .quick-guide.panel { padding: 18px 22px; }
  .quick-guide h2 { padding-right: 0; }
  .guide-steps { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .quick-guide .howto, .quick-guide .howto[open] { border-top: 1px solid var(--rf-line); margin-top: 12px; padding-top: 4px; }
  .quick-guide .howto summary { position: static; padding: 8px 0; }
}
@media (max-width: 420px) {
  .rf-suite-header { padding: 14px; }
  .rf-brand { font-size: 18px; gap: 8px; }
  .rf-brand__mark { width: 32px; height: 32px; flex-basis: 32px; }
  .rf-brand__product { font-size: 8px; }
  .rf-suite-switcher > summary { font-size: 11px; padding: 8px 9px; gap: 7px; }
  .language-switcher { flex-direction: column; align-items: flex-start; gap: 3px; }
  .ui-languages { width: 100%; justify-content: space-between; }
  .wrapper { padding: 28px 14px 18px; }
  .intro h1 { font-size: 31px; letter-spacing: -1.2px; }
  .eyebrow { font-size: 9px; letter-spacing: 1.1px; }
  .panel, .quick-guide.panel { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
