:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --ink: #1d1b16;
  --ink-2: #5d5a52;
  --muted: #8a867c;
  --line: #e3dfd5;
  --accent: #c98a12;
  --accent-ink: #1d1b16;
  --accent-soft: #fbefd6;
  --ok: #2f7d4f;
  --ok-soft: #e1f1e7;
  --err: #b3402a;
  --err-soft: #f8e3dd;
  --shadow: 0 1px 2px rgba(29, 27, 22, .05), 0 8px 24px rgba(29, 27, 22, .06);
  --radius: 16px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --font-read: "Iowan Old Style", Charter, Georgia, "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #1f1d17;
    --surface-2: #2a2820;
    --ink: #f1eee6;
    --ink-2: #c4c0b5;
    --muted: #8f8b80;
    --line: #34312a;
    --accent: #f2b33d;
    --accent-soft: #3a2f17;
    --ok: #6cc08c;
    --ok-soft: #1d3326;
    --err: #ee8a73;
    --err-soft: #3d221b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px calc(32px + env(safe-area-inset-bottom));
}

/* ---------- header */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 0 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.01em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: url("icone.svg") center / cover;
  flex: none;
}
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px;
  cursor: pointer; text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--err); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn {
  width: 44px; height: 44px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: 12px; border: 0; background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- upload */
.drop {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center;
  padding: 30px 20px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: 6px;
}
.drop-icon svg { width: 26px; height: 26px; }
.drop strong { font-size: 17px; }
.drop span { color: var(--muted); font-size: 14px; }

.options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 12px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); padding-left: 2px; }
select {
  appearance: none;
  min-height: 44px; width: 100%;
  padding: 0 36px 0 12px;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238a867c' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center;
}

.uploads { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.upload-row {
  padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  font-size: 14px;
}
.upload-row .row-top { display: flex; justify-content: space-between; gap: 10px; }
.upload-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- list */
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 28px 2px 10px;
}
.section-title h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink-2); letter-spacing: .02em; text-transform: uppercase; }
.section-title span { font-size: 13px; color: var(--muted); }

.list { display: flex; flex-direction: column; }
.card {
  display: block; width: 100%; text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow);
  cursor: pointer; color: inherit; text-decoration: none;
}
.card:hover { border-color: var(--muted); }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-name { flex: 1; min-width: 0; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { margin-top: 2px; font-size: 13px; color: var(--muted); }
.card-preview {
  margin-top: 8px; font-size: 14px; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.status { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status.concluido { background: var(--ok-soft); color: var(--ok); }
.status.transcrevendo, .status.na_fila { background: var(--accent-soft); color: var(--accent); }
.status.erro { background: var(--err-soft); color: var(--err); }

.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s; }
.bar.indeterminate > i { width: 35%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

.empty {
  padding: 34px 20px; text-align: center; color: var(--muted);
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}

/* ---------- phone access panel */
.access {
  margin-top: 28px; padding: 18px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line);
}
.access h3 { margin: 0 0 4px; font-size: 16px; }
.access p { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; }
.access-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.access-item { display: flex; gap: 14px; align-items: center; background: var(--surface); border-radius: 14px; padding: 12px; border: 1px solid var(--line); }
.access-item svg { width: 120px; height: 120px; border-radius: 8px; flex: none; }
.access-item .kind { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.access-item code { display: block; font-size: 15px; margin: 2px 0 8px; word-break: break-all; }
.pass { font-size: 14px; }
.pass b { font-family: ui-monospace, Consolas, monospace; font-size: 17px; letter-spacing: .06em; background: var(--surface); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- detail */
.detail-head { display: flex; align-items: center; gap: 4px; padding: calc(10px + env(safe-area-inset-top)) 0 6px; margin-left: -10px; }
.detail-title { margin: 6px 0 4px; font-size: 22px; line-height: 1.25; letter-spacing: -.01em; word-break: break-word; }
.detail-meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
audio { width: 100%; margin-top: 14px; height: 44px; }

.toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 12px 0; margin-top: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.text {
  margin-top: 18px;
  font: 18px/1.75 var(--font-read);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.text p { margin: 0 0 1.05em; }
.text .t {
  display: inline-block; margin-right: 8px;
  font: 600 12px/1 var(--font); color: var(--accent);
  background: var(--accent-soft); border-radius: 99px; padding: 5px 8px; vertical-align: 3px;
  border: 0; cursor: pointer;
}
.live { color: var(--muted); font: 14px var(--font); display: flex; align-items: center; gap: 8px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.more { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- login */
body.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px;
  padding: 26px 22px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.login-card .muted { margin: 0; color: var(--ink-2); font-size: 14px; }
.login-card input {
  min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); font-size: 17px;
}
.login-card .btn { min-height: 48px; }
.erro { margin: 0; color: var(--err); font-size: 14px; font-weight: 600; }

/* ---------- coletânea */
.send { display: flex; flex-direction: column; gap: 12px; }
.send-project select { font-weight: 600; }
.send-more summary {
  cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600;
  list-style: none; padding: 2px 2px; width: fit-content;
}
.send-more summary::-webkit-details-marker { display: none; }
.send-more summary::before { content: "▸ "; }
.send-more[open] summary::before { content: "▾ "; }
.send-more .options { margin-top: 8px; }
.uploads:empty { display: none; }
.uploads { margin-top: 0; }
.upload-row.failed { border-color: var(--err); color: var(--err); }

.search {
  position: relative; margin-top: 26px;
}
.search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; min-height: 46px; padding: 0 14px 0 42px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 16px;
}
.search input:focus, select:focus, .title-input:focus, .org textarea:focus, .tags:focus-within, .login-card input:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}

.projects {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; margin: 0 -16px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.projects::-webkit-scrollbar { display: none; }
.pchip {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.pchip .n { color: var(--muted); font-weight: 500; }
.pchip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pchip.on .n { color: inherit; opacity: .7; }
.pchip.add { border-style: dashed; color: var(--muted); }
.pdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; vertical-align: 1px; margin-right: 1px; }

.filterbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 10px 0 2px; min-height: 36px; }
.filterbar .spacer { flex: 1; }
.fb-count { font-size: 13.5px; color: var(--muted); padding-left: 2px; }

.day { margin: 22px 2px 10px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.day-group { display: flex; flex-direction: column; gap: 10px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 28px; padding: 0 10px; border-radius: 999px;
  border: 0; background: var(--surface-2); color: var(--ink-2);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.tag:hover { background: var(--accent-soft); color: var(--accent); }
.tag.on { background: var(--accent-soft); color: var(--accent); }
.tag span { font-size: 11px; opacity: .8; }

.btn.disabled { pointer-events: none; opacity: .5; }

/* ---------- detalhe: organização */
.detail-head { justify-content: space-between; }
.saved { font-size: 13px; color: var(--muted); padding-right: 4px; }
.title-input {
  display: block; width: 100%; resize: none; overflow: hidden;
  margin: 6px 0 4px; padding: 4px 6px; margin-left: -6px; width: calc(100% + 12px);
  border: 0; border-radius: 8px; background: transparent;
  font: 700 23px/1.3 var(--font); letter-spacing: -.01em; color: var(--ink);
}
.title-input:hover { background: var(--surface); }
.org {
  margin-top: 16px; padding: 6px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
}
.org-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.org-row:first-child { border-top: 0; }
.org-label { flex: none; width: 64px; font-size: 13px; font-weight: 600; color: var(--muted); }
.org select { min-height: 38px; border-radius: 10px; }
.org textarea {
  flex: 1; min-width: 0; resize: none; overflow: hidden; min-height: 38px;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  font: 15px/1.45 var(--font);
}
.tags {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 5px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: text;
}
.tags input {
  flex: 1; min-width: 120px; min-height: 30px; border: 0; background: transparent; padding: 0 6px; font-size: 15px; outline: none;
}

/* ---------- diálogo */
dialog.sheet {
  width: min(420px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog.sheet::backdrop { background: rgba(20, 18, 12, .45); }
dialog.sheet form { display: flex; flex-direction: column; gap: 14px; padding: 22px 20px 18px; }
dialog.sheet h3 { margin: 0; font-size: 18px; }
dialog.sheet input {
  min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 17px;
}
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.sw.on { border-color: var(--ink); }
.sheet-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sheet-actions .spacer { flex: 1; }

@media (max-width: 520px) {
  .options { grid-template-columns: 1fr; }
  .access-item { flex-direction: column; align-items: flex-start; width: 100%; }
  .detail-title { font-size: 20px; }
  .text { font-size: 17px; }
  .toolbar .btn { flex: 1 1 auto; }
  .toolbar .spacer { display: none; }
}

.card-meta .pdot { margin-right: 6px; }
