/* app.css — the screen UI around the letter. None of this prints.
 * Letter geometry lives in letter.css and is never touched here. */

:root { color-scheme: light; }

body { margin: 0; font-family: 'Roboto', system-ui, sans-serif; }

.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

/* ---- Control panel ------------------------------------------------ */

.app-panel {
  position: sticky;
  top: 0;
  flex: 0 0 320px;
  width: 320px;
  height: 100vh;
  overflow-y: auto;
  padding: 20px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
  box-sizing: border-box;
}

.app-panel__head { margin-bottom: 18px; }

.app-form__title {
  margin: 20px 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}
.app-form__title:first-child { margin-top: 0; }

.app-field { display: block; margin-bottom: 10px; }
.app-field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #475569;
}
.app-field input,
.app-field select {
  width: 100%;
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
  color: #0f172a;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  box-sizing: border-box;
}
.app-field input:focus,
.app-field select:focus {
  outline: 2px solid #00B050;
  outline-offset: -1px;
  border-color: #00B050;
}

.app-field__row { display: flex; gap: 10px; }
.app-field__row .app-field { flex: 1; min-width: 0; }

/* ---- Buttons ------------------------------------------------------ */

.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}
.app-btn--primary { background: #00B050; color: #fff; }
.app-btn--primary:hover { background: #009845; }
.app-btn--ghost { background: #fff; color: #0f172a; border-color: #cbd5e1; }
.app-btn--ghost:hover { background: #f8fafc; }
.app-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.app-hint { margin: 6px 0 0; font-size: 11px; color: #64748b; }

/* ---- Alerts ------------------------------------------------------- */

.app-alert {
  margin: 12px 0 0;
  padding: 9px 11px;
  font-size: 12px;
  border-radius: 6px;
}
.app-alert--warn { background: #fef3c7; color: #92400e; }
.app-alert--error { background: #fee2e2; color: #991b1b; }
.app-alert--info { background: #e0f2fe; color: #075985; }
.app-alert ul { margin: 4px 0 0; padding-left: 16px; }

/* ---- Preview ------------------------------------------------------ */

.app-main { flex: 1; min-width: 0; }

.app-main__bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.app-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 20px;
}

/* Each letter is a real 8.5x11in box; on screen it gets a page shadow. */
.app-preview .letter {
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 8px 24px rgba(15, 23, 42, 0.08);
}
.app-preview .letter--overflow {
  outline: 2px solid #dc2626;
  outline-offset: 2px;
}

/* Screen only: in print the page is the paper, never the window. */
@media screen and (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .app-panel { position: static; width: 100%; flex: none; height: auto; border-right: 0; border-bottom: 1px solid #e2e8f0; }
  .app-preview { padding: 12px; }
  /* Scale the page down to fit a phone without touching its geometry. */
  .app-preview .letter { transform: scale(0.42); transform-origin: top center; margin-bottom: -460pt; }
}

.app-stack { display: flex; flex-direction: column; gap: 8px; }
.app-stack .app-btn { width: 100%; }
.app-hint code {
  padding: 1px 3px;
  font-size: 10px;
  background: #f1f5f9;
  border-radius: 3px;
}

.app-main__actions { display: flex; gap: 8px; }
.app-main__hint {
  margin: 0;
  padding: 8px 20px;
  font-size: 11px;
  line-height: 1.5;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
@media screen and (max-width: 900px) {
  .app-main__bar { flex-wrap: wrap; }
  .app-main__actions { width: 100%; }
  .app-main__actions .app-btn { flex: 1; }
}

/* While building the one-click PDF the letters must be captured at their
 * true 8.5x11in size, never at the phone-width preview scale. */
.app-preview--exporting .letter {
  transform: none !important;
  margin-bottom: 0 !important;
}
/* The red "runs past one page" marker is a screen aid, never part of the
 * downloaded PDF. */
.app-preview--exporting .letter--overflow { outline: none !important; }

/* [hidden] must win over the button's display rule even when Tailwind's
 * preflight has not loaded (offline). */
.app-btn[hidden] { display: none; }

/* A label cannot be :disabled, so the file-chooser is turned off by class. */
.app-btn--disabled {
  opacity: 0.5;
  pointer-events: none;
}
