:root {
  --bg: #0f1222;
  --me: #ff7a59;
  --me2: #ff4f7b;
  --them: #4fd1c5;
  --them2: #6c7cff;
  --text: #f4f5fb;
  --muted: #9aa0bd;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Georgian", "Noto Sans", sans-serif;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
#app { height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

.half { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 20px; min-height: 0; position: relative; }
.half.me { background: radial-gradient(120% 90% at 50% 100%, rgba(255, 122, 89, 0.18), transparent 60%); }
.half.them { background: radial-gradient(120% 90% at 50% 100%, rgba(79, 209, 197, 0.16), transparent 60%); }
body.flip .half.them { transform: rotate(180deg); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip { background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 999px;
  padding: 7px 14px; font-size: 15px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; font-family: inherit; }
button.chip { cursor: pointer; }
.status { color: var(--muted); font-size: 13px; text-align: right; }

.bubble { flex: 1; min-height: 0; overflow-y: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 22px; padding: 16px 18px; display: flex; flex-direction: column; justify-content: center; }
.bubble .main { font-size: clamp(22px, 6.2vw, 34px); line-height: 1.25; font-weight: 600; margin: 0; letter-spacing: -0.01em;
  user-select: text; -webkit-user-select: text; }
.bubble .sub { color: var(--muted); font-size: 15px; margin: 10px 0 0; line-height: 1.35; }
.bubble .sub b { font-weight: 600; color: var(--text); opacity: 0.7; }
.bubble .hint { color: var(--muted); font-size: 17px; text-align: center; margin: 0; line-height: 1.4; }
.bubble .err { color: #ff8b8b; font-size: 16px; margin: 0; }
.bubble.fresh { animation: pop 0.35s ease; }
@keyframes pop { from { transform: scale(0.97); opacity: 0.4; } to { transform: none; opacity: 1; } }

.talk { position: relative; height: 92px; border: 0; border-radius: 28px; color: #fff; font-size: 22px; font-weight: 700;
  font-family: inherit; cursor: pointer; overflow: hidden; touch-action: manipulation; flex-shrink: 0;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6); transition: transform 0.12s ease, filter 0.2s; }
.me .talk { background: linear-gradient(135deg, var(--me), var(--me2)); }
.them .talk { background: linear-gradient(135deg, var(--them), var(--them2)); }
.talk:active { transform: scale(0.98); }
.talk .label { position: relative; z-index: 1; }
.talk .ring { position: absolute; inset: 0; border-radius: inherit; }
.talk.rec .ring { animation: pulse 1.2s ease-in-out infinite; background: rgba(255, 255, 255, 0.18); }
.talk.rec .label::before { content: "● "; color: #fff; animation: blink 1s steps(2) infinite; }
.talk.busy { filter: saturate(0.4) brightness(0.8); }
.talk:disabled { filter: grayscale(1) brightness(0.55); }
@keyframes pulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 0.6; } }
@keyframes blink { 50% { opacity: 0; } }

.divider { height: 34px; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0; }
.divider::before { content: ""; position: absolute; left: 16px; right: 16px; top: 50%; height: 1px; background: var(--line); }
.divider span { position: relative; background: var(--bg); padding: 0 12px; font-weight: 800; letter-spacing: 0.25em;
  text-transform: uppercase; font-size: 12px; color: var(--muted); }
.gear { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); font-size: 17px; cursor: pointer; }

dialog { border: 0; padding: 0; background: transparent; color: var(--text); width: min(520px, 100%); max-width: 100%;
  margin: auto auto 0; }
dialog::backdrop { background: rgba(5, 6, 15, 0.7); backdrop-filter: blur(4px); }
.sheet { background: #181c33; border: 1px solid var(--line); border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; max-height: 88dvh; overflow-y: auto; }
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); flex: 1; }
.sheet .row { display: flex; gap: 12px; }
.sheet .check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
.sheet .check input { width: 20px; height: 20px; accent-color: var(--me); }
.sheet select, .sheet input:not([type]) { font: inherit; font-size: 16px; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; user-select: text; -webkit-user-select: text; }
.sheet button { font: inherit; font-size: 16px; font-weight: 600; border-radius: 14px; padding: 14px; border: 1px solid var(--line); cursor: pointer; }
.sheet .primary { background: linear-gradient(135deg, var(--me), var(--me2)); color: #fff; border: 0; }
.sheet .ghost { background: transparent; color: var(--text); }
.sheet .danger { color: #ff8b8b; }
#historyList { display: flex; flex-direction: column; gap: 10px; user-select: text; -webkit-user-select: text; }
#historyList .h { background: var(--card); border-radius: 14px; padding: 10px 12px; border-left: 3px solid var(--me); }
#historyList .h.them { border-left-color: var(--them); }
#historyList .h p { margin: 0; }
#historyList .h .o { color: var(--muted); font-size: 14px; margin-top: 4px; }
#historyList .empty { color: var(--muted); }

@media (min-width: 700px) {
  #app { max-width: 520px; margin: 0 auto; }
}
