:root {
  --bg: #0f1218;
  --surface: #181c27;
  --border: #2a3142;
  --text: #e8eaef;
  --muted: #9aa3b5;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --danger: #e85656;
  --danger-hover: #f07070;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.logo {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.arquivo-db {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
}

.arquivo-db-label {
  color: var(--muted);
}

.arquivo-db code {
  font-size: 0.85em;
  background: var(--bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.ultima-copia-linha {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  line-height: 1.35;
}

.ultima-copia-label {
  color: var(--muted);
}

.tempo-desde-copia {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
}

.tempo-desde-copia.tempo-desde-copia--ativo {
  color: #2dd4bf;
  text-shadow: 0 0 12px rgba(45, 212, 191, 0.35);
}

.tempo-desde-copia.tempo-desde-copia--aguardando {
  color: var(--muted);
  font-weight: 500;
  text-shadow: none;
}

.btn-link {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: var(--accent-hover);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  border-color: #3d475c;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  background: transparent;
  border-color: #5c3030;
  color: var(--danger);
}

.btn-danger:hover {
  background: #2a1515;
  border-color: var(--danger);
  color: var(--danger-hover);
}

.view {
  display: none;
}

.view-active {
  display: block;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

/* Listagem mais baixa (menos padding e linhas mais curtas) */
#viewLista .panel {
  padding: 0.85rem 1rem;
}

#viewLista .panel-head {
  margin-bottom: 0.55rem;
}

.form-panel .panel-head {
  flex-direction: column;
  align-items: stretch;
}

.form-panel .panel-head h2 {
  margin-top: 0.25rem;
}

.btn-back {
  align-self: flex-start;
  padding-left: 0.35rem;
  padding-right: 0.65rem;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.lista {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lista-row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
}

.lista-indice {
  flex-shrink: 0;
  align-self: center;
  min-width: 1.5rem;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  user-select: none;
}

.lista-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.4rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  line-height: 1.25;
  transition: border-color 0.15s, background 0.15s;
}

.btn-copiar-lista {
  flex-shrink: 0;
  align-self: center;
  padding: 0.28rem 0.5rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.lista-item:hover {
  border-color: #3d5580;
  background: #141820;
}

.lista-item-title {
  font-weight: 600;
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.25;
}

.empty {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

.field input,
.field textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  width: 100%;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.25);
}

.field textarea {
  resize: vertical;
  min-height: 160px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.form-actions-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.65rem 1.1rem;
  background: #252b3a;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 100;
  max-width: min(90vw, 420px);
  text-align: center;
}

.toast.error {
  border-color: #5c3030;
  color: #f5a8a8;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 200;
  /* Cliques passam para a página (ex.: «Nova mensagem»); só o cartão recebe cliques. */
  pointer-events: none;
}

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.65rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.overlay-title {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.overlay-text {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
}

.overlay-text:last-of-type {
  margin-bottom: 1.25rem;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.overlay-footnote {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
