:root {
  --paper: #f5f2ee;
  --slot-bg: #e8e4de;
  --border: #b5afa6;
  --red: #c0392b;
  --red-light: #fdf0ee;
  --red-mid: #dea49e;
  --blue: #1a5fa8;
  --blue-light: #edf4fd;
  --blue-mid: #90b4d8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
nav-bar {
  width: 8.5in;
}

body {
  background: #2c2c2c;
  font-family: "Georgia", serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  gap: 1.5rem;
}

.ui-bar {
  display: flex;
  width: 8.5in;
  align-items: center;
  gap: 1rem;
  color: #ccc;
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  flex-wrap: wrap;
  justify-content: center;
}

.ui-bar h1 {
  font-size: 0.85rem;
  font-weight: normal;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #aaa;
}

.btn {
  border: none;
  padding: 0.5rem 1.4rem;
  font-family: "Courier New", monospace;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
  color: white;
}
.btn:hover {
  opacity: 0.8;
}
.btn-print {
  background: #2e6da4;
}
.btn-exit-preview {
  background: #2e6da4;
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 1000;
}
body:not(.print-preview) .btn-exit-preview {
  display: none;
}
.btn-clear {
  background: transparent;
  color: #888;
  border: 1px solid #555;
}
.btn-clear:hover {
  color: #ccc;
  border-color: #888;
  opacity: 1;
}

/* ── SHEET ── */
.sheet {
  width: 8.5in;
  height: 11in;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  padding: 0.35in;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  position: relative;
}

/* ── SHEET HEADER (title + date) ── */
.sheet-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.1in;
  margin-bottom: 0.12in;
  border-bottom: 1px solid #d0cbc4;
  flex-shrink: 0;
}

.sheet-title {
  flex: 1;
  border: none;
  background: transparent;
  font-family: "Georgia", serif;
  font-size: 1.05rem;
  font-weight: bold;
  color: #222;
  outline: none;
  letter-spacing: 0.02em;
  padding: 2px 0;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.15s;
  min-width: 0;
}
.sheet-title::placeholder {
  color: #bbb;
  font-style: italic;
  font-weight: normal;
}
.sheet-title:focus {
  border-bottom-color: #aaa;
}

.sheet-date {
  flex-shrink: 0;
  border: none;
  background: transparent;
  font-family: "Courier New", monospace;
  font-size: 1rem;
  color: black;
  letter-spacing: 0.06em;
  outline: none;
  padding: 2px 0;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.15s;
  cursor: pointer;
}
.sheet-date:focus {
  border-bottom-color: #aaa;
}
/* Style the date input to match the sheet aesthetic */
.sheet-date::-webkit-calendar-picker-indicator {
  opacity: 0.4;
  cursor: pointer;
}

/* ── COLUMN HEADER ROW ── */
.col-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25in;
  flex-shrink: 0;
  margin-bottom: 0.1in;
}

.ear-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding-bottom: 0.09in;
  font-family: "Courier New", monospace;
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.ear-header.right {
  color: var(--red);
  border-bottom: 2.5px solid var(--red);
}
.ear-header.left {
  color: var(--blue);
  border-bottom: 2.5px solid var(--blue);
}

.ear-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ear-header.right .ear-dot {
  background: var(--red);
}
.ear-header.left .ear-dot {
  background: var(--blue);
}

/* ── IMAGE ROWS ── */
.image-rows {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2in;
  min-height: 0;
}

.image-row {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25in;
  min-height: 0;
}

/* ── CELL (slot + caption) ── */
.cell {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

/* ── SLOT ── */
.slot {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color 0.18s,
    background 0.18s,
    box-shadow 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
}

/* Right Ear — red */
.slot.ear-right {
  border: 2px dashed var(--red-mid);
  background: var(--red-light);
}
.slot.ear-right:hover {
  border-color: var(--red);
  background: #f8e0dc;
}
.slot.ear-right.has-image {
  border: 2.5px solid var(--red);
  background: transparent;
}
.slot.ear-right.selected {
  border: 2.5px solid var(--red);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.25);
}
.slot.ear-right.dragover {
  border-color: var(--red);
  background: #f8e0dc;
}

/* Left Ear — blue */
.slot.ear-left {
  border: 2px dashed var(--blue-mid);
  background: var(--blue-light);
}
.slot.ear-left:hover {
  border-color: var(--blue);
  background: #d6e8f8;
}
.slot.ear-left.has-image {
  border: 2.5px solid var(--blue);
  background: transparent;
}
.slot.ear-left.selected {
  border: 2.5px solid var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 95, 168, 0.25);
}
.slot.ear-left.dragover {
  border-color: var(--blue);
  background: #d6e8f8;
}

/* Image */
.slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  user-select: none;
}
.slot.cover img {
  object-fit: cover;
}

/* Placeholder label */
.slot-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  pointer-events: none;
  padding: 1rem;
}
.slot.has-image .slot-label {
  display: none;
}
.slot-label svg {
  opacity: 0.4;
}
.slot-label span {
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: "Courier New", monospace;
  line-height: 1.6;
}

/* Paste hint badge */
.paste-hint {
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-family: "Courier New", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  border-radius: 2px;
}
.slot.ear-right .paste-hint {
  background: var(--red);
}
.slot.ear-left .paste-hint {
  background: var(--blue);
}
.slot.selected .paste-hint {
  opacity: 1;
}

/* Remove button */
.slot-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 13px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.slot.has-image:hover .slot-remove {
  opacity: 1;
}

/* Fit toggle */
.fit-toggle {
  position: absolute;
  bottom: 6px;
  right: 6px;
  font-family: "Courier New", monospace;
  font-size: 0.52rem;
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.45);
  color: #eee;
  border: none;
  padding: 3px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
  text-transform: uppercase;
}
.slot.has-image:hover .fit-toggle {
  opacity: 1;
}

/* ── CAPTION ── */
.caption-wrap {
  flex-shrink: 0;
  padding: 5px 2px 0;
}

.caption {
  width: 100%;
  border: none;
  border-bottom: 1px solid #ccc;
  background: transparent;
  font-family: "Georgia", serif;
  font-size: 1.2rem;
  color: #333;
  padding: 3px 4px;
  outline: none;
  text-align: center;
  letter-spacing: 0.03em;
  transition: border-color 0.15s;
}
.caption::placeholder {
  color: #bbb;
  font-style: italic;
}
.caption.ear-right:focus {
  border-color: var(--red);
}
.caption.ear-left:focus {
  border-color: var(--blue);
}

/* ── PRINT ── */
input[type="file"] {
  display: none;
}

@media print {
  body {
    background: none;
    padding: 0;
    margin: 0;
  }
  .ui-bar {
    display: none;
  }
  .sheet {
    box-shadow: none;
  }
  .slot-remove,
  .fit-toggle,
  .paste-hint {
    display: none !important;
  }
  .slot:not(.has-image) {
    visibility: hidden !important;
    border: none !important;
  }
  .slot.has-image.ear-right {
    border: 1.5px solid var(--red) !important;
  }
  .slot.has-image.ear-left {
    border: 1.5px solid var(--blue) !important;
  }
  .caption {
    border-bottom-color: #bbb;
  }
  input[type="text"]:placeholder-shown {
    visibility: hidden;
  }
}

.print-preview body,
body.print-preview {
  background: none;
  padding: 0;
  margin: 0;
}
.print-preview .ui-bar {
  display: none;
}
.print-preview .sheet {
  box-shadow: none;
}
.print-preview .slot-remove,
.print-preview .fit-toggle,
.print-preview .paste-hint {
  display: none !important;
}
.print-preview .slot:not(.has-image) {
  visibility: hidden !important;
  border: none !important;
}
.print-preview .slot.has-image.ear-right {
  border: 1.5px solid var(--red) !important;
}
.print-preview .slot.has-image.ear-left {
  border: 1.5px solid var(--blue) !important;
}
.print-preview .caption {
  border-bottom-color: #bbb;
}
.print-preview input[type="text"]:placeholder-shown {
  visibility: hidden;
}

@page {
  size: 8.5in 11in;
  margin: 0;
}
