/* PrintLink local prototype — warm paper + stamp-ink */
:root {
  --paper: #f3eee4;
  --paper-deep: #e7dece;
  --card: #fffaf3;
  --ink: #1b1714;
  --muted: #6b6258;
  --line: #e4d9c8;
  --stamp: #b42318;
  --stamp-deep: #8f1a12;
  --forest: #2f5d50;
  --forest-soft: #e4efe9;
  --gold: #a15c07;
  --gold-soft: #f8ead3;
  --danger: #9f1239;
  --danger-soft: #fde8ee;
  --shadow: 0 18px 50px rgba(54, 36, 20, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #fff8ea 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #f6ddd4 0%, transparent 46%),
    var(--paper);
  font-family: "Source Sans 3", "Segoe UI", "SF Pro Text", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
}

.page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.brand { display: flex; gap: 14px; align-items: flex-start; }
.mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background:
    linear-gradient(160deg, #d84a3a 0%, var(--stamp) 60%, var(--stamp-deep) 100%);
  box-shadow: 0 8px 18px rgba(180, 35, 24, 0.22);
  position: relative;
  flex: 0 0 auto;
}
.mark::before,
.mark::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  background: rgba(255, 250, 243, 0.92);
  border-radius: 2px;
}
.mark::before { top: 14px; height: 3px; }
.mark::after { top: 21px; height: 3px; width: 14px; }

.eyebrow {
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--stamp);
}
h1, h2, .serif {
  font-family: Fraunces, "Iowan Old Style", Palatino, Georgia, serif;
  font-weight: 560;
  letter-spacing: -0.03em;
}
h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.5rem); line-height: 1.15; }
h2 { margin: 0 0 8px; font-size: 1.45rem; }
.lede, .sub { color: var(--muted); margin: 0; }
.lede { font-size: 1.05rem; max-width: 38rem; }

.nav-link {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: rgba(255,250,243,0.7);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
}
.nav-link:hover { background: var(--card); }

.grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 860px) {
  .grid, .top { display: block; }
  .nav-link { display: inline-block; margin-top: 16px; }
}

.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.drop {
  display: block;
  margin: 22px 0 18px;
  padding: 36px 22px;
  border: 1.5px dashed #cfc1aa;
  border-radius: 18px;
  background: #fbf6ec;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.drop:hover, .drop.is-over {
  border-color: var(--stamp);
  background: #fff4ea;
  transform: translateY(-1px);
}
.drop input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.drop strong { display: block; font-size: 1.15rem; margin-bottom: 4px; }
.drop span { color: var(--muted); font-size: 0.95rem; }

.file-chip {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -6px 0 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--gold-soft);
  color: #6b3d04;
}
.file-chip.is-on { display: flex; }
.file-chip b { display: block; word-break: break-all; }

button, .btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-primary, button[type="submit"] {
  background: var(--ink);
  color: #fffaf3;
  width: 100%;
}
button[type="submit"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary:hover, button[type="submit"]:hover:not(:disabled) { background: #000; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.status {
  display: none;
  margin-top: 18px;
  padding: 16px 16px 16px 18px;
  border-radius: 16px;
  border-left: 4px solid var(--forest);
  background: var(--forest-soft);
}
.status.is-on { display: block; }
.status.is-error {
  background: var(--danger-soft);
  border-left-color: var(--danger);
}
.status h3 { margin: 0 0 4px; font-size: 1.05rem; }

.side-card { padding: 22px; }
.side-card ol { margin: 10px 0 0; padding-left: 18px; color: var(--muted); }
.side-card li { margin: 8px 0; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pill-pending { background: var(--gold-soft); color: var(--gold); }
.pill-printed { background: var(--forest-soft); color: var(--forest); }
.pill-cancelled { background: #eeeae3; color: var(--muted); }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.url-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f6f0e4;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  word-break: break-all;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.96rem;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.job-name { font-weight: 700; word-break: break-all; }
.empty {
  padding: 28px 8px;
  color: var(--muted);
  text-align: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: #fbf6ec;
  border-radius: 16px;
  padding: 14px;
}
.stat b { display: block; font-size: 1.4rem; font-family: Fraunces, Georgia, serif; }
.stat span { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 640px) {
  .card { padding: 20px; }
  .stats, table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  td { padding: 3px 0; border: 0; }
}

.qr-card {
  display: flex;
  gap: 22px;
  align-items: center;
  margin: 16px 0 22px;
  padding: 18px;
  border-radius: 18px;
  background: #fbf6ec;
  border: 1px solid var(--line);
  flex-wrap: wrap;
}
.qr-wrap {
  flex: 0 0 auto;
  padding: 10px;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--line);
  line-height: 0;
}
.qr-wrap canvas {
  display: block;
  width: 220px;
  height: 220px;
}
.qr-meta { flex: 1 1 220px; min-width: 200px; }
.qr-meta h2 { margin-bottom: 6px; }
.qr-meta .url-box { margin-top: 12px; }
@media (max-width: 640px) {
  .qr-card { justify-content: center; text-align: center; }
  .qr-meta .url-box { text-align: left; }
}


#qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  min-height: 220px;
}
#qr-box img,
#qr-box canvas {
  display: block;
  width: 220px;
  height: 220px;
}

/* multi-upload + optional crop */
[hidden] { display: none !important; }
body.crop-open { overflow: hidden; }

.queue {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: -6px 0 18px;
}
.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--gold-soft);
  color: #6b3d04;
}
.queue-thumb {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  border-radius: 10px;
  overflow: hidden;
  background: #f3ebe0;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.queue-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.queue-ext {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
}
.queue-ext strong {
  color: var(--stamp);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  line-height: 1;
}
.queue-ext span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.queue-info { flex: 1; min-width: 0; }
.queue-info b { display: block; word-break: break-all; }
.queue-info span { display: block; font-size: 0.9rem; }
.queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  flex: 0 0 auto;
}
.queue-actions .btn-ghost {
  padding: 8px 12px;
  border-radius: 10px;
  min-height: 40px;
}
.sent-list {
  margin: 10px 0 0;
  padding-left: 18px;
}
.sent-list li { margin: 4px 0; word-break: break-all; }

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(27, 23, 20, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.crop-sheet {
  width: min(560px, 100%);
  max-height: calc(100vh - 24px);
  background: var(--card);
  border-radius: 20px 20px 16px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 16px;
}
.crop-head h2 { margin: 0 0 4px; font-size: 1.25rem; }
.crop-head p { margin: 0 0 12px; color: var(--muted); font-size: 0.95rem; }
.crop-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 240px;
  background: #1b1714;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.crop-stage img {
  max-width: 100%;
  max-height: min(58vh, 480px);
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.crop-box {
  position: absolute;
  border: 2px solid #fffaf3;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: move;
  touch-action: none;
}
.handle {
  position: absolute;
  width: 22px;
  height: 22px;
  background: #fffaf3;
  border: 2px solid var(--stamp);
  border-radius: 5px;
  touch-action: none;
}
.handle.nw { left: -11px; top: -11px; cursor: nwse-resize; }
.handle.ne { right: -11px; top: -11px; cursor: nesw-resize; }
.handle.sw { left: -11px; bottom: -11px; cursor: nesw-resize; }
.handle.se { right: -11px; bottom: -11px; cursor: nwse-resize; }
.crop-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.crop-actions .btn-ghost,
.crop-actions .btn-primary {
  flex: 1;
  width: auto;
}
@media (min-width: 700px) {
  .crop-modal { align-items: center; }
  .crop-sheet { border-radius: 20px; }
}
@media (max-width: 640px) {
  .queue-item { flex-wrap: wrap; }
  .queue-info { flex: 1 1 140px; }
  .queue-actions { width: 100%; }
  .queue-actions .btn-ghost { flex: 1; }
}
