:root {
  --paper: #f4f0e6;
  --ink: #1c1915;
  --muted: #5e584e;
  --line: #ddd4c4;
  --button: #0f6e56;
  --button-ink: #f7fffb;
  --panel: #fffdf8;
  --danger: #8d2f2f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 28px 0;
  position: relative;
  z-index: 50;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.history-tab, .mode, .dictate, .text-tools button, .text-tools select {
  font: inherit;
}

.account {
  display: none;
  align-items: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.account.visible { display: flex; }

.balance { font-size: 18px; }

.pay-link {
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
  font-size: 14px;
}

.info {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-family: Georgia, serif;
  font-style: italic;
  cursor: help;
  padding: 0;
}

.info .tip {
  display: none;
  position: absolute;
  right: 0;
  top: 30px;
  width: 280px;
  padding: 12px 14px;
  background: var(--ink);
  color: var(--paper);
  font-family: "Segoe UI", sans-serif;
  font-style: normal;
  font-size: 14px;
  line-height: 1.4;
  text-align: left;
  z-index: 3;
}

.info:hover .tip,
.info:focus .tip,
.info:focus-within .tip { display: block; }

.auth-tab {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 0;
  border-bottom: 1px solid transparent;
}

.auth-tab:hover { border-bottom-color: var(--ink); }

main {
  width: min(920px, calc(100% - 32px));
  margin: 28px auto 48px;
  flex: 1;
}

.lead {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.45;
  text-align: center;
}

.note {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.composer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.text-column { flex: 1; min-width: 0; }

.text-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.text-tools button, .history-tab, .mode, .dictate {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
}

.text-tools label { font-size: 14px; }

.listen-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.mode, .dictate { max-width: 180px; }

.composer.fullscreen, .history-view.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--paper);
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.composer.fullscreen .transcript,
.history-view.fullscreen .transcript {
  width: 100%;
  flex: 1;
  min-height: 0;
}

.transcript {
  width: min(640px, 100%);
  min-height: 240px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: 16px/1.5 "Segoe UI", sans-serif;
}

.listen {
  width: 148px;
  height: 148px;
  flex: 0 0 148px;
  border: 0;
  border-radius: 50%;
  background: var(--button);
  color: var(--button-ink);
  font: 16px/1.25 "Segoe UI", sans-serif;
  cursor: pointer;
  padding: 16px;
}

.listen[aria-pressed="true"] {
  background: #8d2f2f;
}

.status {
  min-height: 1.4em;
  margin: 12px 0 0;
  text-align: center;
  color: var(--danger);
}

.carousel {
  margin-top: 36px;
}

.carousel h2 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}

.carousel-frame {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slide {
  flex: 1;
  display: flex;
  gap: 18px;
  align-items: center;
  min-height: 160px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.slide img {
  width: min(280px, 42%);
  height: 180px;
  object-fit: cover;
  background: #e7e0d2;
}

.slide p {
  margin: 0;
  line-height: 1.45;
}

.nav {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: transparent;
  cursor: pointer;
  font-size: 20px;
}

.carousel-frame[data-count="0"] { display: none; }

.site-footer {
  padding: 28px 20px 36px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

.site-footer a { color: var(--ink); }

.contact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 8px;
  text-decoration: none;
}

.contact.priority { font-weight: 600; }

.icon { width: 16px; height: 16px; display: block; }

.max-qr { margin-top: 12px; }

.max-qr img { width: 120px; height: 120px; }

.auth-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(360px, 100%);
  background: var(--panel);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  padding: 28px 22px;
  z-index: 5;
}

.auth-panel.open { transform: translateX(0); }

.history-panel {
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: min(420px, 100%);
  background: var(--panel);
  border-right: 1px solid var(--line);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  padding: 28px 22px;
  z-index: 40;
  overflow: auto;
}

.history-panel.open { transform: translateX(0); }

.history-list { list-style: none; padding: 0; margin: 12px 0 0; }

.history-list button {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 10px 0;
  cursor: pointer;
  font: inherit;
}

.history-list time { display: block; color: var(--muted); font-size: 13px; }

.history-view {
  position: fixed;
  inset: 0;
  z-index: 41;
  background: var(--paper);
  padding: 20px;
  display: flex;
}

.history-view[hidden] { display: none; }

.rule-dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  width: min(480px, calc(100% - 32px));
}

.rule-dialog textarea {
  width: 100%;
  min-height: 90px;
  font: inherit;
  margin: 8px 0 12px;
}

.auth-panel h2 { margin: 0 0 16px; font-size: 20px; }

.auth-panel label {
  display: block;
  margin: 12px 0 6px;
  font-size: 14px;
}

.auth-panel input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.auth-actions button, .pay-button {
  border: 0;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  padding: 10px 14px;
  cursor: pointer;
}

.auth-error { min-height: 1.3em; color: var(--danger); }

.pay-card {
  width: min(520px, 100%);
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px;
}

.pay-card h1 { margin: 0 0 8px; font-size: 26px; text-align: center; }

.tariff-vars {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  margin: 18px 0;
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 15px;
}

.tariff-vars dt { margin: 0; color: var(--muted); }
.tariff-vars dd { margin: 0; text-align: right; }

.calculator { margin-top: 18px; }

.calculator label { display: block; margin-bottom: 6px; }

.calculator input {
  width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  font: inherit;
}

.sum {
  font-size: 22px;
  margin: 14px 0;
}

@media (max-width: 720px) {
  .composer { flex-direction: column; }
  .listen { width: 120px; height: 120px; flex-basis: 120px; }
  .slide { flex-direction: column; }
  .slide img { width: 100%; }
  .topbar { padding: 14px 14px 0; }
}
