/* ReTurma — visual estilo Instagram (branco/cinza, azul #0095F6,
   degradê amarelo→laranja→rosa→roxo nos detalhes), identidade
   própria: nome, busca escolar e selo "estudou com você". */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Sem isso, classes com display próprio (ex.: .form{display:flex})
   anulam o atributo hidden e formulários "escondidos" aparecem. */
[hidden] { display: none !important; }

:root {
  --text: #262626;
  --muted: #737373;
  --line: #dbdbdb;
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --blue: #0095f6;
  --blue-dark: #1877f2;
  --yellow-badge: #ffc53d;
  --heart: #ff3040;
  --gradient: linear-gradient(45deg, #ffc53d, #ff7a45, #e1306c, #833ab4);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
}

.view { max-width: 480px; margin: 0 auto; min-height: 100dvh; background: var(--bg); }

.logo {
  font-size: 2.4rem; font-weight: 800; letter-spacing: -0.5px; text-align: center;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo.small { font-size: 1.5rem; }
.slogan { text-align: center; font-weight: 600; margin-top: 2px; }
.auth-note { text-align: center; color: var(--muted); font-size: 0.92rem; margin: 8px 0 18px; }
.legal { color: var(--muted); font-size: 0.75rem; text-align: center; margin: 14px 8px; }
.legal.center { padding-bottom: 90px; }

.auth-wrap { padding: 36px 20px 24px; }
.step-title { text-align: center; margin-top: 10px; }

.card {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  padding: 16px; margin-top: 12px;
}
.card-title { font-size: 1rem; margin-bottom: 10px; }
.posts-title { margin: 18px 4px 8px; }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab {
  flex: 1; background: none; border: none; padding: 10px 0; font-size: 0.95rem;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--text); }

.form { display: flex; flex-direction: column; gap: 12px; }
.form label, .lbl { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; margin-bottom: 10px; }
.form label { margin-bottom: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-soft); font-size: 0.95rem; color: var(--text); font-weight: 400;
}
textarea { resize: vertical; }

.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.check input { width: 18px; height: 18px; }

.fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.fieldset legend { font-size: 0.85rem; font-weight: 700; padding: 0 6px; }
.row { display: flex; gap: 10px; }
.row > label { flex: 1; }
.hint { color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.muted { color: var(--muted); }
.error { color: #c62828; font-size: 0.88rem; }
.info { color: #1b7a43; font-size: 0.88rem; }

.btn-primary {
  background: var(--blue); color: #fff; border: none; border-radius: 10px;
  padding: 11px 16px; font-size: 0.95rem; font-weight: 700; cursor: pointer; width: 100%;
}
.btn-primary:active { background: var(--blue-dark); }
.btn-primary.slim { width: auto; padding: 8px 14px; }
.btn-link { background: none; border: none; color: var(--blue); font-weight: 600; cursor: pointer; padding: 6px; }
.btn-danger {
  width: 100%; margin-top: 20px; background: none; border: 1px solid var(--line);
  color: #c62828; border-radius: 10px; padding: 11px; font-weight: 700; cursor: pointer;
}

.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text); padding: 4px; font-size: 1.2rem; }
.icon { width: 26px; height: 26px; }

.page { padding: 12px 12px 96px; }
.feed { display: flex; flex-direction: column; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; line-height: 1.6; }

.post { border-bottom: 1px solid var(--line); padding: 12px 0 16px; }
.post-head { display: flex; align-items: center; gap: 10px; padding: 2px 2px 10px; }
.post-head .who { display: flex; flex-direction: column; }
.post-head .who b { font-size: 0.92rem; }
.post-head .who span { color: var(--muted); font-size: 0.8rem; }
.post-img { width: 100%; border-radius: 8px; display: block; background: #eee; }
.post-text { padding: 8px 2px 0; font-size: 0.94rem; line-height: 1.45; white-space: pre-wrap; }
.post-actions { display: flex; gap: 14px; padding: 8px 2px 2px; align-items: center; }
.action-btn { background: none; border: none; cursor: pointer; color: var(--text); padding: 2px; }
.action-btn .icon { width: 24px; height: 24px; }
.action-btn.liked { color: var(--heart); }
.action-btn.liked svg path { fill: var(--heart); stroke: var(--heart); }
.post-counts { padding: 2px; font-size: 0.86rem; }
.comments { padding: 4px 2px 0; font-size: 0.88rem; display: flex; flex-direction: column; gap: 3px; }
.comments .c b { margin-right: 6px; }
.comment-form { display: flex; gap: 8px; margin-top: 8px; }
.comment-form input { flex: 1; }
.comment-form button { background: none; border: none; color: var(--blue); font-weight: 700; cursor: pointer; }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #d9d9d9; display: block; }
.avatar.big { width: 76px; height: 76px; }
.avatar-ring { padding: 3px; border-radius: 50%; background: var(--gradient); display: inline-block; }
.avatar-ring .avatar { border: 2px solid #fff; }
.avatar-fallback {
  width: 36px; height: 36px; border-radius: 50%; background: var(--gradient); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.avatar-fallback.big { width: 76px; height: 76px; font-size: 1.8rem; }

.search-box { display: flex; gap: 8px; }
.search-box input { flex: 1; }

.people-list { display: flex; flex-direction: column; margin-top: 8px; }
.person { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid #efefef; }
.person .who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.person .who b { font-size: 0.92rem; }
.person .who span { color: var(--muted); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge {
  background: var(--yellow-badge); color: #3a2c00; font-size: 0.7rem; font-weight: 800;
  border-radius: 999px; padding: 2px 8px; display: inline-block; margin-top: 3px; width: fit-content;
}
.btn-follow { background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 7px 14px; font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.btn-follow.following { background: #efefef; color: var(--text); }
.btn-msg { background: #efefef; color: var(--text); border: none; border-radius: 8px; padding: 7px 12px; font-weight: 700; font-size: 0.85rem; cursor: pointer; }

.post-preview { width: 100%; border-radius: 8px; margin-bottom: 10px; }

.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chat-head .card-title { margin: 0; }
.thread-head {
  display: flex; align-items: center; gap: 10px; padding: 6px 0 12px;
  border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.thread-messages { display: flex; flex-direction: column; gap: 8px; min-height: 40dvh; padding-bottom: 8px; }
.bubble {
  max-width: 78%; padding: 9px 13px; border-radius: 20px; font-size: 0.93rem; line-height: 1.4;
  background: #efefef; align-self: flex-start; white-space: pre-wrap; word-break: break-word;
}
.bubble.mine { background: var(--gradient); color: #fff; align-self: flex-end; }
.bubble .when { display: block; font-size: 0.66rem; opacity: 0.75; margin-top: 3px; }
.thread-form { display: flex; gap: 8px; position: sticky; bottom: 76px; background: var(--bg); padding-top: 8px; }
.thread-form input { flex: 1; border-radius: 999px; }

.profile-head { display: flex; gap: 18px; align-items: center; padding: 8px 2px 12px; }
.profile-stats { flex: 1; display: flex; justify-content: space-around; text-align: center; }
.profile-stats b { display: block; font-size: 1.05rem; }
.profile-stats span { color: var(--muted); font-size: 0.78rem; }
.profile-name { padding: 0 2px; }
.profile-bio { padding: 4px 2px 14px; font-size: 0.93rem; white-space: pre-wrap; }
.my-school { padding: 8px 0; border-bottom: 1px solid #efefef; font-size: 0.9rem; }
.my-school:last-child { border-bottom: none; }
.my-school span { color: var(--muted); font-size: 0.8rem; display: block; }

.bottombar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--bg); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); z-index: 30;
}
.nav-btn { background: none; border: none; cursor: pointer; color: var(--text); padding: 4px 10px; opacity: 0.55; }
.nav-btn.active { opacity: 1; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 92px; z-index: 50;
  background: #262626; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 0.88rem; box-shadow: 0 4px 18px rgba(0,0,0,0.25); max-width: 92vw; text-align: center;
}

/* ===== Stories ===== */
.stories-bar {
  display: flex; gap: 14px; overflow-x: auto; padding: 12px 6px 4px;
  scrollbar-width: none;
}
.stories-bar::-webkit-scrollbar { display: none; }
.story-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; cursor: pointer; flex: 0 0 auto; width: 68px;
}
.story-item .sname {
  font-size: 0.72rem; color: var(--text); max-width: 68px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.story-ring {
  width: 62px; height: 62px; border-radius: 50%; padding: 3px;
  background: var(--gradient); position: relative;
}
.story-ring.seen { background: var(--line); }
.story-ring img, .story-ring .avatar-fallback {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  border: 2px solid #fff; display: flex; align-items: center; justify-content: center;
}
.story-plus {
  position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--blue); color: #fff; border: 2px solid #fff;
  font-size: 15px; line-height: 1; display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
}

.story-viewer {
  position: fixed; inset: 0; background: #000; z-index: 200;
  display: flex; flex-direction: column;
}
.story-progress { display: flex; gap: 4px; padding: 12px 12px 0; }
.story-progress i {
  flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35);
  display: block; overflow: hidden; position: relative;
}
.story-progress i.done { background: #fff; }
.story-progress i.active::after {
  content: ""; position: absolute; inset: 0; background: #fff;
  transform-origin: left; animation: storyfill 5s linear forwards;
}
@keyframes storyfill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.story-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff;
}
.story-author { font-weight: 700; font-size: 0.95rem; }
.story-time { color: rgba(255,255,255,.7); font-size: 0.8rem; }
.story-close {
  margin-left: auto; background: none; border: none; color: #fff;
  font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
}
.story-img { flex: 1; width: 100%; object-fit: contain; min-height: 0; }
.story-tap { position: absolute; top: 90px; bottom: 0; width: 35%; }
.story-tap.left { left: 0; }
.story-tap.right { right: 0; }
.story-delete {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  z-index: 2;
}

/* ===== Editar perfil / escolas ===== */
.my-school { display: flex; align-items: center; gap: 10px; }
.my-school .grow { flex: 1; }
.btn-mini {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.btn-mini.danger { color: var(--heart); border-color: #f3c2c7; }

/* ===== Escolha feed x story (Nova publicação) ===== */
.post-mode { display: flex; gap: 8px; margin-bottom: 8px; }
.mode-btn {
  flex: 1; padding: 10px 6px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-soft); color: var(--text); font-weight: 700; font-size: 0.9rem;
  cursor: pointer;
}
.mode-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
