:root {
  color-scheme: light;
  --ink: #14213d;
  --muted: #5c6275;
  --line: #d8dcea;
  --paper: #fffaf0;
  --panel: #ffffff;
  --accent: #ff3d7f;
  --accent-dark: #0a7fd9;
  --teal: #00b8a9;
  --sun: #ffd23f;
  --coral: #ff6b4a;
  --lime: #73d13d;
  --warn: #ffb703;
  --shadow: rgba(20, 33, 61, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(255, 61, 127, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(10, 127, 217, 0.1) 1px, transparent 1px),
    linear-gradient(135deg, #fff7d6 0%, #e8fbff 38%, #fff0f7 74%, #efffe9 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

button,
input,
textarea {
  font: inherit;
}

.home {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
}

.home-hero {
  position: relative;
  width: min(1120px, 100%);
  min-height: min(760px, calc(100vh - 56px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.84fr);
  gap: 36px;
  align-items: center;
}

.home-hero::before,
.home-hero::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.home-hero::before {
  inset: 5% auto auto 48%;
  width: min(44vw, 520px);
  aspect-ratio: 1;
  border: 18px solid rgba(255, 210, 63, 0.72);
  border-radius: 28px;
  transform: rotate(14deg);
}

.home-hero::after {
  right: -10px;
  bottom: 42px;
  width: 300px;
  height: 120px;
  background:
    linear-gradient(90deg, var(--coral), var(--coral)) 0 0 / 100% 16px no-repeat,
    linear-gradient(90deg, var(--teal), var(--teal)) 38px 46px / 78% 16px no-repeat,
    linear-gradient(90deg, var(--accent), var(--accent)) 88px 92px / 60% 16px no-repeat;
  border-radius: 999px;
  transform: rotate(-8deg);
}

.home-copy {
  position: relative;
  z-index: 1;
}

.home-logo {
  width: min(560px, 100%);
  height: auto;
  display: block;
  margin: 0 0 12px;
  filter: drop-shadow(0 18px 22px rgba(20, 33, 61, 0.18));
}

.brand,
.brand-link {
  margin: 0 0 16px;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 0.9;
  letter-spacing: 0;
  text-wrap: balance;
}

.lede {
  max-width: 530px;
  color: #30384f;
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.5;
  font-weight: 720;
}

.primary,
button {
  border: 0;
  border-radius: 6px;
  padding: 12px 17px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  cursor: pointer;
  font-weight: 750;
  box-shadow: 0 10px 22px rgba(255, 61, 127, 0.22);
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

button:hover {
  background: linear-gradient(135deg, var(--accent-dark), var(--teal));
}

a.primary:hover {
  background: linear-gradient(135deg, var(--accent-dark), var(--teal));
}

.cta-wrap {
  position: relative;
  display: inline-block;
  margin-top: 22px;
}

.cta-wrap::before,
.cta-wrap::after {
  content: "♥";
  position: absolute;
  pointer-events: none;
  color: #ff1744;
  font-size: 30px;
  line-height: 1;
  text-shadow:
    -64px -6px 0 #ff5fa2,
    -36px -34px 0 #ff1744,
    28px -38px 0 #ff7a00,
    72px -12px 0 #ff1744,
    42px 42px 0 #ff5fa2;
  filter: drop-shadow(0 0 12px rgba(255, 23, 68, 0.55));
  opacity: 0.92;
}

.cta-wrap::before {
  left: 22px;
  top: -10px;
  transform: rotate(-13deg);
}

.cta-wrap::after {
  right: 18px;
  bottom: -16px;
  color: #ff5fa2;
  font-size: 24px;
  text-shadow:
    -38px 32px 0 #ff1744,
    18px 40px 0 #ff7a00,
    62px 8px 0 #ff1744;
  transform: rotate(12deg);
}

.home-cta {
  position: relative;
  z-index: 1;
  min-height: 74px;
  padding: 20px 34px;
  border: 4px solid #ffffff;
  border-radius: 8px;
  color: #ffffff;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.38), transparent 28%),
    linear-gradient(135deg, #ff1744 0%, #ff3131 48%, #c90020 100%);
  box-shadow:
    0 0 0 7px rgba(255, 23, 68, 0.16),
    0 0 34px rgba(255, 23, 68, 0.78),
    0 18px 38px rgba(201, 0, 32, 0.36);
  font-size: 22px;
  font-weight: 950;
}

.hero-postcard {
  position: relative;
  z-index: 1;
  min-height: 470px;
  padding: 36px;
  border: 8px solid #fff;
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255, 210, 63, 0.9), transparent 36%),
    linear-gradient(150deg, #ffffff 0%, #fff8e8 100%);
  box-shadow: 0 28px 70px var(--shadow);
  transform: rotate(5deg);
}

.hero-postcard::before,
.hero-postcard::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.hero-postcard::before {
  left: -26px;
  top: 52px;
  width: 120px;
  height: 18px;
  background: var(--teal);
  transform: rotate(-18deg);
}

.hero-postcard::after {
  right: 26px;
  bottom: -18px;
  width: 170px;
  height: 18px;
  background: var(--accent);
  transform: rotate(-7deg);
}

.hero-stamp {
  position: absolute;
  right: 30px;
  top: 28px;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 8px dashed #ff3d7f;
  color: #ffffff;
  background: var(--teal);
  font-weight: 950;
}

.hero-photo {
  width: 70%;
  aspect-ratio: 1.16;
  border: 7px solid #fff;
  border-radius: 8px;
  background:
    radial-gradient(circle at 70% 28%, #ffd23f 0 13%, transparent 14%),
    linear-gradient(160deg, #0a7fd9 0 50%, #00b8a9 51% 100%);
  box-shadow: 0 15px 30px rgba(20, 33, 61, 0.18);
  transform: rotate(-7deg);
}

.hero-photo span {
  display: block;
  width: 58%;
  height: 44%;
  margin: 33% 0 0 10%;
  border-radius: 60% 60% 8px 8px;
  background: linear-gradient(135deg, #73d13d, #009f87);
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-lines {
  position: absolute;
  right: 34px;
  top: 150px;
  display: grid;
  gap: 18px;
}

.hero-lines i {
  display: block;
  width: 150px;
  height: 8px;
  border-radius: 999px;
  background: #0a7fd9;
}

.hero-lines i:nth-child(2) {
  width: 120px;
  background: #ff6b4a;
}

.hero-lines i:nth-child(3) {
  width: 165px;
  background: #00b8a9;
}

.hero-postcard strong {
  position: absolute;
  left: 32px;
  right: 32px;
  bottom: 36px;
  color: #ff3d7f;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
  text-wrap: balance;
}

.editor-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  gap: 28px;
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(20, 33, 61, 0.08);
}

.editor {
  padding: 22px;
  overflow: auto;
}

.minimal-editor {
  display: grid;
  gap: 24px;
  margin-top: 22px;
}

.simple-field {
  display: grid;
  gap: 10px;
}

.simple-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  text-transform: lowercase;
}

.simple-label button {
  min-width: 0;
  padding: 9px 12px;
  white-space: nowrap;
}

.simple-field textarea {
  min-height: 120px;
}

.simple-field textarea[name="address_text"] {
  min-height: 140px;
}

.quiet-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hidden-field,
.hidden-controls {
  display: none;
}

.progress {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 18px 0 24px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.progress i {
  height: 2px;
  background: var(--line);
}

.progress span {
  white-space: nowrap;
}

.progress .active {
  color: var(--accent-dark);
}

.step {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.step h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.voice-status {
  margin: 8px 0 14px;
  padding: 10px 12px;
  border: 1px solid #cddbd5;
  border-radius: 6px;
  color: var(--accent-dark);
  background: #f3faf6;
  font-size: 14px;
  font-weight: 700;
}

.agent-stream {
  min-height: 48px;
  margin: 0 0 14px;
  padding: 12px;
  border-left: 3px solid var(--warn);
  color: #2f3432;
  background: #fff8e8;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.realtime-agent {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}

.voice-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.voice-card:first-of-type {
  border-top: 0;
}

.voice-card textarea,
.voice-card input {
  grid-column: 1 / -1;
  margin: 0;
}

.ask {
  margin: 0;
  font-weight: 850;
}

.hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.mic {
  min-width: 82px;
  background: #2f3432;
}

.mic.recording {
  background: #b43d2f;
}

.mic:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.transcript {
  margin-top: 18px;
}

.debug-panel {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.debug-panel summary {
  cursor: pointer;
  font-weight: 800;
}

.debug-actions {
  margin: 10px 0;
}

.debug-panel pre {
  max-height: 260px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111;
  color: #d9f7e8;
  white-space: pre-wrap;
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  color: #3f4442;
  font-size: 14px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

.file-input input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.camera-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.camera-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111;
  object-fit: cover;
}

.file-input span {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px dashed #aab3af;
  border-radius: 6px;
  color: var(--accent-dark);
  background: #f7faf8;
}

.grid {
  display: grid;
  gap: 10px;
}

.two {
  grid-template-columns: 1fr 120px;
}

.three {
  grid-template-columns: 1fr 80px 110px;
}

.send-step p {
  color: var(--muted);
}

.send-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.subtle-link a {
  color: var(--accent-dark);
  font-weight: 850;
}

.preview-wrap {
  position: sticky;
  top: 24px;
  height: calc(100vh - 48px);
  display: grid;
  grid-template-rows: auto 1fr 1fr;
  gap: 14px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.postcard {
  position: relative;
  min-height: 0;
  aspect-ratio: 6 / 4;
  width: min(100%, 850px);
  border: 1px solid #cdd5d1;
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(32, 33, 36, 0.12);
  overflow: hidden;
}

.front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.front.generating img,
.front.generating .empty-image {
  filter: saturate(0.78) brightness(0.72);
}

.front.generating::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  top: calc(50% - 30px);
  width: 56px;
  height: 56px;
  border: 6px solid rgba(255, 255, 255, 0.42);
  border-top-color: #ffffff;
  border-right-color: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(255, 61, 127, 0.48);
  transform: translate(-50%, -50%);
  animation: postcard-spin 0.82s linear infinite;
}

.front.generating::after {
  content: "Generating postcard...";
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 84px;
  color: #fff;
  background:
    radial-gradient(circle at center, rgba(255, 61, 127, 0.34), transparent 34%),
    rgba(20, 33, 61, 0.62);
  font-size: clamp(18px, 2.6vw, 30px);
  font-weight: 950;
  text-align: center;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
}

@keyframes postcard-spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .front.generating::before {
    animation: none;
  }
}

.empty-image {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(15, 139, 112, 0.1), rgba(242, 184, 75, 0.18)),
    var(--paper);
}

.back {
  display: grid;
  grid-template-columns: 1fr 1px 0.82fr;
  gap: 28px;
  padding: 34px;
}

.message {
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: clamp(15px, 1.8vw, 22px);
}

.divider {
  background: #c9d1cd;
}

address {
  align-self: center;
  font-style: normal;
  line-height: 1.6;
  color: #2f3432;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .home {
    place-items: start center;
  }

  .home-hero {
    min-height: auto;
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .home-hero::before {
    inset: 14% -70px auto auto;
    width: 300px;
    border-width: 12px;
  }

  .home-hero::after {
    right: -110px;
    bottom: 28%;
  }

  .hero-postcard {
    min-height: 390px;
    transform: rotate(2deg);
  }

  .editor-shell {
    grid-template-columns: 1fr;
  }

  .preview-wrap {
    position: static;
    height: auto;
  }
}

@media (max-width: 560px) {
  .editor-shell,
  .home {
    padding: 12px;
  }

  .editor {
    padding: 18px;
  }

  .home-logo {
    width: min(100%, 440px);
  }

  h1 {
    font-size: clamp(38px, 13vw, 56px);
  }

  .home-cta {
    width: 100%;
  }

  .hero-postcard {
    min-height: 320px;
    padding: 22px;
    border-width: 6px;
  }

  .hero-stamp {
    right: 18px;
    top: 18px;
    width: 72px;
    height: 72px;
    border-width: 6px;
  }

  .hero-photo {
    width: 72%;
    border-width: 5px;
  }

  .hero-lines {
    right: 20px;
    top: 114px;
    gap: 13px;
  }

  .hero-lines i {
    width: 105px;
    height: 7px;
  }

  .hero-lines i:nth-child(2) {
    width: 86px;
  }

  .hero-lines i:nth-child(3) {
    width: 115px;
  }

  .hero-postcard strong {
    left: 22px;
    right: 22px;
    bottom: 26px;
  }

  .two,
  .three {
    grid-template-columns: 1fr;
  }

  .back {
    gap: 14px;
    padding: 20px;
  }
}

/* ===== Admin page (/a) ===== */
.admin-shell {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.admin-header {
  display: flex;
  align-items: baseline;
  gap: 24px;
  margin-bottom: 20px;
}
.admin-header h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
}
.admin-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 16px;
}
.admin-empty {
  color: var(--muted);
  padding: 40px 0;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e9e7;
  vertical-align: top;
}
.admin-table th {
  font-weight: 700;
  color: var(--muted);
  background: #f5f7f6;
  position: sticky;
  top: 0;
}
.admin-thumb img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.admin-id code {
  font-size: 12px;
  color: var(--muted);
}
.admin-msg,
.admin-addr {
  max-width: 280px;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.admin-ts {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.admin-links {
  white-space: nowrap;
  font-size: 12px;
}
.admin-placeholder {
  color: var(--muted);
}
