/* ============================================================
   Bureau of Vernacular Affairs — stylesheet
   The whole joke: a stiff manila gov form (left) vs a glowing
   modern chat bubble (right). Two type systems, two worlds.
   ============================================================ */

:root {
  --paper: #efe7d2;
  --paper-line: #d8cba6;
  --ink: #2b2418;
  --ink-soft: #6b5d44;
  --stamp-red: #b4302a;
  --night: #0f1226;
  --night-2: #161a36;
  --glow: #7c5cff;
  --glow-2: #22d3ee;
  --bubble-in: #242a52;
  --bubble-out: linear-gradient(135deg, #7c5cff, #22d3ee);
  --text-bright: #eef1ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, #1d2350 0%, transparent 60%),
    radial-gradient(900px 500px at 0% 110%, #241a4d 0%, transparent 55%),
    var(--night);
  color: var(--text-bright);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 22px 8px;
}

/* ---------------- LEFT: THE PAPER FORM ---------------- */
.form-panel { display: flex; }

.paper {
  position: relative;
  width: 100%;
  background: var(--paper);
  /* faint horizontal ruling, like a carbon form */
  background-image: repeating-linear-gradient(
    var(--paper) 0px, var(--paper) 27px,
    var(--paper-line) 28px, var(--paper) 29px
  );
  color: var(--ink);
  border: 1px solid #b9ab83;
  border-radius: 2px;
  padding: 26px 28px 22px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45), inset 0 0 60px rgba(150,130,80,.12);
  font-family: "Courier New", "Courier", ui-monospace, monospace;
}

/* torn/perforated top edge feel */
.paper::before {
  content: "";
  position: absolute;
  top: -1px; left: 0; right: 0; height: 6px;
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, rgba(0,0,0,.18) 8px 9px);
  opacity: .5;
}

.form-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 12px;
}

.seal {
  width: 46px; height: 46px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 22px;
  color: var(--stamp-red);
}

.dept { margin: 0; font-size: 10px; letter-spacing: 1.5px; color: var(--ink-soft); }
.form-head-text h1 { margin: 2px 0; font-size: 21px; letter-spacing: .5px; }
.subtitle { margin: 0; font-size: 11px; color: var(--ink-soft); }

.stamp {
  align-self: center;
  border: 3px double var(--stamp-red);
  color: var(--stamp-red);
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 13px;
  padding: 6px 10px;
  transform: rotate(8deg);
  border-radius: 4px;
  opacity: .85;
  white-space: nowrap;
}
.stamp.approved { color: #2e7d32; border-color: #2e7d32; }
.stamp.processing { color: var(--ink-soft); border-color: var(--ink-soft); transform: rotate(-4deg); }

.legalese {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 14px 0 18px;
  text-align: justify;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  margin: 6px 0 6px;
}
.req { color: var(--stamp-red); font-weight: 400; }

textarea.typewriter, select.typewriter {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: rgba(255,255,255,.45);
  border: 1px solid #9c8e66;
  border-radius: 2px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}
textarea.typewriter:focus, select.typewriter:focus {
  outline: 2px solid var(--stamp-red);
  outline-offset: 1px;
}

.char-row { font-size: 10.5px; color: var(--ink-soft); text-align: right; margin: 4px 2px 0; }

.samples { margin: 12px 0 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.samples-label { font-size: 11px; color: var(--ink-soft); margin-right: 2px; }
.sample-btn {
  font-family: inherit;
  font-size: 11px;
  background: #e3d8b8;
  border: 1px solid #9c8e66;
  border-radius: 2px;
  padding: 4px 8px;
  cursor: pointer;
  color: var(--ink);
}
.sample-btn:hover { background: #d8caa0; }

.select-wrap { position: relative; }

.persona-blurb { font-size: 11px; color: var(--ink-soft); min-height: 16px; margin: 8px 2px 0; font-style: italic; }

.submit-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; }

.translate-btn {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: 1.5px;
  font-size: 14px;
  color: #fff;
  background: var(--stamp-red);
  border: none;
  border-radius: 3px;
  padding: 12px 18px;
  cursor: pointer;
  box-shadow: 0 4px 0 #7e211d;
  transition: transform .05s ease;
}
.translate-btn:hover { background: #c2362f; }
.translate-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #7e211d; }
.translate-btn:disabled { background: #9c8e66; box-shadow: 0 4px 0 #7a6e4e; cursor: not-allowed; }

.quota { font-size: 11px; color: var(--ink-soft); }
.quota strong, .quota #quotaCount { color: var(--ink); font-weight: 700; }
.quota.unlimited { color: #2e7d32; }

.filed-note { font-size: 10px; color: var(--ink-soft); margin: 14px 0 0; font-style: italic; }

/* ---------------- RIGHT: THE GLOWING CHAT ---------------- */
.chat-panel {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--night-2), #11142b);
  border: 1px solid rgba(124,92,255,.35);
  border-radius: 22px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.03), 0 24px 60px rgba(60,30,160,.35),
              0 0 80px rgba(124,92,255,.15);
  overflow: hidden;
  min-height: 520px;
}

.chat-topbar {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 18px;
  background: rgba(255,255,255,.03);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: #28d17c; box-shadow: 0 0 10px #28d17c; }
.chat-title { font-weight: 600; font-size: 14px; }
.chat-meta { margin-left: auto; font-size: 11px; color: #8b90c4; }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble {
  max-width: 86%;
  padding: 13px 16px;
  border-radius: 20px;
  font-size: 15.5px;
  line-height: 1.5;
  animation: pop .28s ease;
}
.bubble p { margin: 0; }
.bubble p + p { margin-top: 8px; }

.bubble-in {
  align-self: flex-start;
  background: var(--bubble-in);
  border: 1px solid rgba(255,255,255,.07);
  border-bottom-left-radius: 6px;
}
.bubble-out {
  align-self: flex-end;
  background: var(--bubble-out);
  color: #0b0e22;
  font-weight: 500;
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 30px rgba(124,92,255,.45);
}
.welcome { color: #c7ccf2; }

.bubble .src-tag {
  display: block;
  font-size: 10.5px;
  letter-spacing: .4px;
  opacity: .65;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #c7ccf2;
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2){ animation-delay: .2s; }
.typing span:nth-child(3){ animation-delay: .4s; }

.chat-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.ghost-btn {
  font: inherit; font-size: 12.5px;
  background: rgba(255,255,255,.06);
  color: var(--text-bright);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}
.ghost-btn:hover { background: rgba(255,255,255,.12); }

/* ---------------- FOOTER ---------------- */
.footer-bar {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  padding: 14px 18px 24px;
}
.link-btn {
  font: inherit; font-size: 13px;
  background: none; border: none; cursor: pointer;
  color: #aeb3e0; text-decoration: none;
  padding: 6px 12px; border-radius: 8px;
}
.link-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.link-btn.tip { color: #ffd479; }

/* ---------------- MODALS ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6,8,20,.7);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 20px; z-index: 50;
}
/* The [hidden] attribute must win over display:grid, or modals can't close. */
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  width: 100%; max-width: 480px;
  background: linear-gradient(180deg, #1b1f3d, #14172e);
  border: 1px solid rgba(124,92,255,.4);
  border-radius: 18px;
  padding: 26px 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 4px; }
.modal h3 { margin: 0 0 6px; font-size: 15px; }
.modal-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: #aeb3e0;
  font-size: 26px; line-height: 1; cursor: pointer;
}
.modal-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.08); }
.muted { color: #9aa0d0; font-size: 13px; line-height: 1.55; }

.badge {
  font-size: 10px; letter-spacing: .5px; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.badge.free { background: rgba(40,209,124,.18); color: #5ff0a8; }
.badge.paid { background: rgba(255,212,121,.18); color: #ffd479; }

.text-input {
  width: 100%; font: inherit; font-size: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text-bright);
  border-radius: 10px; padding: 11px 13px; margin-top: 8px;
}
.text-input:focus { outline: 2px solid var(--glow); }

.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.code-row { display: flex; gap: 8px; margin-top: 10px; }
.code-row .text-input { margin-top: 0; }

.solid-btn {
  font: inherit; font-size: 13px; font-weight: 600;
  background: var(--glow); color: #0b0e22;
  border: none; border-radius: 10px; padding: 10px 16px;
  cursor: pointer; text-decoration: none; display: inline-block; text-align: center;
}
.solid-btn:hover { filter: brightness(1.08); }
.solid-btn.buy { background: linear-gradient(135deg, #ffd479, #ff9e3d); width: 100%; margin-top: 10px; }
.save-msg { font-size: 12px; color: #5ff0a8; }

.modal-foot { margin-top: 18px; }

/* ---------------- TOAST ---------------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #11142b; border: 1px solid rgba(124,92,255,.5);
  color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; z-index: 80; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

/* ---------------- ANIMATIONS ---------------- */
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------------- RESPONSIVE ------