/* Tokens visuais da skill `padroes-visuais` (tema escuro + claro). */
:root {
  --bg-color: #2e2d2b;
  --text-main: #f1f5f9;
  --text-muted: rgba(241, 245, 249, 0.62);
  --icon-color: #f1f5f9;
  --menu-bg: #262524;
  --menu-border: rgba(255, 255, 255, 0.12);
  --btn-ctrl-bg: rgba(255, 255, 255, 0.05);
  --btn-ctrl-border: rgba(255, 255, 255, 0.15);
  --btn-hover-bg: rgba(255, 255, 255, 0.1);
  --btn-primary-bg: #f1f5f9;
  --btn-primary-text: #1c1b1a;
  --btn-primary-hover: #ffffff;
  --input-bg: rgba(0, 0, 0, 0.22);
  --focus-border: rgba(255, 255, 255, 0.5);
  --view-bg: rgba(38, 37, 36, 0.86);
  --vignette-color: rgba(0, 0, 0, 0);
  --scrollbar-thumb: rgba(255, 255, 255, 0.16);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.35);
  --danger: #f0a6a0;
  --warn: #e8c07d;
  --ok: #9ecf9a;
  --radius: 14px;
  --curve: cubic-bezier(0.333333, 0, 0.666667, 1);
  color-scheme: dark;
  font-family: 'Atkinson Hyperlegible Next', 'Plus Jakarta Sans', -apple-system,
    BlinkMacSystemFont, sans-serif;
}

/* Tema claro (a classe vai no <html> e no <body>). */
html.light-theme,
body.light-theme {
  --bg-color: #faf9f6;
  --text-main: #0f172a;
  --text-muted: rgba(15, 23, 42, 0.62);
  --icon-color: #0f172a;
  --menu-bg: #ffffff;
  --menu-border: rgba(0, 0, 0, 0.12);
  --btn-ctrl-bg: rgba(0, 0, 0, 0.04);
  --btn-ctrl-border: rgba(0, 0, 0, 0.12);
  --btn-hover-bg: rgba(0, 0, 0, 0.08);
  --btn-primary-bg: #0f172a;
  --btn-primary-text: #faf9f6;
  --btn-primary-hover: #1e293b;
  --input-bg: rgba(0, 0, 0, 0.03);
  --focus-border: rgba(15, 23, 42, 0.5);
  --view-bg: rgba(250, 249, 246, 0.88);
  --vignette-color: rgba(230, 229, 221, 0.4);
  --scrollbar-thumb: rgba(0, 0, 0, 0.16);
  --scrollbar-thumb-hover: rgba(0, 0, 0, 0.35);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* O atributo `hidden` precisa vencer o `display` dos componentes. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-color);
  color: var(--text-main);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 15px;
  font-weight: 300;
  line-height: 1.7;
  letter-spacing: -0.005em;
  transition: color 100ms var(--curve), background 100ms var(--curve);
}

a {
  color: var(--text-main);
  text-underline-offset: 3px;
}

button {
  font: inherit;
}

/* Barra de rolagem no tema (skill). */
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: content-box;
}
@supports (-moz-appearance: none) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
  }
}

/* ------- topo ------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--view-bg);
  border-bottom: 1px solid var(--menu-border);
  backdrop-filter: blur(18px) saturate(1.05);
  transition: background 100ms var(--curve), border-color 100ms var(--curve);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.logo-svg {
  width: 19px;
  height: 19px;
  color: var(--icon-color);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}


.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 12px rgba(158, 207, 154, 0.7);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}


/* ------- botões ------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--btn-ctrl-border);
  background: var(--btn-ctrl-bg);
  color: var(--text-main);
  cursor: pointer;
  transition: opacity 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.btn:hover {
  background: var(--btn-hover-bg);
}
.btn:focus-visible {
  outline: 2px solid var(--text-main);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border-color: transparent;
  font-weight: 500;
}
.btn-primary:hover {
  background: var(--btn-primary-hover);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-danger {
  color: var(--danger);
  border-color: rgba(240, 166, 160, 0.35);
}
.btn-small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.82rem;
}

/* Botão de ícone (38×38, redondo, sem borda nem fundo — skill). O fundo é o
   próprio painel onde ele está (topo, rodapé ou barra de filtros). */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--icon-color);
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease, transform 0.6s ease;
}
.icon-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.2;
}
.icon-btn:hover {
  background: var(--btn-hover-bg);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--text-main);
  outline-offset: 2px;
}
.icon-btn.rotating {
  transform: rotate(180deg) scale(0.85);
  opacity: 0;
}

/* ------- aviso ------- */
.banner {
  margin: 16px 24px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--menu-border);
  background: var(--menu-bg);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.banner.warn {
  border-color: rgba(232, 192, 125, 0.5);
}
.banner.error {
  border-color: rgba(240, 166, 160, 0.5);
}

/* ------- telas centrais ------- */
.root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.screen.center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 64px;
}
.card {
  width: min(440px, 100%);
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--menu-border);
  background: var(--menu-bg);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.35);
}
.card h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.card p.muted,
.muted {
  color: var(--text-muted);
}
.card p {
  margin: 0 0 18px;
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  font-weight: 300;
}

/* ------- formulários ------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--btn-ctrl-border);
  background: var(--input-bg);
  color: var(--text-main);
  font: inherit;
  transition: border-color 0.3s ease;
}
.field textarea {
  min-height: 120px;
  resize: vertical;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--focus-border);
}
.field input[type='file'] {
  padding: 8px;
  font-size: 0.85rem;
}
.field .hint {
  font-size: 0.76rem;
  color: var(--text-muted);
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}
.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
  margin-top: 10px;
}

/* ------- app ------- */
.screen.app {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 0;
}
.list-pane {
  border-right: 1px solid var(--menu-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.filter-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--view-bg);
  border-bottom: 1px solid var(--menu-border);
  -webkit-backdrop-filter: blur(18px) saturate(1.05);
  backdrop-filter: blur(18px) saturate(1.05);
}
.filter-tabs {
  display: flex;
  gap: 12px;
}
.filter-bar .icon-btn {
  color: var(--text-muted);
}
.filter-bar .icon-btn.active {
  color: var(--text-main);
  background: var(--btn-hover-bg);
}
/* Escrever: à direita, separado por um divisor sutil dos filtros. */
.filter-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}
.filter-bar .filter-right .icon-btn {
  color: var(--text-main);
}
.filter-divider {
  width: 1px;
  height: 20px;
  background: var(--menu-border);
}
.list-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.list-body {
  padding: 8px;
}
.group-title {
  margin: 12px 8px 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.msg {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.3s ease;
}
.msg:hover {
  background: var(--btn-ctrl-bg);
}
.msg.active {
  background: var(--btn-ctrl-bg);
  border-color: var(--btn-ctrl-border);
}
.msg .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.msg .from {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg .subject {
  font-size: 0.86rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg.unread .from {
  font-weight: 600;
}
.msg.unread .subject {
  color: var(--text-main);
  font-weight: 500;
}
.msg .when {
  flex: none;
  font-size: 0.74rem;
  color: var(--text-muted);
}
.tag {
  display: inline-block;
  font-size: 0.68rem;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--btn-ctrl-border);
  color: var(--text-muted);
}
.tag.warn {
  color: var(--warn);
  border-color: rgba(232, 192, 125, 0.5);
}

.read-pane {
  padding: 24px;
  overflow-y: auto;
  min-width: 0;
}
.read-pane .placeholder {
  color: var(--text-muted);
  margin-top: 40px;
  text-align: center;
}
.reader-head {
  border-bottom: 1px solid var(--menu-border);
  padding-bottom: 14px;
  margin-bottom: 16px;
}
.reader-head h2 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 500;
  line-height: 1.25;
}
.reader-meta {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: grid;
  gap: 2px;
}
.body-text {
  white-space: pre-wrap;
  word-wrap: break-word;
  font: inherit;
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
  margin: 0;
}
.html-frame {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--menu-border);
  border-radius: 10px;
  background: #ffffff;
}
.section-title {
  margin: 22px 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attachment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--menu-border);
  border-radius: 10px;
  background: var(--btn-ctrl-bg);
}
.attachment .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------- composição ------- */
.compose {
  width: min(720px, 100%);
}
.compose h2 {
  margin-top: 0;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 500;
  line-height: 1.25;
}

.reset-steps {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--menu-border);
  background: var(--input-bg);
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre;
}

/* ------- rodapé ------- */
.footer {
  position: sticky;
  bottom: 0;
  z-index: 6;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--view-bg);
  border-top: 1px solid var(--menu-border);
  transition: background 100ms var(--curve), border-color 100ms var(--curve);
}
/* Tema sempre à direita, mesmo quando só ele aparece (antes do login). */
.footer #theme {
  margin-left: auto;
}

/* ------- responsivo ------- */
@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
  }
  .footer {
    padding: 10px 16px;
  }
  .screen.app {
    grid-template-columns: 1fr;
  }
  .list-pane {
    border-right: none;
    border-bottom: 1px solid var(--menu-border);
    max-height: 45vh;
  }
  .read-pane {
    padding: 18px 16px 48px;
  }
  .banner {
    margin: 12px 16px 0;
  }
}
