/* Truck Club — Coleta. Mobile-first, pensado para iPhone em tela cheia. */

:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #ece7dc;
  --text: #16191d;
  --muted: #6c7480;
  --line: #ddd7c9;
  --accent: #b45309;
  --accent-soft: #f3e3d0;
  --ok: #157347;
  --danger: #b42318;
  --radius: 16px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101418;
    --surface: #181d23;
    --surface-2: #222932;
    --text: #eef1f4;
    --muted: #98a2ad;
    --line: #2c343d;
    --accent: #f59e0b;
    --accent-soft: #3a2c14;
    --ok: #34d399;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* display:flex/grid de .sheet-backdrop e .btn-block anulariam o atributo hidden */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }

input, textarea, button, select { font: inherit; color: inherit; }
input, textarea { font-size: 16px; } /* impede auto-zoom no iOS */

.view { display: none; min-height: 100dvh; }
.view.active { display: block; }

/* ---------------------------------------------------------- boot */
.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); z-index: 90;
}
.boot.gone { display: none; }
.spinner {
  width: 26px; height: 26px; border: 3px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- login */
.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; padding: 32px 24px calc(32px + var(--safe-b));
}
.login-mark { color: var(--accent); }
.login-mark svg { width: 56px; height: 56px; }
.login-wrap h1 { margin: 12px 0 0; font-size: 28px; letter-spacing: -.02em; }
.login-sub { margin: 0 0 26px; color: var(--muted); }
.login-wrap form { width: 100%; max-width: 360px; }
.login-foot { margin-top: 22px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------- campos */
.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block; font-size: 13px; font-weight: 600; color: var(--muted);
  margin-bottom: 7px; letter-spacing: .01em;
}
.field em { font-style: normal; font-weight: 400; opacity: .7; }
.field input, .field textarea, .inline-input {
  width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  -webkit-appearance: none; appearance: none;
}
.field textarea { resize: vertical; min-height: 130px; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.error { color: var(--danger); font-size: 14px; margin: -6px 0 12px; }

/* ---------------------------------------------------------- botões */
.btn {
  border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 650;
  background: var(--surface-2); color: var(--text); cursor: pointer; min-height: var(--tap);
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { filter: brightness(.92); }
@media (prefers-color-scheme: dark) { .btn-primary { color: #16191d; } }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-sm { padding: 9px 14px; min-height: 40px; border-radius: 11px; font-size: 14px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.icon-btn {
  border: 0; background: transparent; font-size: 22px; line-height: 1;
  min-width: 44px; min-height: 44px; border-radius: 12px; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

/* ---------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: calc(8px + var(--safe-t)) 14px 8px;
}
.topbar-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; flex: 1; }
.brand svg { width: 26px; height: 26px; color: var(--accent); }
.top-label { font-size: 12px; font-weight: 700; letter-spacing: .09em; color: var(--muted); text-transform: uppercase; }
.topbar-simple { display: flex; align-items: center; gap: 6px; }
.topbar-simple .top-label { flex: 1; text-align: center; }

.searchbar { position: relative; margin: 6px 0 8px; }
.search-ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
#search {
  width: 100%; padding: 11px 12px 11px 38px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); -webkit-appearance: none; appearance: none;
}
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------------------------------------------------------- chips */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips-wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 34px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip.on { color: #16191d; } }
.chip .chip-n { opacity: .7; font-weight: 500; }

/* ---------------------------------------------------------- lista */
.list { padding: 12px 14px calc(120px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex; gap: 12px; align-items: flex-start; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; width: 100%; cursor: pointer; box-shadow: var(--shadow);
}
.card:active { transform: scale(.99); }
.card-thumb {
  width: 54px; height: 54px; flex: 0 0 54px; border-radius: 12px;
  background: var(--surface-2); display: grid; place-items: center; font-size: 24px; overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 640; font-size: 15px; margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-snippet {
  font-size: 13px; color: var(--muted); margin: 0 0 6px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 11px; color: var(--muted); }
.card-tag { background: var(--accent-soft); color: var(--text); border-radius: 999px; padding: 3px 9px; font-weight: 600; }
.card-proc { color: var(--accent); font-weight: 600; }

.empty { text-align: center; padding: 70px 32px calc(120px + var(--safe-b)); color: var(--muted); }
.empty-ico { font-size: 46px; }
.empty h2 { margin: 12px 0 6px; font-size: 19px; color: var(--text); }
.empty p { margin: 0; font-size: 14px; }

/* ---------------------------------------------------------- FAB */
.fab {
  position: fixed; right: 18px; bottom: calc(20px + var(--safe-b)); z-index: 30;
  width: 60px; height: 60px; border-radius: 22px; border: 0;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 22px rgba(0,0,0,.28);
}
@media (prefers-color-scheme: dark) { .fab { color: #16191d; } }
.fab svg { width: 26px; height: 26px; }
.fab:active { transform: scale(.94); }

/* ---------------------------------------------------------- sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 8px 18px calc(20px + var(--safe-b));
  animation: rise .24s cubic-bezier(.32,.72,0,1);
  -webkit-overflow-scrolling: touch;
}
@keyframes rise { from { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.sheet-foot { display: flex; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.sheet-foot .inline-input { flex: 1; }

.sheet-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pick {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 16px;
  padding: 14px 6px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 84px;
  color: var(--text);
}
.pick:active { transform: scale(.97); }
.pick-ico { font-size: 26px; line-height: 1; }
.pick-rec { background: var(--accent-soft); border-color: var(--accent); }

.pane { margin-top: 4px; }

/* ---------------------------------------------------------- gravação */
.rec-box { text-align: center; padding: 10px 0 4px; }
.rec-time { font-size: 40px; font-weight: 300; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.rec-hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.rec-wave { display: flex; gap: 4px; justify-content: center; align-items: flex-end; height: 44px; margin: 18px 0; }
.rec-wave i { width: 4px; height: 8px; border-radius: 3px; background: var(--line); transition: height .12s; }
.rec-wave.on i { background: var(--accent); }
.rec-btn {
  width: 72px; height: 72px; border-radius: 50%; border: 3px solid var(--accent);
  background: transparent; display: grid; place-items: center; margin: 0 auto 14px; cursor: pointer;
}
.rec-btn span { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); transition: .2s; }
.rec-btn.rec span { width: 26px; height: 26px; border-radius: 6px; background: var(--danger); }
.rec-btn.rec { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent) 14%, transparent); } }

/* ---------------------------------------------------------- progresso */
.progress-box { padding: 18px 4px; }
.prog-name { font-weight: 600; font-size: 14px; margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-track { height: 8px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width .2s; }
.prog-label { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------- detalhe */
.item-body { padding: 16px 16px calc(48px + var(--safe-b)); }
.item-hero { width: 100%; border-radius: 16px; margin-bottom: 16px; display: block; background: var(--surface-2); }
.item-audio { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 16px; }
.item-audio button { border: 0; background: var(--accent); color: #fff; width: 46px; height: 46px; border-radius: 50%; font-size: 18px; cursor: pointer; }
.item-section { margin-bottom: 20px; }
.item-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0 0 8px; }
.item-section p, .item-section pre {
  margin: 0; font-size: 15px; white-space: pre-wrap; word-break: break-word;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
}
.item-section pre { font-family: inherit; }
.item-link { color: var(--accent); word-break: break-all; font-size: 14px; }
.item-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.item-actions { display: flex; gap: 10px; margin-top: 8px; }
.item-actions .btn { flex: 1; }
.meta-row { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------- menu */
.sheet-menu { padding-bottom: calc(20px + var(--safe-b)); }
.menu-list { display: flex; flex-direction: column; }
.menu-item {
  border: 0; background: transparent; text-align: left; padding: 15px 4px; font-size: 16px;
  border-bottom: 1px solid var(--line); cursor: pointer; color: var(--text);
}
.menu-item:active { background: var(--surface-2); }

/* ---------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-b)); z-index: 80;
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  max-width: 88vw; text-align: center; box-shadow: var(--shadow);
}
.toast.err { background: var(--danger); color: #fff; }

/* ---------------------------------------------------------- instalação */
.pwa-hint {
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 14px;
  padding: 12px 14px; font-size: 13px; margin: 0 14px 10px; line-height: 1.5;
}
.pwa-hint b { display: block; margin-bottom: 3px; }
