:root {
  --bg: #0f1115; --card: #191c23; --line: #2a2f3a;
  --ink: #f3f4f6; --dim: #9aa1ad; --accent: #3987e5; --good: #199e70; --warn: #d95926;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg:#fcfcfb; --card:#fff; --line:#e5e4df; --ink:#0b0b0b; --dim:#52514e; --accent:#2a78d6; --good:#1baf7a; --warn:#eb6834; color-scheme: light; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.view { flex: 1; padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
/* Bắt buộc: display:flex ở trên sẽ đè mất thuộc tính hidden nếu không có dòng này. */
.view[hidden] { display: none; }
.hint { color: var(--dim); font-size: 13px; margin: 0; }
.mono { font-variant-numeric: tabular-nums; }

button { font: inherit; border: 0; border-radius: 10px; padding: 11px 14px; background: var(--accent); color: #fff; cursor: pointer; }
button:active { opacity: .8; }
button.ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); }
button.small { padding: 7px 11px; font-size: 13px; }
button.danger { color: var(--warn); border-color: var(--warn); }
button[disabled] { opacity: .45; cursor: default; }

.cards { display: grid; gap: 10px; }
.card { text-align: left; background: var(--card); border: 1px solid var(--line); color: var(--ink); padding: 14px; border-radius: 12px; }
.card b { display: block; font-size: 15px; }
.card span { color: var(--dim); font-size: 13px; }

.feed { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.you { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.err { align-self: center; background: transparent; border: 1px solid var(--warn); color: var(--warn); font-size: 13px; }
.note { align-self: flex-start; max-width: 88%; font-size: 13px; border-left: 2px solid var(--warn); padding: 2px 0 2px 10px; color: var(--dim); }
.note.better { border-color: var(--good); }
.note b { color: var(--ink); font-weight: 600; }

.mic-bar { position: sticky; bottom: 0; background: var(--bg); padding-top: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.status { color: var(--dim); font-size: 13px; min-height: 20px; text-align: center; }
.mic { width: 76px; height: 76px; border-radius: 50%; font-size: 30px; padding: 0; }
.mic.on { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.mic[hidden] { display: none; }
@keyframes pulse { 50% { transform: scale(1.07); } }

.draft-box { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.draft-box[hidden] { display: none; }
.draft-box textarea {
  font: inherit; width: 100%; resize: vertical; min-height: 76px;
  padding: 11px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--card); color: var(--ink);
}
.draft-actions { display: flex; gap: 8px; justify-content: flex-end; }
.draft-actions button { min-width: 84px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
input[type=url], input[type=password] { font: inherit; padding: 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
input[type=range] { accent-color: var(--accent); }

.logitem { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; margin-bottom: 8px; font-size: 13px; }
.logitem .when { color: var(--dim); font-size: 11px; }
.logitem .said { margin: 4px 0; }
