:root {
  color-scheme: light;
  --ink: #1d1b18;
  --muted: #6f675d;
  --paper: #f9f6ef;
  --panel: #fffdf8;
  --rule: #ddd4c6;
  --accent: #176f6b;
  --accent-strong: #0c4f4c;
  --warn: #9d3d26;
  --shadow: 0 20px 50px rgba(35, 28, 18, 0.11);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(120deg, #f7f2e8 0%, #edf5f4 58%, #f6eee7 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #ece6dc;
  color: var(--ink);
}

button.secondary:hover {
  background: #e0d6c8;
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(460px, 1fr) minmax(260px, 340px);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.panel,
.toolbar {
  background: rgba(255, 253, 248, 0.88);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.brand h1,
.crop-head h2 {
  margin: 4px 0 0;
  font-size: 25px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 156px;
  margin: 18px 0;
  border: 1.5px dashed #b9ab98;
  border-radius: 8px;
  background: #fbf8f0;
  text-align: center;
  cursor: pointer;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #eaf5f3;
}

.drop-zone input {
  display: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 30px;
  line-height: 1;
}

.drop-zone small,
.hint,
.status-strip {
  color: var(--muted);
  font-size: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input[type="date"],
input[type="text"] {
  min-height: 38px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 0 10px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.status-strip span {
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 4px 8px;
  background: white;
}

.thumbs {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 360px);
  overflow: auto;
}

.thumb {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: white;
  padding: 7px;
}

.thumb.drag-over {
  outline: 2px solid var(--accent);
}

.thumb img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
}

.thumb strong,
.thumb small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb strong {
  font-size: 13px;
}

.thumb small {
  color: var(--muted);
  font-size: 11px;
}

.thumb button {
  width: 38px;
  padding: 0;
}

.stage {
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--rule);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border-radius: 0;
  background: white;
  color: var(--ink);
}

.segmented button.active {
  background: var(--ink);
  color: white;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.paper-wrap {
  position: relative;
  width: min(100%, 980px);
  margin: 0 auto;
  aspect-ratio: 1748 / 1181;
}

#preview-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: white;
  box-shadow: var(--shadow);
}

.safe-line {
  pointer-events: none;
  position: absolute;
  inset: 2.25%;
  border: 1px dashed rgba(157, 61, 38, 0.7);
}

.hint {
  text-align: center;
}

.layout-list {
  display: grid;
  gap: 10px;
}

.layout-card {
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  background: white;
  color: var(--ink);
  text-align: left;
  padding: 12px;
}

.layout-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.layout-card strong {
  display: block;
  margin-bottom: 4px;
}

.layout-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.crop-dialog {
  width: min(900px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.crop-dialog::backdrop {
  background: rgba(20, 18, 15, 0.58);
}

.crop-panel {
  display: grid;
  gap: 14px;
  border-radius: 8px;
  background: var(--panel);
  padding: 18px;
}

.crop-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.icon-button {
  width: 36px;
  padding: 0;
  background: #ece6dc;
  color: var(--ink);
}

#crop-canvas {
  width: 100%;
  max-height: 62vh;
  background: #111;
  border-radius: 6px;
  touch-action: none;
}

.crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 1080px) {
  .app {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .thumbs {
    max-height: none;
  }
}
