/* Navegacao principal, "Minhas etiquetas", "Modelos", dialogos de nome/pasta e titulo do editor.
   Mesmos tokens de app.css (acento petroleo, superficies suaves, Inter + Montserrat). */

/* ---------- Botoes simples (dialogos e paginas novas) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-text);
  font: 600 13.5px var(--font-ui); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s, box-shadow .15s, transform .1s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--c-surface-2); border-color: color-mix(in srgb, var(--c-text) 22%, transparent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.btn--lg { height: 40px; padding: 0 18px; font-size: 14px; border-radius: 10px; }
.btn--accent { background: var(--c-accent); border-color: var(--c-accent); color: #fff; box-shadow: 0 4px 12px -6px color-mix(in srgb, var(--c-accent) 80%, transparent); }
.btn--accent:hover:not(:disabled) { background: var(--c-accent-strong); border-color: var(--c-accent-strong); }
.btn--danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: #A51F1F; border-color: #A51F1F; }
.btn--danger-ghost { border-color: transparent; background: transparent; color: var(--c-danger); }
.btn--danger-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--c-danger) 9%, transparent); border-color: transparent; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--c-accent); }
.btn--ghost:hover:not(:disabled) { background: var(--c-accent-soft); border-color: transparent; }
.btn.is-on { background: var(--c-accent-soft); border-color: color-mix(in srgb, var(--c-accent) 40%, transparent); color: var(--c-accent); }

/* ---------- Barra superior: navegacao principal ---------- */
.app-nav { display: flex; align-items: center; gap: 2px; margin-left: 18px; }
.app-nav__link {
  position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border-radius: 8px;
  color: var(--c-text-2); font-weight: 600; text-decoration: none; transition: background .15s, color .15s;
}
.app-nav__link:hover { background: var(--c-surface-2); color: var(--c-text); }
.app-nav__link.is-active { color: var(--c-text); }
.app-nav__link.is-active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -12px; height: 3px; border-radius: 3px 3px 0 0; background: var(--c-accent);
}

/* ---------- Barra de baixo (celular, fora do editor) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 var(--safe-right, 0) var(--safe-bottom, 0) var(--safe-left, 0);
  background: color-mix(in srgb, var(--c-surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--c-border-soft);
}
.bottom-nav .menu-anchor { position: static; display: grid; }
.bottom-nav__item {
  display: grid; justify-items: center; align-content: center; gap: 3px; min-height: var(--tabbar-h, 58px); padding: 6px 0 4px;
  border: 0; background: none; color: var(--c-text-2); font: 600 11px var(--font-ui); text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav__item > svg { width: 24px; height: 24px; padding: 3px 18px; box-sizing: content-box; border-radius: 999px; transition: background .2s var(--ease); }
.bottom-nav__item.is-active { color: var(--c-accent); }
.bottom-nav__item.is-active > svg { background: var(--c-accent-soft); }
.bottom-nav__item:active > svg { background: var(--c-surface-2); }
.avatar--sm { width: 24px; height: 24px; font-size: 12px; margin: 3px 0; }
.bottom-nav__item.is-active .avatar--sm { box-shadow: 0 0 0 3px var(--c-accent-soft); }
body:has(.bottom-nav) .home, body:has(.bottom-nav) .page { padding-bottom: calc(var(--tabbar-h, 58px) + 28px + var(--safe-bottom, 0px)); }

/* ---------- Paginas (Minhas etiquetas, Modelos) ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 28px 28px 80px; }
.page__header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page__heading h1 { font-size: clamp(26px, 2.6vw, 34px); font-weight: 800; letter-spacing: -.03em; }
.page__lead { margin: 4px 0 0; color: var(--c-text-2); }
.library__tabs { display: inline-flex; gap: 2px; padding: 3px; margin-bottom: 16px; border-radius: 11px; background: var(--c-surface-2); }
.lib-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 18px; border: 0; border-radius: 8px;
  background: transparent; color: var(--c-text-2); font: 600 13.5px var(--font-ui); cursor: pointer; transition: background .15s, color .15s;
}
.lib-tab:hover { color: var(--c-text); }
.lib-tab.is-active { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-1); }

.library__toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.search-box {
  flex: 1 1 280px; max-width: 460px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid var(--c-border); border-radius: 10px; background: var(--c-surface); transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }
.search-box__input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--c-text); font: 500 14px var(--font-ui); height: 100%; }
.sort-select { display: inline-flex; align-items: center; gap: 8px; }
.sort-select__label { font-size: 12px; font-weight: 600; color: var(--c-text-2); }
.sort-select .field__input { width: auto; height: 40px; border-radius: 10px; padding: 0 10px; }
.library__toolbar > .btn { height: 40px; border-radius: 10px; }

.folder-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.folder-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--c-border-soft); background: var(--c-surface); color: var(--c-text-2); font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.folder-chip:hover { color: var(--c-text); border-color: var(--c-border); }
.folder-chip.is-active { background: var(--c-text); border-color: var(--c-text); color: var(--c-surface); }
.folder-chip__count { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--c-surface-2); color: var(--c-text-2); }
.folder-chip.is-active .folder-chip__count { background: color-mix(in srgb, var(--c-surface) 22%, transparent); color: inherit; }
.folder-chip--new { border-style: dashed; color: var(--c-accent); background: transparent; }

.bulk-bar {
  position: sticky; top: 68px; z-index: 20; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
  padding: 8px 8px 8px 16px; border-radius: 14px; background: var(--c-surface); border: 1px solid color-mix(in srgb, var(--c-accent) 35%, transparent);
  box-shadow: var(--shadow-2); animation: pop .16s var(--ease);
}
.bulk-bar__count { font-weight: 700; }
.bulk-bar__spacer { flex: 1; }

/* ---------- Cartoes ---------- */
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.lib-grid--row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lib-card {
  position: relative; display: flex; flex-direction: column; border-radius: 14px; background: var(--c-surface);
  border: 1px solid var(--c-border-soft); transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s;
  -webkit-touch-callout: none;
}
.lib-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.lib-card.is-selected { border-color: var(--c-accent); box-shadow: 0 0 0 2px var(--c-accent), var(--shadow-1); }
.lib-card.is-menu-open { z-index: 120; transform: none !important; transition: none; }
.lib-card__thumb {
  display: grid; place-items: center; height: 156px; padding: 16px; border-radius: 13px 13px 0 0; overflow: hidden;
  background: repeating-conic-gradient(var(--c-surface-2) 0% 25%, var(--c-surface) 0% 50%) 50% / 16px 16px;
}
.lib-card__thumb img { max-width: 100%; max-height: 122px; width: auto; height: auto; border-radius: 4px; background: #fff; box-shadow: var(--shadow-2); -webkit-user-drag: none; }
.lib-card__placeholder { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: var(--c-surface); }
.lib-card__meta { display: grid; gap: 3px; padding: 10px 44px 12px 12px; min-width: 0; }
.lib-card__title { font-weight: 650; color: var(--c-text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-card__title:hover { text-decoration: underline; text-underline-offset: 2px; }
.lib-card__info { display: flex; gap: 5px; flex-wrap: wrap; font-size: 12px; color: var(--c-text-2); }
.lib-card__folder { display: inline-flex; align-items: center; gap: 4px; width: fit-content; max-width: 100%; margin-top: 3px; padding: 1px 8px 1px 6px; border-radius: 999px; background: var(--c-surface-2); font-size: 11.5px; font-weight: 600; color: var(--c-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card__more { position: absolute; right: 6px; bottom: 8px; }
@media (min-width: 600px) { .lib-card__menu { right: 0; top: auto; bottom: calc(100% + 4px); } }
.lib-card__check {
  position: absolute; z-index: 2; top: 8px; left: 8px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: color-mix(in srgb, var(--c-surface) 92%, transparent); box-shadow: var(--shadow-1); cursor: pointer;
  opacity: 0; transition: opacity .15s;
}
.lib-card__check input { width: 18px; height: 18px; accent-color: var(--c-accent); cursor: pointer; margin: 0; }
.lib-card:hover .lib-card__check, .lib-card__check:focus-within, .lib-card.is-selected .lib-card__check, .library:has(.bulk-bar) .lib-card__check { opacity: 1; }
.lib-card--compact .lib-card__meta { padding-right: 12px; }
.lib-card--skeleton { height: 224px; background: linear-gradient(90deg, var(--c-surface) 25%, var(--c-surface-2) 50%, var(--c-surface) 75%) 0 0 / 200% 100%; animation: shimmer 1.2s infinite; }
.lib-more { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- Estados vazios ---------- */
.empty-state {
  display: grid; justify-items: center; gap: 8px; text-align: center; padding: 48px 24px; border-radius: 18px;
  border: 1px dashed var(--c-border); background: color-mix(in srgb, var(--c-surface) 70%, transparent); color: var(--c-text-2);
}
.empty-state strong { font: 700 18px var(--font-display); color: var(--c-text); }
.empty-state span { max-width: 46ch; }
.empty-state--compact { padding: 32px 20px; }
.empty-state--inline { justify-items: start; text-align: left; padding: 18px 20px; }
.empty-state--inline strong { font-size: 15px; }
.empty-state--error { border-style: solid; border-color: color-mix(in srgb, var(--c-danger) 30%, transparent); }
.empty-state__actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.empty-state__art { position: relative; width: 120px; height: 84px; margin-bottom: 6px; }
.empty-state__art span { position: absolute; background: #fff; border-radius: 8px; border: 1px solid var(--c-border-soft); box-shadow: var(--shadow-2); }
.empty-state__art span:nth-child(1) { width: 70px; height: 46px; left: 0; top: 18px; transform: rotate(-8deg); }
.empty-state__art span:nth-child(2) { width: 60px; height: 40px; right: 0; top: 4px; transform: rotate(7deg); }
.empty-state__art span:nth-child(3) { width: 64px; height: 42px; left: 30px; bottom: 0; background: var(--c-accent-soft); border-color: color-mix(in srgb, var(--c-accent) 30%, transparent); }
.empty-state__icon { opacity: .6; }

/* ---------- Lixeira ---------- */
.trash-note { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--c-surface-2); color: var(--c-text-2); font-size: 13px; }
.trash-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.trash-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; border-radius: 14px;
  background: var(--c-surface); border: 1px solid var(--c-border-soft);
}
.trash-row__icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--c-surface-2); }
.trash-row__text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.trash-row__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-row__meta { display: flex; gap: 6px 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--c-text-2); }
.trash-row__purge { color: var(--c-warn); font-weight: 600; }
.trash-row__actions { display: flex; gap: 6px; flex: none; }
.trash-row--skeleton { height: 70px; background: linear-gradient(90deg, var(--c-surface) 25%, var(--c-surface-2) 50%, var(--c-surface) 75%) 0 0 / 200% 100%; animation: shimmer 1.2s infinite; }

/* ---------- Inicio: secoes com link "ver todos" ---------- */
.section__header { justify-content: space-between; }
.section__link { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; text-decoration: none; }
.section__link:hover { text-decoration: underline; text-underline-offset: 3px; }
.hero__hint { position: relative; z-index: 1; margin: 14px 0 0; font-size: 12.5px; color: var(--c-text-2); }
.template-grid--row { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); grid-auto-rows: auto; }

/* ---------- Avisos com acao ("Desfazer", "Ver") ---------- */
.toast__action {
  border: 0; background: color-mix(in srgb, #fff 12%, transparent); color: #8FE3F5; font: 700 13px var(--font-ui);
  height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer;
}
.toast__action:hover { background: color-mix(in srgb, #fff 20%, transparent); }

/* ---------- Dialogos de nome/pasta ---------- */
.prompt__form, .save-dialog__form { display: grid; gap: 14px; }
.prompt__input { height: 40px; font-size: 15px; }
.prompt__meta { display: flex; justify-content: space-between; gap: 8px; min-height: 16px; }
.prompt__count { font-size: 11.5px; color: var(--c-text-2); font-variant-numeric: tabular-nums; margin-left: auto; }
.prompt__count.is-over { color: var(--c-danger); font-weight: 700; }
.confirm__message { margin: 0; color: var(--c-text-2); }
.modal--sheet .modal__footer .btn { min-width: 96px; }
.folder-list { display: grid; gap: 4px; max-height: 280px; overflow-y: auto; margin-bottom: 14px; }
.folder-option {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
}
.folder-option:hover { background: var(--c-surface-2); }
.folder-option.is-selected { border-color: color-mix(in srgb, var(--c-accent) 45%, transparent); background: var(--c-accent-soft); }
.folder-option input { accent-color: var(--c-accent); }
.folder-option__name { flex: 1; font-weight: 600; }
.folder-option__count { font-size: 12px; color: var(--c-text-2); }
.folder-new { display: flex; align-items: flex-end; gap: 8px; }
.folder-new__add { height: 34px; }

/* ---------- Editor: voltar, caminho e titulo ---------- */
.topbar__crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px 0 8px; border-radius: 8px;
  color: var(--c-text-2); font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s, color .15s;
}
.back-link:hover { background: var(--c-surface-2); color: var(--c-text); }
.crumb-sep { color: var(--c-border); font-size: 18px; font-weight: 300; }
.doc-title {
  display: inline-flex; align-items: center; gap: 6px; max-width: clamp(140px, 24vw, 340px); height: 34px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--c-text); cursor: text;
  font: 700 15px var(--font-display); letter-spacing: -.01em;
}
.doc-title:hover { border-color: var(--c-border); }
.doc-title__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-title__pencil { flex: none; opacity: 0; transition: opacity .15s; }
.doc-title:hover .doc-title__pencil, .doc-title:focus-visible .doc-title__pencil { opacity: .8; }
.doc-title--editing { position: relative; display: inline-flex; padding: 0; border: 0; }
.doc-title__input {
  width: clamp(180px, 26vw, 360px); height: 34px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--c-accent);
  background: var(--c-surface); color: var(--c-text); font: 700 15px var(--font-display); box-shadow: 0 0 0 3px var(--c-accent-soft); outline: 0;
}
.doc-title--editing.is-invalid .doc-title__input { border-color: var(--c-danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-danger) 15%, transparent); }
.doc-title__error {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 30; white-space: nowrap; padding: 6px 10px; border-radius: 8px;
  background: var(--c-danger); color: #fff; font-size: 12px; font-weight: 600; box-shadow: var(--shadow-2);
}
.topbar__back {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 8px 0 6px; border-radius: 10px; flex: none;
  color: var(--c-text); text-decoration: none; font: 600 13px var(--font-ui);
}
.topbar__back:active { background: var(--c-surface-2); }
.doc-title--compact { max-width: 100%; height: 36px; font-size: 15px; padding: 0 4px; }
.topbar--compact .doc-title--editing, .topbar--compact .doc-title__input { width: 100%; min-width: 0; }
.topbar--medium .doc-title { max-width: clamp(110px, 18vw, 220px); }

/* ---------- Telas largas e estreitas ---------- */
@media (max-width: 1100px) {
  .lib-grid--row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 599.98px) {
  .app-nav { display: none; }
  .page { padding: 16px calc(14px + var(--safe-right, 0px)) 40px calc(14px + var(--safe-left, 0px)); }
  .page__header { align-items: center; margin-bottom: 14px; }
  .page__heading h1 { font-size: 26px; }
  .page__header > .btn--lg { height: 40px; padding: 0 14px; }
  .library__tabs { display: flex; }
  .lib-tab { flex: 1; height: 40px; }
  .search-box { flex-basis: 100%; max-width: none; height: 44px; }
  .sort-select { flex: 1; }
  .sort-select .field__input { flex: 1; }
  .folder-bar { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px 14px; padding: 0 14px 2px; scrollbar-width: none; }
  .folder-bar::-webkit-scrollbar { display: none; }
  .folder-chip { flex: none; height: 36px; }
  .bulk-bar { top: calc(64px + var(--safe-top, 0px)); padding: 8px; }
  .bulk-bar__count { width: 100%; padding-left: 6px; }
  .lib-grid, .lib-grid--row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .lib-card__thumb { height: 112px; padding: 10px; }
  .lib-card__thumb img { max-height: 90px; }
  .lib-card__meta { padding: 8px 40px 10px 10px; }
  .lib-card__title { font-size: 13.5px; }
  .lib-card__info { font-size: 11.5px; }
  .lib-card__check { opacity: 1; width: 34px; height: 34px; }
  .library:not(:has(.bulk-bar)) .lib-card__check { opacity: 0; pointer-events: none; }
  .lib-card__more { right: 2px; bottom: 4px; }
  .trash-row { flex-wrap: wrap; }
  .trash-row__actions { width: 100%; }
  .trash-row__actions .btn { flex: 1; }
  .template-grid--row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section__link { font-size: 13px; }

  /* dialogos pequenos: gaveta de baixo (nao tela cheia) */
  .modal-backdrop:has(.modal--sheet) { place-items: end stretch; background: rgba(12, 18, 24, .42); }
  .modal.modal--sheet { position: relative; height: auto; max-height: 88dvh; border-radius: 20px 20px 0 0; }
  .modal.modal--sheet .modal__header { border-bottom: 0; padding-top: 18px; }
  .modal.modal--sheet .modal__header::before {
    content: ""; position: absolute; left: 50%; top: 7px; width: 42px; height: 5px; margin-left: -21px; border-radius: 3px;
    background: color-mix(in srgb, var(--c-text) 22%, transparent);
  }
  .modal.modal--sheet .modal__footer { flex-wrap: wrap; }
  .modal.modal--sheet .modal__footer .btn { flex: 1 1 0; height: 46px; font-size: 15px; }
  .leave-dialog .modal__footer .btn--accent { order: -1; flex-basis: 100%; }
  .folder-new__add { height: 44px; }
  .doc-title__error { white-space: normal; max-width: 70vw; }
}
/* rotulo do voltar so quando sobra espaco para o titulo */
@media (max-width: 429.98px) {
  .topbar__back-label { display: none; }
}
@media (hover: none) {
  .lib-card:hover { transform: none; box-shadow: none; }
  .lib-card:not(.is-menu-open):active { transform: scale(.985); }
  .doc-title__pencil { opacity: .6; }
}

/* Historico: trabalho cancelado (nao e falha) */
.pill--neutral { background: var(--c-surface-2); color: var(--c-text-2); }

/* Texto so para leitores de tela (e testes): a bolinha do celular continua sendo so a cor */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* toque: nao ha arrastar arquivo para a tela */
@media (pointer: coarse) { .hero__hint { display: none; } }

.lib-card__badge { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--c-accent); }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.share-list li { display: grid; grid-template-columns: 1fr 200px; align-items: center; gap: 12px; }
