/* ============================================================
   Lista por Voz — tema sobre o Bootstrap 5
   Paleta: floresta + persimmon, tipografia Fraunces + Manrope
   ============================================================ */

:root,
[data-bs-theme="light"] {
  --lv-bg: #F3F6EC;
  --lv-surface: #FFFFFF;
  --lv-surface-2: #ECF1E3;
  --lv-ink: #17241C;
  --lv-ink-muted: #5B6C5C;
  --lv-border: #DCE3D1;
  --lv-accent: #E2582B;
  --lv-accent-ink: #FFF7F0;
  --lv-success: #3F7D4B;
  --lv-success-soft: #E3F0E4;
  --lv-danger: #B0413E;
  --lv-danger-soft: #F7E4E2;
  --lv-shadow: 0 14px 34px -16px rgba(23, 36, 28, .22);

  --bs-body-bg: var(--lv-bg);
  --bs-body-color: var(--lv-ink);
  --bs-border-color: var(--lv-border);
  --bs-primary: var(--lv-accent);
  --bs-primary-rgb: 226, 88, 43;
  --bs-border-radius: .8rem;
  --bs-border-radius-sm: .55rem;
  --bs-border-radius-lg: 1.1rem;
  --bs-body-font-family: 'Manrope', ui-sans-serif, system-ui, sans-serif;
}

[data-bs-theme="dark"] {
  --lv-bg: #10160E;
  --lv-surface: #1A2318;
  --lv-surface-2: #212C1E;
  --lv-ink: #EEF3E7;
  --lv-ink-muted: #9CAE93;
  --lv-border: #2C372A;
  --lv-accent: #F17A46;
  --lv-accent-ink: #1B0D06;
  --lv-success: #6FBE7C;
  --lv-success-soft: #22331F;
  --lv-danger: #E58A82;
  --lv-danger-soft: #3A211F;
  --lv-shadow: 0 14px 34px -14px rgba(0, 0, 0, .6);

  --bs-body-bg: var(--lv-bg);
  --bs-body-color: var(--lv-ink);
  --bs-border-color: var(--lv-border);
  --bs-primary: var(--lv-accent);
  --bs-primary-rgb: 241, 122, 70;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--lv-bg);
  color: var(--lv-ink);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}
h1, h2 { font-family: 'Fraunces', Georgia, serif; text-wrap: balance; margin: 0; }

.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  background: var(--lv-surface);
  display: flex;
  flex-direction: column;
  box-shadow: var(--lv-shadow);
  position: relative;
}

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
  background: var(--lv-surface);
  border-bottom: 1px solid var(--lv-border);
}
.eyebrow {
  margin: 0 0 2px; font-size: 12px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--lv-accent);
}
.app-header h1 { font-size: 21px; font-weight: 600; line-height: 1.15; color: var(--lv-ink); }
.list-meta { margin: 4px 0 0; font-size: 13px; color: var(--lv-ink-muted); font-variant-numeric: tabular-nums; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding-top: 2px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--lv-border);
  background: var(--lv-surface-2); color: var(--lv-ink); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s ease, transform .1s ease; padding: 0; position: relative;
}
.icon-btn:hover { background: var(--lv-border); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn[aria-expanded="true"] { background: var(--lv-accent); color: var(--lv-accent-ink); border-color: var(--lv-accent); }

#theme-toggle .icon-moon { display: none; }
[data-bs-theme="dark"] #theme-toggle .icon-sun { display: none; }
[data-bs-theme="dark"] #theme-toggle .icon-moon { display: block; }

.btn-outline-pill {
  border: 1px solid var(--lv-border); background: transparent; color: var(--lv-ink);
  font-family: 'Manrope', sans-serif; font-size: 13px; font-weight: 600; padding: 9px 13px; border-radius: 999px;
  white-space: nowrap; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-outline-pill:hover { background: var(--lv-surface-2); color: var(--lv-ink); }
.btn-outline-pill.is-confirm { background: var(--lv-danger); border-color: var(--lv-danger); color: #fff; }

.btn-accent {
  border: none; background: var(--lv-accent); color: var(--lv-accent-ink); font-weight: 700;
  font-size: 13.5px; padding: 0 18px; border-radius: 999px;
}
.btn-accent:hover { background: var(--lv-accent); color: var(--lv-accent-ink); filter: brightness(1.06); }

/* ---------- progress ---------- */
.app-progress { height: 3px; background: var(--lv-surface-2); border-radius: 0; }
.app-progress .progress-bar { background: var(--lv-success); transition: width .35s ease; }

/* ---------- banners ---------- */
#banner-area { padding: 0 20px; }
#banner-area .alert { margin: 14px 0 0; font-size: 13.5px; border-radius: var(--bs-border-radius-sm); }
#banner-area .alert-actions { margin-top: 8px; }
#banner-area .alert-actions .btn { --bs-btn-padding-y: .3rem; --bs-btn-padding-x: .7rem; --bs-btn-font-size: .78rem; }

/* ---------- list area ---------- */
.list-area {
  flex: 1; overflow-y: auto; padding: 16px 20px 10px;
  display: flex; flex-direction: column; gap: 18px;
}
.empty-state { text-align: center; padding: 38px 12px 14px; color: var(--lv-ink-muted); }
.empty-state h2 { font-size: 18px; font-weight: 600; color: var(--lv-ink); margin-bottom: 8px; }
.empty-state p { margin: 0 auto; max-width: 30ch; font-size: 14px; line-height: 1.55; }
.empty-state .example {
  display: inline-block; margin-top: 14px; font-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
  font-size: 12.5px; background: var(--lv-surface-2); border: 1px solid var(--lv-border);
  padding: 6px 11px; border-radius: 999px; color: var(--lv-ink-muted);
}

.cat-card { border: 1px solid var(--lv-border); background: var(--lv-surface); overflow: hidden; }
.cat-card .card-header {
  display: flex; align-items: center; gap: 9px; background: var(--lv-surface);
  border-bottom: 1px solid var(--lv-border); padding: 10px 13px;
}
.cat-icon {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--cat-color) 18%, var(--lv-surface));
  color: var(--cat-color);
}
.cat-icon svg { width: 15px; height: 15px; }
.cat-title { font-size: 14.5px; font-weight: 700; color: var(--lv-ink); font-family: 'Manrope', sans-serif; }
.cat-count {
  margin-left: auto; font-size: 12px; color: var(--lv-ink-muted); font-weight: 600;
  font-variant-numeric: tabular-nums; background: var(--lv-surface-2); border-radius: 999px; padding: 2px 9px;
}

.list-group-item.lv-item {
  display: flex; align-items: center; gap: 11px; background: var(--lv-surface);
  border-color: var(--lv-border); padding: 11px 13px; animation: rowIn .28s ease both;
}
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.lv-item.is-new { background: color-mix(in srgb, var(--cat-color, var(--lv-accent)) 12%, var(--lv-surface)); }

.item-check {
  width: 24px; height: 24px; border-radius: 50%; border: 1.7px solid var(--lv-border);
  background: var(--lv-surface); flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: transparent; transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
  padding: 0;
}
.item-check:active { transform: scale(.9); }
.item-check svg { width: 14px; height: 14px; }
.lv-item.is-checked .item-check { background: var(--lv-success); border-color: var(--lv-success); color: #fff; }

.item-text { flex: 1; font-size: 14.5px; color: var(--lv-ink); line-height: 1.4; word-break: break-word; }
.lv-item.is-checked .item-text { color: var(--lv-ink-muted); text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: var(--lv-ink-muted); }
.item-qty { margin-left: 6px; --bs-badge-padding-x: .5em; background: var(--lv-accent) !important; color: var(--lv-accent-ink) !important; font-variant-numeric: tabular-nums; }

.lv-item .btn-close { --bs-btn-close-opacity: .55; flex-shrink: 0; }
.lv-item .btn-close:hover { --bs-btn-close-opacity: 1; }

/* ---------- manual add ---------- */
.manual-add { padding: 0 20px 14px; }
.manual-add .form-control { background: var(--lv-surface-2); border-color: var(--lv-border); color: var(--lv-ink); }
.manual-add .form-control:focus { border-color: var(--lv-accent); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--lv-accent) 20%, transparent); }

/* ---------- mic dock ---------- */
.mic-dock {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 6px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--lv-surface) 65%, transparent);
}
.link-btn {
  border: none; background: none; color: var(--lv-ink-muted); font-family: 'Manrope', sans-serif; font-size: 12.5px;
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 2px 6px;
}
.caption {
  min-height: 18px; margin: 0; font-family: ui-monospace, 'SF Mono', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
  font-size: 12.5px; color: var(--lv-ink-muted); text-align: center; max-width: 36ch; line-height: 1.4;
}
.caption:not(:empty)::before { content: '“'; }
.caption:not(:empty)::after { content: '”'; }

.mic-btn {
  position: relative; width: 82px; height: 82px; border-radius: 50%; border: none;
  background: var(--lv-accent); color: var(--lv-accent-ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--lv-accent) 65%, transparent);
  transition: transform .12s ease;
}
.mic-btn:active { transform: scale(.95); }
.mic-btn:disabled { opacity: .45; cursor: not-allowed; }
.mic-icon { width: 30px; height: 30px; position: relative; z-index: 2; }
.mic-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--lv-accent); opacity: 0; }
.mic-btn.is-listening { background: var(--lv-danger); box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--lv-danger) 65%, transparent); }
.mic-btn.is-listening .mic-ring { border-color: var(--lv-danger); animation: micPulse 1.6s ease-out infinite; opacity: 1; }
@keyframes micPulse { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.55); opacity: 0; } }
.hint { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--lv-ink-muted); }

@media (prefers-reduced-motion: reduce) {
  .lv-item { animation: none; }
  .mic-btn.is-listening .mic-ring { animation: none; opacity: .35; }
}

/* ---------- history offcanvas ---------- */
.history-offcanvas {
  height: 78vh; max-width: 480px; margin: 0 auto; background: var(--lv-surface); color: var(--lv-ink);
  border-top: 1px solid var(--lv-border); border-radius: 18px 18px 0 0;
}
.history-offcanvas .offcanvas-header { border-bottom: 1px solid var(--lv-border); }
.history-offcanvas .offcanvas-title { font-size: 18px; font-weight: 600; }
.history-empty-hint { font-size: 13.5px; color: var(--lv-ink-muted); padding: 6px 2px; }

#history-accordion .accordion-item { background: var(--lv-surface); border-color: var(--lv-border); }
#history-accordion .accordion-button {
  background: var(--lv-surface); color: var(--lv-ink); font-size: 13.5px; font-weight: 600;
  box-shadow: none; gap: 10px;
}
#history-accordion .accordion-button:not(.collapsed) { background: var(--lv-surface-2); color: var(--lv-ink); }
#history-accordion .accordion-button::after { margin-left: auto; }
#history-accordion .h-count { color: var(--lv-ink-muted); font-weight: 500; font-variant-numeric: tabular-nums; font-size: 12.5px; }
#history-accordion .accordion-body { padding: 0; }
#history-accordion .history-del {
  border: none; background: transparent; color: var(--lv-ink-muted); width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-left: 8px;
}
#history-accordion .history-del:hover { background: var(--lv-surface-2); color: var(--lv-danger); }
#history-accordion .history-del.is-confirm { background: var(--lv-danger); color: #fff; }
#history-accordion .history-del svg { width: 13px; height: 13px; }
.history-items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--lv-border); }
.history-items li {
  display: flex; align-items: center; gap: 9px; padding: 9px 16px; font-size: 13.5px;
  border-bottom: 1px solid var(--lv-border);
}
.history-items li:last-child { border-bottom: none; }
.history-items li.is-checked .item-text { color: var(--lv-ink-muted); text-decoration: line-through; }
.history-items .item-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--cat-color); flex-shrink: 0; }

:focus-visible { outline: 2px solid var(--lv-accent); outline-offset: 2px; }
