/* Security-paper palette: cool tinted paper, deep ink, teal guilloche, stamp red. */
:root {
  --paper: #eef2f1;
  --surface: #f8faf9;
  --ink: #142326;
  --muted: #4f6467;
  --rule: #c3d1cf;
  --guilloche: #3f7f78;
  --stamp: #c8102e;
  --focus: #c8102e;
  --on-ink: #f8faf9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e191b;
    --surface: #142328;
    --ink: #e2ebe9;
    --muted: #93a8a8;
    --rule: #2b3f43;
    --guilloche: #5fa79d;
    --stamp: #e8495a;
    --focus: #f0707d;
    --on-ink: #0e191b;
    color-scheme: dark;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* Always show the scrollbar (where scrollbars take up space) so the layout
     doesn't shift sideways when adding images makes the page scroll. */
  overflow-y: scroll;
}

/* Elements styled with display: flex/grid must still hide with the hidden attribute. */
[hidden] { display: none !important; }

/* Full-height column so the footer sits at the bottom even when the page is short. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.5 var(--sans);
}

/* ---------- masthead: the one decorative element ---------- */

.masthead {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
}

.guilloche {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.guilloche path { fill: none; vector-effect: non-scaling-stroke; }
.guilloche .g-teal { stroke: var(--guilloche); stroke-width: 0.8; opacity: 0.35; }
.guilloche .g-red { stroke: var(--stamp); stroke-width: 1.1; opacity: 0.55; }

.masthead-inner {
  position: relative;
  max-width: 76rem;
  margin: 0 auto;
  padding: 3.25rem 1.5rem 2.5rem;
}

h1 {
  display: inline-block;
  margin: 0;
  padding: 0.1em 0.3em 0.1em 0;
  background: var(--paper);
  font: 600 clamp(2rem, 5vw, 3.25rem) / 1.1 var(--serif);
  letter-spacing: -0.01em;
}

.lead {
  max-width: 38rem;
  margin: 1rem 0 0;
  padding: 0.25rem 0.5rem 0.25rem 0;
  background: var(--paper);
  color: var(--muted);
  font-size: 1.0625rem;
}

/* ---------- layout ---------- */

.layout {
  flex: 1 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
  gap: 2.5rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  align-items: start;
}

@media (max-width: 52rem) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; padding: 1.5rem 1rem 3rem; }
  .masthead-inner { padding: 2.25rem 1rem 1.75rem; }
}

/* ---------- controls ---------- */

/* Pinned while scrolling through the images, but only while it fits in the window
   (app.js adds .is-tall otherwise), so the panel never needs its own scrollbar. */
.controls {
  position: sticky;
  top: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.controls.is-tall { position: static; }

@media (max-width: 52rem) {
  .controls { position: static; }
}

.field { margin: 0 0 1.25rem; padding: 0; border: 0; min-width: 0; }

.field > label,
.field > legend,
.field-row > label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  padding: 0;
  font-weight: 600;
  font-size: 0.9375rem;
}

output { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }

.field-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.field-row > label { margin: 0; }

.hint { margin: 0.375rem 0 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.45; }
.hint-tight { margin: 0 0 1.25rem; }

textarea,
input[type="number"],
select {
  width: 100%;
  padding: 0.5rem 0.625rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
}

textarea { resize: vertical; min-height: 3.25rem; }

input[type="range"] { width: 100%; accent-color: var(--stamp); }
input[type="checkbox"] { accent-color: var(--stamp); width: 1rem; height: 1rem; margin: 0; }

.field > .check,
.check {
  display: flex;
  justify-content: flex-start;
  font-weight: 400;
  align-items: center;
  gap: 0.5rem;
  margin: 0.625rem 0 0;
  font-size: 0.9375rem;
  cursor: pointer;
}

.more > .check { margin: 0 0 1.25rem; }

.final-text {
  margin: 0.625rem 0 0;
  padding: 0.375rem 0.625rem;
  border-left: 3px solid var(--stamp);
  color: var(--stamp);
  font-weight: 700;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.final-text:empty { display: none; }

/* segmented strength control */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

.segmented label { position: relative; cursor: pointer; }
.segmented label + label { border-left: 1px solid var(--rule); }

.segmented input {
  position: absolute;
  opacity: 0;
  inset: 0;
  margin: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  padding: 0.5rem 0.25rem;
  text-align: center;
  font-size: 0.9375rem;
}

.segmented input:checked + span { background: var(--ink); color: var(--on-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -4px; }

.color-pick { display: flex; align-items: center; gap: 0.75rem; }

input[type="color"] {
  width: 3rem;
  height: 2rem;
  padding: 2px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 4px;
  cursor: pointer;
}

.more { border-top: 1px solid var(--rule); padding-top: 0.75rem; }

.more summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
  padding: 0.25rem 0;
}

.more[open] summary { margin-bottom: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-2 .field { margin-bottom: 1.25rem; }

.file-row { display: flex; align-items: center; gap: 0.625rem; }
.file-row input[type="file"] { min-width: 0; flex: 1; font-size: 0.8125rem; color: var(--muted); }

/* Native "Choose file" button, styled like .button-quiet. */
input[type="file"]::file-selector-button {
  margin-right: 0.625rem;
  padding: 0.375rem 0.75rem;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover { border-color: var(--muted); }
input[type="file"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.file-row input[type="number"] { flex: 1; }

/* ---------- buttons ---------- */

button { font: inherit; cursor: pointer; }

.button-primary,
.button-quiet {
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  font-size: 0.9375rem;
  white-space: nowrap;
}

.button-primary { background: var(--ink); color: var(--on-ink); border: 1px solid var(--ink); font-weight: 600; }
.button-primary:hover { filter: brightness(1.25); }
.button-primary:disabled { opacity: 0.4; cursor: not-allowed; filter: none; }

.button-quiet { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.button-quiet:hover { border-color: var(--muted); }
.button-quiet[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.link {
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  font-size: inherit;
}

.link:hover { color: var(--stamp); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- drop zone ---------- */

.dropzone {
  display: grid;
  justify-items: center;
  padding: 2rem 1.25rem;
  border: 1.5px dashed var(--rule);
  border-radius: 6px;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone.is-over { border-color: var(--stamp); background: var(--surface); }

.has-items .dropzone { padding: 1rem; }
.has-items .dropzone .card-outline { display: none; }

.card-outline { width: 7rem; height: auto; margin-bottom: 0.75rem; }
.card-outline rect,
.card-outline path { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-linecap: round; }

.drop-title { margin: 0; font-size: 1.0625rem; }

.notice {
  margin: 1rem 0 0;
  padding: 0.625rem 0.875rem;
  border-left: 3px solid var(--stamp);
  background: var(--surface);
  font-size: 0.9375rem;
}

/* ---------- items ---------- */

.items { list-style: none; margin: 0; padding: 0; }

.item {
  margin-top: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}

.preview {
  display: grid;
  place-items: center;
  min-height: 8rem;
  padding: 0.75rem;
  background:
    repeating-linear-gradient(45deg, transparent 0 10px, color-mix(in srgb, var(--rule) 25%, transparent) 10px 11px),
    var(--paper);
}

.preview canvas,
.preview img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.18);
}

.preview .error { color: var(--stamp); font-weight: 600; padding: 1rem; text-align: center; }

.item.is-busy .preview canvas { opacity: 0.6; transition: opacity 0.2s; }

.item-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--rule);
}

.item-meta { display: grid; min-width: 0; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-size { margin: 0; }
.item-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.625rem; margin-top: 1.5rem; }

.footnote { max-width: 40rem; margin-top: 1.5rem; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
}

.site-footer p {
  max-width: 76rem;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.875rem;
}

@media (max-width: 52rem) {
  .site-footer p { padding: 1.25rem 1rem 1.5rem; }
}

.site-footer a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.site-footer a:hover { color: var(--stamp); }

.heart { color: var(--stamp); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
