:root {
  --ink: var(--syn-text, #ece7dd);
  --muted: var(--syn-text-muted, #a8a29a);
  --line: var(--syn-border-strong, rgba(214, 198, 168, 0.16));
  --surface: var(--syn-surface, #1b1f24);
  --canvas: var(--syn-bg, #121417);
  --accent: var(--syn-red, #c1121f);
  --accent-dark: #ad101c;
  --focus: var(--syn-steel, #4c6b73);
  --success: var(--syn-ok, #3fb07a);
}

* { box-sizing: border-box; }
html { min-height: 100%; font-size: 16px; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}
button, input { font: inherit; }
a { color: inherit; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-nav, .page-shell, .site-footer { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }
.site-nav { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-family: var(--syn-font-display, Georgia, serif); font-size: 1.05rem; font-weight: 700; letter-spacing: 0.04em; text-decoration: none; }
.account { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 0.875rem; }
.account form { margin: 0; }
.account-link { color: var(--ink); font-weight: 650; text-decoration: none; }
.account-link:hover { color: var(--accent-dark); }
.text-button { padding: 0; color: var(--ink); background: transparent; border: 0; font-weight: 650; cursor: pointer; }
.text-button:hover { color: var(--accent-dark); }
.page-shell { padding-block: 64px 80px; }

.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 36px; }
.eyebrow { margin: 0 0 8px; color: var(--accent-dark); font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
h1, h2, p { overflow-wrap: break-word; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.08; font-weight: 760; letter-spacing: 0; }
h2 { margin: 0; font-size: 1.15rem; line-height: 1.3; font-weight: 730; letter-spacing: 0; }
.format-note { margin: 0 0 7px; color: var(--muted); font-size: 0.875rem; text-align: right; }

.upload-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr); min-height: 430px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--syn-radius-card, 14px); overflow: hidden; }
.upload-panel, .preview-panel { min-width: 0; padding: 36px; }
.upload-panel { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.drop-zone { min-height: 270px; padding: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--syn-surface-raised, #22272e); border: 1px dashed var(--line); border-radius: var(--syn-radius-input, 8px); cursor: pointer; text-align: center; transition: border-color 150ms ease, background-color 150ms ease; }
.drop-zone:hover, .drop-zone.is-dragging { background: color-mix(in srgb, var(--syn-surface-raised, #22272e) 85%, var(--success)); border-color: var(--success); }
.drop-zone:focus-within { outline: 3px solid color-mix(in srgb, var(--focus) 25%, transparent); outline-offset: 2px; }
.drop-zone input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.drop-zone-title { font-weight: 750; }
.drop-zone-file { max-width: 100%; min-height: 22px; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }

.resize-control { min-width: 0; margin: 18px 0 0; padding: 0; border: 0; }
.resize-control legend { margin-bottom: 8px; color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.resize-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.resize-options label { min-width: 0; cursor: pointer; }
.resize-options input { position: absolute; opacity: 0; pointer-events: none; }
.resize-options span { min-height: 76px; padding: 12px; display: flex; flex-direction: column; justify-content: center; gap: 4px; background: var(--syn-surface-raised, #22272e); border: 1px solid var(--line); border-radius: var(--syn-radius-input, 8px); transition: border-color 150ms ease, background-color 150ms ease; }
.resize-options strong { font-size: 0.8rem; }
.resize-options small { color: var(--muted); font-size: 0.65rem; line-height: 1.35; }
.resize-options input:checked + span { background: color-mix(in srgb, var(--syn-surface-raised, #22272e) 85%, var(--focus)); border-color: var(--focus); }
.resize-options input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 2px; }

.scale-control { margin-top: 18px; padding: 16px 18px; background: var(--syn-surface-raised, #22272e); border: 1px solid var(--line); border-radius: var(--syn-radius-input, 8px); }
.scale-control-heading, .scale-control-notes { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.scale-control-heading label { font-size: 0.85rem; font-weight: 700; }
.scale-control-heading output { color: var(--syn-gold, #b89c5a); font-family: var(--syn-font-mono, monospace); font-size: 0.8rem; }
.scale-control input[type="range"] { width: 100%; margin: 12px 0 8px; accent-color: var(--accent); cursor: pointer; }
.scale-control-notes { color: var(--muted); font-size: 0.7rem; }
.scale-control .field-validation { margin-bottom: 0; }

.button { min-height: 44px; padding: 10px 18px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: var(--syn-radius-input, 8px); font-size: var(--syn-text-small, 14.3px); font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer; }
.button-primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.button-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.button-secondary { color: var(--ink); background: var(--syn-surface-raised, #22272e); border-color: var(--line); }
.button-secondary:hover { border-color: var(--ink); }
.upload-panel > .button-primary { width: 100%; margin-top: 20px; }
.validation-summary:empty, .field-validation:empty { display: none; }
.validation-summary, .field-validation { margin-bottom: 16px; color: #a22d22; font-size: 0.875rem; }
.validation-summary ul { margin: 0; padding-left: 20px; }
.field-validation { margin: 8px 0 0; }

.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.alpha-status { color: var(--muted); font-size: 0.75rem; font-weight: 700; text-align: right; }
.alpha-status.has-alpha { color: var(--success); }
.checkerboard {
  background-color: #fff;
  background-image: linear-gradient(45deg, #dce1de 25%, transparent 25%), linear-gradient(-45deg, #dce1de 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #dce1de 75%), linear-gradient(-45deg, transparent 75%, #dce1de 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.preview-stage { width: min(100%, 270px); aspect-ratio: 1; margin-inline: auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--syn-radius-input, 8px); overflow: hidden; }
.preview-stage canvas { width: 100%; height: 100%; image-rendering: auto; }
.preview-placeholder { color: #7d8982; font-size: 0.8rem; font-weight: 700; }
.preview-details { margin: 26px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.preview-details div { min-width: 0; }
.preview-details dt { margin-bottom: 3px; color: var(--muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.preview-details dd { margin: 0; font-size: 0.85rem; }
.actual-size-preview { margin-top: 24px; }
.actual-size-preview h3 { margin-bottom: 10px; color: var(--muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.actual-size-stage { width: 102px; height: 102px; display: grid; place-items: center; border: 1px solid var(--line); overflow: hidden; }
.actual-size-stage canvas { display: block; width: 100px; height: 100px; }
.actual-size-stage span { color: #7d8982; font-size: 0.7rem; font-weight: 700; }

.result-band { margin-top: 28px; padding: 32px 36px; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: center; color: var(--ink); background: var(--syn-surface-raised, #22272e); border: 1px solid var(--line); border-radius: var(--syn-radius-card, 14px); }
.result-band .eyebrow { color: var(--syn-gold, #b89c5a); }
.result-content { min-width: 0; display: flex; align-items: center; gap: 24px; }
.result-preview { width: 102px; height: 102px; flex: 0 0 102px; border: 1px solid #748078; }
.result-preview img { display: block; }
.url-field { min-width: 0; flex: 1; }
.url-field label { display: block; margin-bottom: 8px; color: #c6d0ca; font-size: 0.75rem; font-weight: 700; }
.url-control { display: flex; }
.url-control input { min-width: 0; height: 44px; flex: 1; padding: 0 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--syn-radius-input, 8px) 0 0 var(--syn-radius-input, 8px); }
.url-control .button { flex: 0 0 auto; border-radius: 0 var(--syn-radius-input, 8px) var(--syn-radius-input, 8px) 0; }
.copy-status { min-height: 18px; margin-top: 5px; display: block; color: var(--success); font-size: 0.75rem; }

.admin-heading { margin-bottom: 24px; }
.admin-search { margin-bottom: 28px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--syn-radius-card, 14px); }
.admin-search label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.admin-search > div { display: flex; gap: 10px; }
.admin-search input { min-width: 0; height: 44px; flex: 1; padding: 0 13px; color: var(--ink); background: var(--syn-surface-raised, #22272e); border: 1px solid var(--line); border-radius: var(--syn-radius-input, 8px); }
.admin-search input:focus { border-color: var(--focus); outline: 3px solid color-mix(in srgb, var(--focus) 25%, transparent); }
.admin-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.upload-card { min-width: 0; padding: 20px; display: grid; grid-template-columns: 122px minmax(0, 1fr); gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--syn-radius-card, 14px); }
.upload-card-preview { width: 122px; height: 122px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--syn-radius-input, 8px); overflow: hidden; }
.upload-card-preview img { width: 100px; height: 100px; object-fit: contain; }
.upload-card-body { min-width: 0; }
.upload-card-body h2 { margin-bottom: 14px; overflow: hidden; font-size: 0.95rem; text-overflow: ellipsis; white-space: nowrap; }
.upload-card-body dl { margin: 0 0 12px; display: grid; gap: 8px; }
.upload-card-body dl div { min-width: 0; }
.upload-card-body dt { color: var(--muted); font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.upload-card-body dd { margin: 1px 0 0; overflow: hidden; font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.upload-card-body code { max-width: 100%; display: block; overflow: hidden; color: var(--syn-gold, #b89c5a); font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }
.admin-empty { padding: 64px 24px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: var(--syn-radius-card, 14px); text-align: center; }
.admin-empty h2 { margin-bottom: 8px; color: var(--ink); }
.admin-empty p { margin: 0; }
.pagination-nav { margin-top: 28px; display: flex; align-items: center; justify-content: center; gap: 18px; color: var(--muted); font-size: 0.8rem; }
.pagination-nav .is-disabled { opacity: 0.4; cursor: not-allowed; }

.access-state { max-width: 680px; padding-block: 64px; }
.access-state h1 { margin-bottom: 20px; }
.access-state p:not(.eyebrow) { max-width: 580px; margin: 0 0 28px; color: var(--muted); font-size: 1.05rem; line-height: 1.7; }
.site-footer { padding-block: 24px 36px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.75rem; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent); outline-offset: 2px; }

@media (max-width: 780px) {
  .site-nav, .page-shell, .site-footer { width: min(100% - 28px, 640px); }
  .page-shell { padding-block: 40px 56px; }
  .workspace-heading { align-items: start; flex-direction: column; gap: 16px; }
  .format-note { text-align: left; }
  .upload-grid { grid-template-columns: 1fr; }
  .upload-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .result-band { grid-template-columns: 1fr; }
  .admin-gallery { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .account-name { display: none; }
  .upload-panel, .preview-panel, .result-band { padding: 24px; }
  .drop-zone { min-height: 220px; padding: 24px 16px; }
  .result-content { align-items: start; flex-direction: column; }
  .url-control { align-items: stretch; flex-direction: column; gap: 8px; }
  .url-control input, .url-control .button { width: 100%; border-radius: var(--syn-radius-input, 8px); }
  .site-footer { flex-direction: column; }
  .admin-search > div { align-items: stretch; flex-direction: column; }
  .admin-search .button { width: 100%; }
  .upload-card { grid-template-columns: 92px minmax(0, 1fr); padding: 16px; gap: 14px; }
  .upload-card-preview { width: 92px; height: 92px; }
  .upload-card-preview img { width: 78px; height: 78px; }
  .pagination-nav { gap: 10px; }
  .resize-options { grid-template-columns: 1fr; }
  .resize-options span { min-height: 58px; }
}
