:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --card: #fff; --text: #1c2025; --muted: #6a7280;
  --accent: #1f6feb; --line: #e3e6ea; --warn: #b54708; --warn-bg: #fff1e0;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171a; --card: #1e2227; --text: #e8eaed; --muted: #98a0ab;
          --accent: #4c8dff; --line: #2d333a; --warn: #ffb366; --warn-bg: #3a2a16; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { padding: 0; }
#app { padding-bottom: calc(170px + env(safe-area-inset-bottom)); }
.main { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.top { position: sticky; top: 0; background: var(--bg); padding: 12px 0 6px; display: flex; gap: 8px; align-items: center; z-index: 2; }
#search { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); font: inherit; }
.status { font-size: 12px; color: var(--muted); white-space: nowrap; }

[hidden] { display: none !important; }
.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); }
.login-card button { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.login-card .btn-login { display: block; text-align: center; text-decoration: none; background: var(--accent); color: #fff; border-radius: 10px; padding: 10px; font-weight: 600; }
.login-card .warn { margin: 0; font-size: 13px; background: var(--warn-bg); color: var(--warn); padding: 8px 10px; border-radius: 8px; }
.login-card .error { margin: 0; color: #d1242f; font-size: 13px; min-height: 1em; }
#logout { white-space: nowrap; font-size: 12px; padding: 4px 10px; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 6px 12px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer; }
.chips.small .chip { font-size: 13px; padding: 4px 10px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.list { display: grid; gap: 10px; padding-top: 6px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.note { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.note.done { opacity: .55; }
.note.pinned { border-color: var(--accent); }
.note .body { white-space: pre-wrap; word-wrap: break-word; outline: none; min-height: 1.4em; }
.note .tag, .note .person { color: var(--accent); cursor: pointer; font-weight: 500; }
.note .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.badge { background: var(--warn-bg); color: var(--warn); padding: 2px 8px; border-radius: 999px; }
.meta .spacer { flex: 1; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px 6px; border-radius: 8px; }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--bg); color: var(--text); }
.check { display: flex; gap: 8px; align-items: flex-start; }
.check input { margin-top: 5px; width: 18px; height: 18px; }
.check.ticked span { text-decoration: line-through; color: var(--muted); }

.capture { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
#text { width: 100%; resize: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; background: var(--bg); color: var(--text); max-height: 40vh; }
#text:focus, #search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.capture-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.remind { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.remind input { font: inherit; font-size: 13px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
#save { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 10px 22px; font: inherit; font-weight: 600; cursor: pointer; }

/* ---- Assuntos: menu lateral, grupos e barra de ferramentas ---- */
.side { position: fixed; top: 0; bottom: 0; left: 0; width: 280px; max-width: 85vw; background: var(--card);
  border-right: 1px solid var(--line); padding: 16px 12px 24px; overflow-y: auto; z-index: 10;
  transform: translateX(-100%); transition: transform .2s ease; }
.side.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9; }
.menu-btn { white-space: nowrap; }
.side h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 8px 6px; }
.side h2:first-child { margin-top: 4px; }
.side .none { color: var(--muted); font-size: 13px; margin: 4px 8px; }
.nav-item { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: none;
  border: 0; color: var(--text); font: inherit; font-size: 15px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.nav-item:hover, .nav-item:focus-visible { background: var(--bg); }
.nav-item[aria-pressed="true"] { background: var(--accent); color: #fff; }
.nav-item .count { opacity: .7; font-size: 13px; }
.nav-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 4px 0; }
.toolbar:empty { display: none; }
.toolbar strong { font-size: 18px; margin-right: auto; }
.toolbar input { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.link-btn { background: none; border: 0; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; padding: 4px 6px; }
.link-btn.danger { color: #d1242f; }

.group-head { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; color: var(--text);
  font: inherit; font-weight: 600; font-size: 15px; padding: 10px 2px 4px; cursor: pointer; text-align: left; }
.group-head .arrow { display: inline-block; width: 1em; color: var(--muted); transition: transform .15s; }
.group-head[aria-expanded="false"] .arrow { transform: rotate(-90deg); }
.group-head .count { color: var(--muted); font-weight: 400; font-size: 13px; }
.group { display: grid; gap: 10px; }
.subject-badge { background: var(--bg); color: var(--text); border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 12px; }

.editor { display: grid; gap: 8px; }
.editor textarea, .editor input { width: 100%; font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.editor .row { display: flex; gap: 8px; align-items: center; }
.editor .row input { flex: 1; }
.editor .primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; }

.field { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-width: 0; }
.field input { font: inherit; font-size: 13px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; min-width: 0; }
#subject { width: 140px; }
.capture-row { flex-wrap: wrap; }
#save { margin-left: auto; }

@media (min-width: 900px) {
  #app { padding-left: 280px; }
  .side { transform: none; max-width: none; }
  .menu-btn, .scrim { display: none !important; }
  .capture { left: 280px; right: 0; }
}

@media (max-width: 899px) {
  .top { flex-wrap: wrap; }
  .top .status { flex: 1; }
  #search { order: 3; flex: 1 1 100%; min-width: 0; }
  #who { display: inline-block; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
}

/* ---- Enviar nota / recebidas ---- */
.note.unread { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.received { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.received strong { color: var(--text); }
.received-msg { margin-top: 2px; font-style: italic; color: var(--text); }
.new-badge { background: var(--accent); color: #fff; border: 0; cursor: pointer; font: inherit; font-size: 12px; }
.badge.sent { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.sendbox { display: grid; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.sendbox input { width: 100%; font: inherit; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.sendbox .hint { margin: 0; font-size: 13px; color: var(--muted); }
.sendbox .warn-text { color: var(--warn); }
.sendbox .error { margin: 0; color: #d1242f; font-size: 13px; }
.sendbox .error:empty { display: none; }
.sendbox .chosen { margin: 0; font-weight: 600; }
.sendbox .row { display: flex; gap: 8px; align-items: center; }
.sendbox .primary { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.sendbox .primary:disabled { opacity: .5; cursor: not-allowed; }
.results { display: grid; gap: 4px; }
.result { text-align: left; background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 14px; cursor: pointer; }
.result:hover, .result:focus-visible { border-color: var(--accent); }

/* ---- Reuniões ---- */
.meetings { padding: 8px 0 2px; }
.meetings h2 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.meetings .hint { margin: 0; font-size: 13px; color: var(--muted); }
.meeting-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.meeting-card { flex: 0 0 210px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 4px; align-content: start; }
.meeting-card.live { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.meeting-card.past { opacity: .55; }
.meeting-card .time { font-size: 12px; color: var(--muted); }
.meeting-card .title { font-weight: 600; font-size: 14px; line-height: 1.3; }
.meeting-card .actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.primary-sm { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }

.meeting-box { display: grid; gap: 6px; margin-bottom: 8px; }
.meeting-chip { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--accent); border-radius: 10px; padding: 6px 10px; font-size: 14px; }
.meeting-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meeting-chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 6px; }
.attendee-row { display: flex; gap: 6px; flex-wrap: wrap; }
.attendee { background: var(--card); border: 1px solid var(--line); color: var(--accent); border-radius: 999px; padding: 2px 10px; font: inherit; font-size: 13px; cursor: pointer; }

.group-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding: 12px 2px 4px; }
.group-title .count { color: var(--muted); font-size: 13px; }
.badge.meeting-badge { background: var(--bg); color: var(--text); border: 1px solid var(--line); }

/* ---- Lembretes ---- */
.reminder-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; background: var(--warn-bg); color: var(--warn);
  border-radius: 10px; padding: 8px 12px; margin: 6px 0 2px; font-size: 14px; font-weight: 600; }
.reminder-banner span { margin-right: auto; }
.reminder-banner .link-btn { color: inherit; text-decoration: underline; font-weight: 500; }
.remind-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.remind-edit input { width: auto; }

/* ---- Voz ---- */
.mic { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; font-size: 18px; line-height: 1; padding: 8px 12px; cursor: pointer; }
.mic:disabled { opacity: .4; cursor: not-allowed; }
.mic[hidden] { display: none; }
.rec-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.rec-bar .link-btn { color: inherit; text-decoration: underline; font-weight: 500; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #d1242f; animation: rec-blink 1s infinite; }
@keyframes rec-blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }
.body.transcribing { color: var(--muted); font-style: italic; }
.audio-block { margin-top: 8px; display: grid; gap: 4px; }
.audio-label { font-size: 12px; color: var(--muted); }
.audio-block audio { width: 100%; height: 36px; }
.audio-block .hint { margin: 0; font-size: 12px; color: var(--muted); }
.audio-fail { font-size: 13px; color: var(--warn); }
