*, *::before, *::after { box-sizing: border-box; }
:root {
  --bg: #0f0f0f;
  --surface: #191919;
  --surface-2: #222;
  --border: #2d2d2d;
  --text: #f2f0ed;
  --muted: #9c9995;
  --brand-blue: #2d2e80;
  --brand-blue-hover: #3c3da0;
  --green: #5eb986;
  --red: #e16b6b;
  --amber: #e6ae59;
  --radius: 14px;
}
html { color-scheme: dark; }
@font-face {
  font-family: "Patrick Hand";
  src: url("/fonts/free/PatrickHand-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "Kalam";
  src: url("/fonts/free/Kalam-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("/fonts/free/Caveat-Variable.ttf") format("truetype");
  font-display: swap;
}
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding-bottom: 64px; }
.topbar { height: 84px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; overflow: hidden; border-radius: 11px; background: #fff; }
.brand-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 12px; }
.user-info { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.user-info img { width: 30px; height: 30px; border-radius: 50%; }
.user-info a { color: var(--muted); text-decoration: none; margin-left: 4px; }
.user-info a:hover { color: var(--text); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.login-wrap { min-height: calc(100vh - 180px); display: grid; place-items: center; }
.login-panel { width: min(500px, 100%); padding: 44px; }
.login-panel h1 { margin: 8px 0 12px; font-size: clamp(28px, 5vw, 42px); line-height: 1.08; letter-spacing: -.04em; }
.login-panel > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; margin: 0 0 28px; }
.google-btn { display: inline-flex; background: #fff; color: #272727; text-decoration: none; padding: 11px 18px; border-radius: 9px; font-size: 14px; font-weight: 700; }
.workspace { display: grid; grid-template-columns: minmax(360px, .92fr) minmax(430px, 1.08fr); gap: 24px; align-items: start; }
.form-panel { padding: 30px; }
.section-heading, .history-heading, .preview-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.eyebrow { margin: 0; color: var(--brand-blue-hover); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2 { margin: 6px 0 0; letter-spacing: -.03em; }
h1 { font-size: 25px; }
h2 { font-size: 19px; }
.mode-badge { color: var(--amber); border: 1px solid rgba(230,174,89,.35); background: rgba(230,174,89,.08); border-radius: 99px; padding: 5px 9px; font-size: 11px; font-weight: 700; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 26px; }
label { display: block; margin-top: 16px; color: var(--muted); font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; margin-top: 7px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: #111; color: var(--text); padding: 11px 12px; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 180px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(45,46,128,.18); }
.field-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 7px; color: #777; font-size: 10px; font-weight: 500; }
.print-options { display: flex; align-items: end; gap: 20px; }
.font-size-label { flex: 1; }
.paper-source-label { width: 130px; }
.copies-label { width: 105px; }
.font-size-control { min-height: 42px; display: flex; align-items: center; gap: 12px; }
.font-size-control input[type="range"] { flex: 1; margin: 7px 0 0; padding: 0; accent-color: var(--brand-blue); box-shadow: none; }
.font-size-control output { width: 48px; color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.primary-btn, .secondary-btn { border: 0; border-radius: 9px; padding: 12px 16px; cursor: pointer; font-weight: 750; }
.primary-btn { color: #fff; background: var(--brand-blue); }
.primary-btn:hover:not(:disabled) { background: var(--brand-blue-hover); }
.secondary-btn { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); }
.secondary-btn:hover { border-color: #555; }
button:disabled { opacity: .5; cursor: wait; }
.preview-column { padding: 12px 4px 0; }
.preview-heading { align-items: end; margin: 0 2px 18px; }
.preview-heading > span, .history-heading > span { color: var(--muted); font-size: 11px; }
.postcard { position: relative; aspect-ratio: 6 / 4; overflow: hidden; background: #fff url("/postcard-guide.png") center / 100% 100% no-repeat; color: #342a2f; border-radius: 5px; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.postcard-message { position: absolute; white-space: pre-wrap; line-height: 1.38; font-family: "Patrick Hand", cursive; overflow: hidden; transform-origin: center; }
.postcard-return-address { position: absolute; left: 53.15%; top: 44.5%; width: 40.9%; height: 32%; color: #202020; font-family: "Patrick Hand", cursive; line-height: 1.42; overflow: hidden; }
.postcard-return-address span { display: block; }
.preview-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 17px 2px 0; }
.history-panel, .admin-panel { margin-top: 24px; padding: 26px 30px; }
.history-heading { align-items: center; }
.text-btn { border: 0; background: transparent; color: var(--brand-blue-hover); cursor: pointer; padding: 5px; font-size: 12px; font-weight: 700; }
.history-list { margin-top: 18px; }
.history-row { min-height: 58px; display: grid; grid-template-columns: minmax(220px, 1fr) auto 64px; align-items: center; gap: 18px; border-top: 1px solid var(--border); }
.history-row:first-child { border-top: 0; }
.history-main strong, .history-main small { display: block; }
.history-main strong { font-size: 14px; }
.history-main strong span { color: var(--brand-blue-hover); }
.history-main small { color: var(--muted); margin-top: 5px; font-size: 11px; }
.status { min-width: 60px; text-align: center; border-radius: 99px; padding: 4px 8px; font-size: 10px; font-weight: 800; }
.status.submitted { color: var(--green); background: rgba(94,185,134,.1); }
.status.mock_submitted { color: var(--amber); background: rgba(230,174,89,.1); }
.status.failed { color: var(--red); background: rgba(225,107,107,.1); }
.status.preparing { color: var(--muted); background: rgba(255,255,255,.05); }
.empty-state { color: var(--muted); padding: 22px 0 4px; margin: 0; font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 14px; margin-top: 12px; }
.settings-grid .secondary-btn { align-self: end; margin-top: 16px; }
.notice { margin-top: 16px; border: 1px solid; border-radius: 9px; padding: 11px 13px; font-size: 12px; line-height: 1.4; }
.notice.success { color: var(--green); border-color: rgba(94,185,134,.45); background: rgba(94,185,134,.07); }
.notice.error { color: var(--red); border-color: rgba(225,107,107,.45); background: rgba(225,107,107,.07); }
.error-text { color: var(--red); }
.hidden { display: none !important; }
@media (max-width: 880px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-column { order: -1; }
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .shell { width: min(100% - 20px, 1180px); }
  .topbar { height: 70px; }
  .user-info span { display: none; }
  .form-panel, .history-panel, .admin-panel, .login-panel { padding: 22px; }
  .field-grid, .button-row, .settings-grid { grid-template-columns: 1fr; }
  .history-row { grid-template-columns: 1fr auto; padding: 11px 0; }
  .history-row .reprint-btn { grid-column: 2; }
  .field-meta { display: block; }
  .field-meta span { display: block; margin-top: 4px; }
  .print-options { align-items: stretch; flex-wrap: wrap; }
  .font-size-label { flex-basis: 100%; }
  .paper-source-label { flex: 1; }
}
