:root {
  --bg: #0b0d10; --panel: #14181d; --line: #252b33; --text: #eef1f4; --muted: #8b95a1;
  --accent: #3ddc97; --accent-ink: #062b1b; --danger: #ff6b5e; --warn-bg: #3a2a0c; --warn: #ffcf66;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }

.gate { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; text-align: center; }
.gate form { display: flex; flex-direction: column; gap: 12px; width: min(340px, 100%); }
.mark { width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 26px; letter-spacing: .5px; }
h1 { margin: 0; font-size: 24px; }
input { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.primary { padding: 14px 20px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; min-width: 240px; }
.ghost { background: transparent; color: var(--muted); padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); }
.muted, .msg { color: var(--muted); margin: 0; }
.msg:empty { display: none; }

.app { height: 100%; display: flex; flex-direction: column; max-width: 640px; margin: 0 auto; padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom); }
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; }
.brand { font-weight: 700; }
.talk { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 8px 0 16px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.me { align-self: flex-end; background: #1f3a2f; border-bottom-right-radius: 6px; }
.ai { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.ai.thinking { color: var(--muted); }

.draft { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 12px; }
.draft-head { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.warn { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-weight: 600; }
.draft dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; }
.draft dt { color: var(--muted); }
.draft dd { margin: 0; word-break: break-all; font-weight: 600; }
.draft pre { margin: 0 0 12px; white-space: pre-wrap; font: inherit; max-height: 30vh; overflow-y: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.draft-actions { display: flex; gap: 10px; justify-content: flex-end; }
.send { background: var(--accent); color: var(--accent-ink); font-weight: 800; padding: 12px 28px; border-radius: 14px; }
.send:disabled { opacity: .5; }

footer { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 8px 0 16px; }
.type { display: flex; gap: 8px; width: 100%; }
.type button { width: 52px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-size: 20px; }
.hold { width: 112px; height: 112px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; box-shadow: 0 0 0 0 rgba(61,220,151,.5); transition: transform .12s ease; }
.hold.listening { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(61,220,151,.18); }
.hold:disabled { background: var(--line); color: var(--muted); }
.chips { display: flex; gap: 8px; width: 100%; overflow-x: auto; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); white-space: nowrap; }
.link-btn { display: inline-flex; align-items: center; text-decoration: none; padding: 12px 18px; border-radius: 14px; }
.link-btn.ghost { color: var(--text); }
