/* Communication Gym — mobile-first, dark by default, warm accent. */
:root {
  --bg: #12100f;
  --bg-2: #1b1815;
  --card: #211d1a;
  --card-2: #2a2521;
  --line: #37302b;
  --text: #f3ede7;
  --muted: #a99f96;
  --accent: #ff7a5c;
  --accent-2: #c9457a;
  --good: #6fcf97;
  --warn: #f2c94c;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f2ee; --bg-2: #efe9e3; --card: #fff; --card-2: #f3ede7;
    --line: #e2d8ce; --text: #241f1b; --muted: #6f655c;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}
#app { display: flex; flex-direction: column; height: 100dvh; }

#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
#topTitle { flex: 1; font-weight: 700; font-size: 17px; text-align: center; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 12px; font-size: 20px; cursor: pointer;
}
.icon-btn:active { transform: scale(0.96); }
#backBtn { font-size: 26px; line-height: 1; }

#screen { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 16px; }
.pad-b { padding-bottom: calc(24px + var(--safe-bottom)); }

.lead { color: var(--muted); font-size: 14px; margin: 2px 0 14px; }
.section-title { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; }

/* Home tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: left; cursor: pointer; color: var(--text);
  display: flex; flex-direction: column; gap: 6px; min-height: 108px;
}
.tile:active { transform: scale(0.98); }
.tile .emoji { font-size: 26px; }
.tile .t-name { font-weight: 650; font-size: 15px; }
.tile .t-tag { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 12px; min-height: 0; }
.tile.wide .emoji { font-size: 22px; }

.banner {
  background: linear-gradient(135deg, rgba(255,122,92,.16), rgba(201,69,122,.16));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px; margin-bottom: 14px;
}
.banner b { color: var(--accent); }
.banner button { margin-top: 10px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card-2);
  color: var(--text); padding: 11px 14px; border-radius: 12px; font-size: 15px;
  cursor: pointer; font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 11px; font-size: 13px; border-radius: 10px; font-weight: 600; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 12px; border-radius: 999px; font-size: 13px; cursor: pointer;
}
.chip.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }

/* Forms */
label.fld { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], select, textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 15px; font-family: inherit;
}
textarea { min-height: 96px; resize: vertical; }
textarea.locked { background: var(--bg-2); color: var(--muted); cursor: default; opacity: .85; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 12px; }
.card h3 { margin: 0 0 4px; font-size: 15px; }

/* Setup screen (module) */
.setup .card { margin-bottom: 12px; }

/* Chat */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; padding: 11px 13px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 5px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.ai b { color: var(--accent); }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 12px; text-align: center; max-width: 92%; }
.msg .save-btn {
  display: inline-block; margin-top: 8px; font-size: 12px; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; cursor: pointer;
}
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }

.composer {
  border-top: 1px solid var(--line); background: var(--bg-2);
  padding: 8px 10px calc(8px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 8px;
}
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 44px; max-height: 140px; }
.chat-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.send-btn { flex: none; width: 46px; height: 46px; border-radius: 12px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 20px; cursor: pointer; }
.send-btn:disabled { opacity: .5; }

/* Progress */
.meter { height: 8px; background: var(--card-2); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.kv { display: flex; justify-content: space-between; font-size: 13px; margin-top: 10px; }
.kv small { color: var(--muted); }

/* Saved lines */
.line-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.line-item .meta { color: var(--muted); font-size: 11px; margin-top: 6px; display: flex; justify-content: space-between; }
.line-item .x { color: var(--muted); cursor: pointer; }

.empty { color: var(--muted); text-align: center; padding: 40px 20px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.4);
}

/* Legal pages */
.legal { color: var(--text); font-size: 14px; line-height: 1.6; }
.legal p { margin: 0 0 12px; }
.legal b { color: var(--text); }
.legal-links { margin-top: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.legal-links a { color: var(--accent); text-decoration: none; }
.legal-links a:hover { text-decoration: underline; }

/* Onboarding wizard */
.onboarding { max-width: 520px; margin: 0 auto; }
.ob-progress { display: flex; gap: 6px; justify-content: center; margin: 6px 0 14px; }
.ob-dot { width: 20px; height: 4px; border-radius: 999px; background: var(--line); transition: background .2s; }
.ob-dot.on { background: var(--accent); }
.ob-welcome { text-align: center; padding-top: 24px; }
.ob-logo-img { width: 76px; height: 76px; margin: 0 auto 10px; display: block; }
.ob-title { font-size: 26px; font-weight: 800; margin: 6px 0 12px; }
.ob-sub { color: var(--muted); font-size: 15px; line-height: 1.55; margin-bottom: 24px; }
.ob-q { font-size: 22px; font-weight: 700; line-height: 1.25; margin: 6px 0 4px; }
.ob-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.ob-choice { text-align: left; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 16px; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s, transform .05s; }
.ob-choice:hover { border-color: var(--accent); background: var(--card-2); }
.ob-choice:active { transform: scale(.99); }

/* Landing page */
.landing { max-width: 560px; margin: 0 auto; }
.ld-hero { text-align: center; padding: 20px 0 8px; }
.ld-logo { width: 84px; height: 84px; margin: 0 auto 12px; display: block; }
.ld-title { font-size: 30px; font-weight: 800; line-height: 1.15; margin: 6px 0 12px; }
.ld-sub { color: var(--muted); font-size: 16px; line-height: 1.55; margin: 0 auto 20px; max-width: 470px; }
.ld-examples { display: flex; flex-direction: column; gap: 8px; }
.ld-ex { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 15px; }
.ld-ex-i { font-size: 20px; flex: 0 0 auto; }
.ld-steps { display: flex; flex-direction: column; gap: 14px; }
.ld-step { display: flex; gap: 14px; align-items: flex-start; }
.ld-step-n { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.ld-step-t { font-weight: 700; font-size: 16px; }
.ld-step-d { color: var(--muted); font-size: 14px; line-height: 1.5; margin-top: 2px; }

/* Voice controls */
.mic-btn { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 18px; cursor: pointer; }
.mic-btn.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; animation: micpulse 1.1s infinite; }
@keyframes micpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,122,92,.5); } 50% { box-shadow: 0 0 0 7px rgba(255,122,92,0); } }
.btn.small.on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
