:root {
  --jade: #0E5C5B;
  --jade-deep: #06302F;
  --jade-soft: #CFE8E4;
  --coral: #FF6B5A;
  --paper: #FAF7F2;
  --sand: #EDE8DF;
  --ink: #1C1B19;
  --ink-muted: #6F6B64;
  --outline: #DBD5CA;
  --white: #FFFFFF;
  --radius-s: 14px;
  --radius-m: 20px;
  --radius-l: 28px;
  --shadow: 0 1px 2px rgba(6,48,47,.06), 0 8px 24px rgba(6,48,47,.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- shared ---------- */
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-muted); margin: 0 0 8px;
}
.btn {
  appearance: none; border: none; cursor: pointer; font: inherit; font-weight: 600;
  border-radius: var(--radius-m); padding: 0 20px; height: 52px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s, opacity .15s, background .15s;
}
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--jade); color: #fff; }
.btn-ghost { background: transparent; color: var(--jade); border: 1.5px solid var(--outline); }
.btn-text { background: transparent; color: var(--ink-muted); border: none; height: 44px; padding: 0 8px; }
.btn-block { width: 100%; }

.field {
  width: 100%; border: 1.5px solid var(--outline); background: var(--white);
  border-radius: var(--radius-s); padding: 14px 16px; font: inherit; color: var(--ink);
  outline: none; transition: border-color .15s;
}
.field:focus { border-color: var(--jade); }
.field::placeholder { color: var(--ink-muted); }
/* code entry: same font as every other field, only centered + spaced */
.field-code { text-align: center; letter-spacing: 6px; }
.field-code::placeholder { letter-spacing: normal; }

.card {
  background: var(--white); border-radius: var(--radius-m); box-shadow: var(--shadow);
}

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.spinner-jade { border-color: var(--jade-soft); border-top-color: var(--jade); }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--jade-deep); color: #fff; padding: 12px 18px; border-radius: 999px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 50; animation: rise .2s ease;
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.err { color: var(--coral); font-size: 14px; }

/* ---------- auth ---------- */
.auth {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  max-width: 440px; width: 100%; margin: 0 auto; padding: 32px 24px;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 32px; }
.brand-mark {
  width: 64px; height: 64px; border-radius: 20px; background: var(--jade);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.brand-mark svg { width: 34px; height: 34px; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.brand p { margin: 0; color: var(--ink-muted); font-size: 15px; }

.tabs { display: flex; background: var(--sand); border-radius: var(--radius-s); padding: 4px; margin-bottom: 20px; }
.tab {
  flex: 1; text-align: center; padding: 10px; border-radius: 11px; cursor: pointer;
  font-weight: 600; color: var(--ink-muted); border: none; background: transparent; font: inherit;
}
.tab.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 3px rgba(6,48,47,.1); }

.auth form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- app shell ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; gap: 12px;
}
.topbar .title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.topbar .title .dot { width: 28px; height: 28px; border-radius: 9px; background: var(--jade); display: grid; place-items: center; }
.topbar .title .dot svg { width: 16px; height: 16px; }
.acct { font-size: 13px; color: var(--ink-muted); display: flex; align-items: center; gap: 10px; }

main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 4px 20px 40px; }

/* language bar */
.langbar {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.lang-select {
  appearance: none; -webkit-appearance: none; width: 100%;
  border: 1.5px solid var(--outline); background: var(--white) ;
  border-radius: var(--radius-s); padding: 13px 14px; font: inherit; font-weight: 600;
  color: var(--ink); cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236F6B64' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 34px;
}
.swap {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--outline);
  background: var(--white); display: grid; place-items: center; cursor: pointer;
}
.swap svg { width: 18px; height: 18px; }
.swap:active { transform: rotate(180deg); transition: transform .2s; }

/* editor */
.editor { position: relative; margin-bottom: 14px; }
.editor textarea {
  width: 100%; min-height: 150px; resize: vertical; border: 1.5px solid var(--outline);
  background: var(--white); border-radius: var(--radius-m); padding: 18px; font: inherit;
  font-size: 17px; color: var(--ink); outline: none;
}
.editor textarea:focus { border-color: var(--jade); }
.editor .clear {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--sand); color: var(--ink-muted); cursor: pointer; display: none;
  align-items: center; justify-content: center; font-size: 16px;
}
.editor .clear.show { display: flex; }

.controls { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 42px; height: 25px; border-radius: 999px; background: var(--outline); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--jade); }
.switch input:checked + .track::after { transform: translateX(17px); }

/* result */
.result { padding: 18px; margin-bottom: 14px; }
.result .out { font-size: 19px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.result .meta { margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--ink-muted); font-size: 13px; }
.result .meta .score { background: var(--jade-soft); color: var(--jade-deep); border-radius: 999px; padding: 3px 10px; font-weight: 600; }
.icon-btn { border: none; background: var(--sand); border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.back { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--sand); color: var(--ink-muted); font-size: 14px; }
.cands { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cand { background: var(--paper); border-radius: var(--radius-s); padding: 10px 12px; font-size: 15px; }
.cand .c-score { color: var(--jade); font-weight: 600; font-size: 12px; }

/* paywall */
.paywall {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 32px 28px; max-width: 440px; margin: 0 auto; gap: 16px;
}
.paywall .crown { width: 72px; height: 72px; border-radius: 20px; background: var(--jade); display: grid; place-items: center; }
.paywall .crown svg { width: 36px; height: 36px; }
.paywall h2 { margin: 4px 0 0; font-size: 23px; }
.paywall p { margin: 0; color: var(--ink-muted); }
.paywall .price { font-size: 26px; font-weight: 700; color: var(--jade); }

.muted { color: var(--ink-muted); }
.hidden { display: none !important; }

/* ---------- mode tabs ---------- */
.mode-tabs { max-width: 360px; margin: 0 auto 18px; }

/* ---------- voice ---------- */
.rec-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 0 10px; }
.rec-btn {
  width: 92px; height: 92px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--jade); display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(14,92,91,.3); transition: transform .12s, background .15s;
}
.rec-btn svg { width: 38px; height: 38px; }
.rec-btn:active { transform: scale(.94); }
.rec-btn:disabled { background: var(--outline); box-shadow: none; cursor: default; }
.rec-btn.recording { background: var(--coral); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,90,.5); } 50% { box-shadow: 0 0 0 16px rgba(255,107,90,0); } }
.rec-status { font-size: 14px; text-align: center; min-height: 20px; }
.result .eyebrow { margin-bottom: 6px; }

/* ---------- photo ---------- */
.photo-cont { position: relative; display: block; line-height: 0; border-radius: 14px; overflow: hidden; }
.photo-img { width: 100%; height: auto; display: block; border-radius: 14px; }
.ov {
  position: absolute; box-sizing: border-box;
  background: rgba(6,48,47,.86); color: #fff; border-radius: 4px;
  padding: 1px 4px; line-height: 1.15; overflow: hidden;
  display: flex; align-items: center; word-break: break-word;
}

/* ---------- PWA install bar ---------- */
.installbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--jade-deep); color: #fff; border-radius: var(--radius-m);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; box-shadow: var(--shadow); z-index: 60; font-size: 14px;
  max-width: 700px; margin: 0 auto; animation: rise .2s ease;
}
.installbar b { font-weight: 700; }
.installbar .btn-text { color: rgba(255,255,255,.7); }
.ib-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ib-go {
  background: var(--coral); color: #fff; border: none; border-radius: 12px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; flex-shrink: 0;
}

/* ---------- safe areas (iOS standalone notch) ---------- */
.topbar { padding-top: calc(16px + env(safe-area-inset-top)); }
.auth, .paywall { padding-top: calc(32px + env(safe-area-inset-top)); }
main { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
