/* The editing screen: form beside a live preview. */

.editor {
  display: grid;
  grid-template-columns: minmax(20rem, 32rem) 1fr;
  gap: 1rem;
  padding: 1rem;
  align-items: start;
  min-width: 0;
}

.editor .form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.editor .preview {
  position: sticky;
  top: 3.5rem;
  max-height: calc(100vh - 4rem);
  overflow: auto;
  padding: 0.25in 0;
}

/* Shrink the sheet on smaller screens so the whole width stays visible. */
@media (max-width: 1500px) {
  .editor .preview .sheet { zoom: 0.75; }
}

@media (max-width: 64rem) {
  .editor { grid-template-columns: 1fr; }
  .editor .preview { position: static; max-height: none; }
  .editor .preview .sheet { zoom: 0.6; }
}

@media (max-width: 40rem) {
  .editor { padding: 0.5rem; gap: 0.5rem; }
  .editor .preview .sheet { zoom: 0.42; }
}

.form-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #555;
  margin: 0.6rem 0 0;
}

.loading {
  padding: 2rem;
  text-align: center;
}

.save-status {
  font-size: 0.85rem;
  color: #555;
}

.save-status.failed {
  color: #b00020;
  font-weight: 600;
}

/* ---- Cards ---- */

.card {
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.card > summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  list-style: none;
}

.card > summary::-webkit-details-marker { display: none; }

.card > summary::before {
  content: "▸";
  font-size: 0.8rem;
  color: #777;
}

.card[open] > summary::before { content: "▾"; }

.card-kind {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  min-width: 6.5rem;
}

.card-title {
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-note {
  font-size: 0.75rem;
  color: #666;
}

.card-body {
  padding: 0.25rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-top: 1px solid #eee;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* ---- Fields ---- */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.field-label {
  font-size: 0.75rem;
  color: #444;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.field-label small {
  color: #888;
  font-weight: 400;
}

.field-label .counter {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.field-label .counter.over {
  color: #b00020;
  font-weight: 700;
}

.overflow-banner {
  margin: 0;
  padding: 0.5rem 1rem;
  background: #b00020;
  color: white;
  font-size: 0.9rem;
}

.field-number { flex: 0 0 auto; max-width: 8rem; }

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

.field-row > input[type="text"] { flex: 1; }

.reminder-row .when { flex: 0 0 8rem; }

.editor input[type="text"],
.editor input[type="date"],
.editor input[type="number"],
.editor textarea,
.editor select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: white;
  width: 100%;
  box-sizing: border-box;
}

.editor textarea { resize: vertical; }
.editor textarea.notes { min-height: 10rem; font-size: 0.9rem; line-height: 1.4; }
.notes-card .card-actions { align-items: center; }
.upload-row { align-items: center; }
.upload { display: inline-flex; flex-direction: column; gap: 0.2rem; font-size: 0.75rem; color: #444; }
.upload input[type="file"] { font-size: 0.85rem; }
.upload-message { color: #1a7f37; }

.editor button {
  font: inherit;
  padding: 0.35rem 0.7rem;
  border: 1px solid #999;
  border-radius: 4px;
  background: #f5f5f5;
  cursor: pointer;
}

.editor button:disabled { opacity: 0.5; cursor: not-allowed; }
.editor button.danger { color: #b00020; border-color: #b00020; background: white; }
.editor button.add { align-self: flex-start; }
.editor button.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--ui-accent);
  font-size: 0.75rem;
  text-decoration: underline;
}

.hint {
  font-size: 0.75rem;
  color: #777;
  margin: 0;
}

.warning {
  font-size: 0.85rem;
  color: #b00020;
  border: 1px solid #b00020;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  margin: 0;
}

.card-actions .hint { flex: 1; align-self: center; }

.toolbar .toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.choice {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr));
  gap: 0.4rem;
}

.thumb {
  aspect-ratio: 1;
  padding: 0.3rem !important;
  background: white !important;
  border: 2px solid #ccc !important;
  border-radius: 6px !important;
}

.thumb.selected {
  border-color: var(--ui-accent) !important;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.25);
}

.thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.3rem 0.15rem 0.55rem;
  border: 1px solid #999;
  border-radius: 999px;
  font-size: 0.85rem;
}

.chip.suggestion { border-style: dashed; }
.suggestions { display: flex; flex-direction: column; gap: 0.3rem; }

.chip button {
  border: none;
  background: none;
  padding: 0 0.25rem;
  line-height: 1;
  font-size: 1rem;
}

@media print {
  .editor { display: block; padding: 0; }
  .editor .form, .loading, .overflow-banner { display: none; }
  .editor .preview { position: static; max-height: none; overflow: visible; padding: 0; }
  .editor .preview .sheet { zoom: 1; }
}
