/* Brand face, self-hosted so the app works with no network on the floor.
 * Only Bold is licensed here, so it is used for headings and buttons — which
 * are bold anyway — while body copy stays on the native system stack. */
@font-face {
  font-family: 'Centra No1';
  src: url('assets/fonts/CentraNo1-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --brand: 'Centra No1', 'Helvetica Neue', Arial, sans-serif;
  --accent: #c74e27;
  --accent-dark: #a33f1f;
  --ink: #1c1a18;
  --ink-soft: #6b635c;
  --line: #e3ddd5;
  --bg: #f6f4f1;
  --card: #ffffff;
  --radius: 14px;
  --bar-h: calc(64px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: calc(var(--bar-h) + 16px);
}

/* ---------- app bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.appbar h1 {
  margin: 0;
  font-family: var(--brand);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
}

main {
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 16px 0;
}

/* ---------- size selector ---------- */

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.seg button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 11px 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink-soft);
  font: inherit;
  cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}

.seg button strong { font-family: var(--brand); font-size: 16px; font-weight: 700; }
.seg button span { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }

.seg button[aria-selected="true"] {
  border-color: var(--accent);
  background: #fdf6f2;
  color: var(--accent);
}

/* ---------- preview ---------- */

.preview-wrap { margin-bottom: 18px; }

.paper {
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(28, 26, 24, .1), 0 8px 24px -12px rgba(28, 26, 24, .3);
}

#preview {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
}

.caption {
  margin: 8px 2px 0;
  font-size: 11.5px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- forms ---------- */

fieldset {
  margin: 0 0 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

legend {
  font-family: var(--brand);
  padding: 0 8px;
  margin-left: -4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}

.field { margin-top: 12px; }
.field:first-of-type { margin-top: 2px; }

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  padding: 12px 13px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fcfbfa;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;   /* <16px makes iOS Safari zoom on focus */
  font-weight: 600;
  line-height: 1.2;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.field input::placeholder { color: #b9b1a8; font-weight: 500; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 400px) { .row { grid-template-columns: 1fr; } }

/* ---------- settings panel ---------- */

.panel {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}

.panel summary {
  padding: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: " ▾"; color: var(--ink-soft); }
.panel[open] summary { border-bottom: 1px solid var(--line); }
.panel[open] summary::after { content: " ▴"; }

.panel-body { padding: 14px; }

.hint {
  margin: 0 0 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
}

.hint code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #f0ece7;
  font-size: 11.5px;
}

.bgrow {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.bgthumb {
  flex: 0 0 auto;
  width: 54px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f4f1;
  overflow: hidden;
}

.bgthumb img { width: 100%; height: 100%; object-fit: cover; }

.bgmeta { flex: 1 1 auto; min-width: 0; }
.bgmeta strong { display: block; font-size: 13px; }
.bgstate { font-size: 11.5px; color: var(--ink-soft); }
.bgbtns { display: flex; gap: 6px; }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-soft);
}

.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.footnote {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
}

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

.btn {
  padding: 12px 16px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  font: 700 14px/1 var(--brand);
  cursor: pointer;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .5; }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn.tiny { padding: 7px 10px; font-size: 12px; border-radius: 8px; }
.btn.full { width: 100%; margin-top: 12px; }

.actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.actions .btn { padding: 14px 16px; font-size: 15px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bar-h) + 16px);
  z-index: 30;
  transform: translate(-50%, 12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
