/* ============================================
   Trilha Thaina — Premium · suave · feminino
   Inspiração: Glossier · Aesop · Granado
   Paleta dessaturada, tipografia editorial
   ============================================ */

:root {
  /* Cores — paleta sofisticada e quase monocromática */
  --ivory:        #FAF6F1;   /* fundo principal */
  --ivory-deep:   #F2EBE3;   /* superfícies suaves */
  --paper:        #FFFFFF;   /* cards */

  --ink:          #2A1F26;   /* texto primário (quase preto, com fundo aubergine) */
  --ink-2:        #5C4E55;   /* texto secundário */
  --ink-3:        #8E7F86;   /* terciário */
  --ink-4:        #BEB1B6;   /* desabilitado / placeholders */

  --rose:         #B88A95;   /* dusty rose (acento principal) */
  --rose-deep:    #8E5E6C;   /* hover / texto sobre rose */
  --rose-soft:    #EFDDDF;   /* fundo de destaque suave */
  --rose-tint:    #FAF0EE;   /* tinte de fundo */

  --wine:         #5E3742;   /* acento profundo, raríssimo */
  --gold:         #B89968;   /* dourado discreto (concluído/destaque) */
  --sage:         #8BA89A;   /* concluído (verde acinzentado) */

  --line:         #E8DDD4;   /* linhas e borders */
  --line-soft:    #F2E9E1;

  --shadow-xs:    0 1px 2px rgba(58, 30, 38, 0.04);
  --shadow-sm:    0 4px 16px rgba(58, 30, 38, 0.06);
  --shadow-md:    0 10px 32px rgba(58, 30, 38, 0.08);
  --shadow-lg:    0 24px 64px rgba(58, 30, 38, 0.10);

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Tipografia */
  --font-display: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--ivory);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  padding-bottom: 64px;
}

img, video, audio { max-width: 100%; display: block; }

::selection { background: var(--rose-soft); color: var(--ink); }

/* ---------- Tipografia ---------- */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
h1 { font-size: 32px; font-weight: 300; }
h1 em { font-style: italic; font-weight: 300; color: var(--rose-deep); }
h2 { font-size: 22px; font-weight: 400; }
h3 { font-size: 17px; font-weight: 500; font-family: var(--font-body); letter-spacing: -0.01em; }

.eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.muted   { color: var(--ink-2); }
.muted-2 { color: var(--ink-3); }
.tiny    { font-size: 12.5px; color: var(--ink-3); }

/* ---------- Container ---------- */
.container {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 246, 241, 0.78);
  backdrop-filter: saturate(140%) blur(18px);
  -webkit-backdrop-filter: saturate(140%) blur(18px);
  border-bottom: 1px solid var(--line-soft);
}
.app-header-inner {
  max-width: 580px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-logo {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.app-logo em { font-style: italic; color: var(--rose-deep); font-weight: 300; }
.app-logo .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--rose);
  display: inline-block;
  margin: 0 2px;
  position: relative;
  top: -2px;
}

.app-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--rose-soft);
  color: var(--rose-deep);
  display: grid; place-items: center;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  border: 1px solid var(--rose);
  font-family: var(--font-display);
}

/* ---------- Card ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.card-flat {
  background: transparent;
  border: 1px solid var(--line);
  box-shadow: none;
}
.card-tint {
  background: var(--rose-tint);
  border-color: var(--rose-soft);
}

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  text-decoration: none;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  min-height: 46px;
}
.btn:active { transform: scale(.98); }

.btn-primary {
  background: var(--ink);
  color: var(--ivory);
}
.btn-primary:hover { background: var(--wine); }

.btn-rose {
  background: var(--rose);
  color: var(--paper);
}
.btn-rose:hover { background: var(--rose-deep); }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-outline:hover { border-color: var(--ink); }

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  padding: 10px 16px;
  min-height: auto;
}
.btn-ghost:hover { color: var(--ink); }

.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 13px; min-height: 36px; }

/* ---------- Input ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.input, textarea.input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--ink-4); }
.input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--rose-soft);
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.6; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 0%, var(--rose-soft) 0%, transparent 55%),
    radial-gradient(ellipse at 100% 100%, var(--ivory-deep) 0%, transparent 60%),
    var(--ivory);
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 44px 36px 36px;
  box-shadow: var(--shadow-md);
  text-align: center;
}
.login-monogram {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 300;
  font-style: italic;
  color: var(--rose-deep);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}
.login-divider {
  display: block;
  width: 32px;
  height: 1px;
  background: var(--rose);
  margin: 14px auto 18px;
}
.login-title { font-size: 26px; margin-bottom: 6px; }
.login-sub { color: var(--ink-2); font-size: 14px; margin-bottom: 32px; line-height: 1.55; }

/* ---------- Alert ---------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  text-align: left;
  border: 1px solid;
}
.alert-error   { background: #FBEFEF; color: #862020; border-color: #F0D4D4; }
.alert-success { background: #EEF4F0; color: #3F6B53; border-color: #D6E4DB; }
.alert-info    { background: var(--rose-tint); color: var(--rose-deep); border-color: var(--rose-soft); }

/* ---------- Hero do dashboard ---------- */
.hero {
  padding: 8px 4px 28px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 28px;
}
.hero .eyebrow { color: var(--rose-deep); }
.hero h1 { font-size: 34px; margin-top: 8px; }
.hero p { color: var(--ink-2); font-size: 15px; margin-top: 12px; max-width: 460px; }

.progress-shell {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.progress-bar {
  flex: 1;
  height: 4px;
  background: var(--line);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--rose);
  border-radius: var(--r-pill);
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.progress-num {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 4px;
}
.section-title h2 { font-size: 18px; font-family: var(--font-body); font-weight: 600; letter-spacing: -0.01em; }

/* ---------- Lista de módulos ---------- */
.module-list {
  display: flex;
  flex-direction: column;
}
.module-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 20px 4px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  transition: background .2s;
}
.module-card:hover {
  background: var(--rose-tint);
  margin: 0 -16px;
  padding-left: 20px;
  padding-right: 20px;
  border-radius: var(--r-sm);
  border-bottom-color: transparent;
}
.module-card:last-child { border-bottom: none; }

.module-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 300;
  font-style: italic;
  color: var(--rose);
  min-width: 36px;
  line-height: 1;
}
.module-meta { min-width: 0; }
.module-meta .title {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.module-meta .sub {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.45;
}
.module-meta .timing {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.module-status {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid;
  white-space: nowrap;
}
.status-todo  { color: var(--ink-3); border-color: var(--line); }
.status-doing { color: var(--rose-deep); border-color: var(--rose); background: var(--rose-tint); }
.status-done  { color: var(--sage); border-color: var(--sage); background: #EEF4F0; }

/* ---------- Audio player ---------- */
.audio-player {
  background: var(--ivory-deep);
  border-radius: var(--r-md);
  padding: 20px;
  margin-bottom: 24px;
}
.audio-player .label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
  font-weight: 500;
}
.audio-player audio {
  width: 100%;
}

/* ---------- Checklist ---------- */
.checklist { list-style: none; }
.checklist li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: padding .2s, background .2s;
}
.checklist li:last-child { border-bottom: none; }
.checklist li:hover { padding-left: 8px; }
.checklist li.checked .check-text { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 0.5px; }

.check-box {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--ink-4);
  background: var(--paper);
  display: grid; place-items: center;
  margin-top: 2px;
  font-size: 11px;
  color: transparent;
  transition: all .2s;
}
.checklist li.checked .check-box {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.check-text { font-size: 14.5px; line-height: 1.55; flex: 1; color: var(--ink); }

.checklist-section {
  font-family: var(--font-display);
  font-size: 15px;
  font-style: italic;
  font-weight: 400;
  color: var(--rose-deep);
  margin: 24px 0 4px;
  letter-spacing: -0.01em;
}
.checklist-section:first-child { margin-top: 8px; }

/* ---------- Upload area ---------- */
.upload-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.upload-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  background: var(--ivory);
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}
.upload-btn:hover {
  background: var(--rose-tint);
  border-color: var(--rose);
  color: var(--rose-deep);
}
.upload-btn svg { width: 22px; height: 22px; stroke-width: 1.5; }
.upload-btn input { display: none; }

.uploads-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.upload-thumb {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--ivory-deep);
  position: relative;
  border: 1px solid var(--line-soft);
}
.upload-thumb img { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb .audio-ico {
  width: 100%; height: 100%;
  background: var(--rose-tint);
  color: var(--rose-deep);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
}
.upload-thumb .timestamp {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 6px 8px;
  font-size: 10px;
  letter-spacing: 0.04em;
  background: linear-gradient(transparent, rgba(42,31,38,.7));
  color: white;
  text-align: center;
}

/* ---------- Save indicator ---------- */
.save-indicator {
  position: fixed;
  top: 76px; right: 20px;
  background: var(--ink);
  color: var(--ivory);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity .25s, transform .25s;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.save-indicator.show { opacity: 1; transform: translateY(0); }

/* ---------- Admin ---------- */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line-soft);
}
.admin-tab {
  flex-shrink: 0;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  transition: color .2s, border-color .2s;
}
.admin-tab:hover { color: var(--ink); }
.admin-tab.active {
  color: var(--ink);
  border-bottom-color: var(--rose);
}

.admin-row {
  padding: 20px 0;
  border-bottom: 1px solid var(--line-soft);
}
.admin-row:last-child { border-bottom: none; }

.note-quote {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  color: var(--ink);
  line-height: 1.5;
  padding: 14px 18px;
  border-left: 2px solid var(--rose);
  background: var(--rose-tint);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-top: 12px;
}

/* ---------- Utils ---------- */
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.text-center { text-align: center; }
.divider {
  height: 1px; background: var(--line-soft); margin: 24px 0;
}
.divider-elegant {
  display: flex; align-items: center; gap: 12px;
  margin: 32px 0;
  color: var(--ink-3);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.divider-elegant::before, .divider-elegant::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE FIXES — iOS PWA, safe area, touch targets, overflow
   ═══════════════════════════════════════════════════════════════════ */

/* iOS safe-area: respeita notch + home indicator */
.app-header {
  padding-top: env(safe-area-inset-top, 0);
}
body {
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.fab {
  bottom: calc(20px + env(safe-area-inset-bottom, 0)) !important;
}

/* Header com 9 itens — scroll horizontal no mobile (não quebra) */
.app-user {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.app-user::-webkit-scrollbar { display: none; }
.app-user > a, .app-user > span { flex-shrink: 0; }

/* Inputs sempre 16px no mobile (evita zoom-on-focus do iOS) */
@media (max-width: 768px) {
  .input, input[type="text"], input[type="search"], input[type="email"],
  input[type="number"], input[type="date"], input[type="tel"], textarea, select {
    font-size: 16px !important;
  }
}

/* Touch targets mínimos 44×44 — botões ×, ícones, links pequenos */
button[title="Excluir"],
button[title="Cancelar"],
button[title="Fechar"],
#closeModal,
#closeAudioModal,
[data-delete-item],
[data-delete-aula],
.iosBanner button,
#iosInstallBanner button {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Tabelas markdown não estouram — wrap horizontal */
#resultadoMd table,
#resMd table,
.markdown-output table,
article.card-flat table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  white-space: nowrap;
}
#resultadoMd table th,
#resultadoMd table td,
#resMd table th,
#resMd table td {
  padding: 6px 10px;
  border: 1px solid var(--rose-soft);
  font-size: 12.5px;
  white-space: normal;
}

/* FAB não cobre conteúdo no final da página */
main.container {
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0));
}

/* Contraste tiny — escurecer cor */
.tiny {
  color: var(--ink-2);
}

/* Cards/modais com max-height respeitando viewport real */
.modal-overlay > div, [role="dialog"] > div {
  max-height: calc(90dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
}

/* Scroll indicator nos admin-tabs (mostra que tem mais à direita) */
.admin-tabs {
  position: relative;
  scroll-snap-type: x proximity;
}
.admin-tabs > * { scroll-snap-align: start; }

/* Modal background tap-to-close cursor hint */
#aulaModal, #quickAudioModal, #onboardingOverlay { cursor: pointer; }
#aulaModal > div, #quickAudioModal > div, #onboardingOverlay > div { cursor: default; }

