:root {
  --bg: #0f1420;
  --bg-elev: #182034;
  --bg-elev-2: #1f2941;
  --border: #2b3752;
  --text: #e8ecf5;
  --text-dim: #93a0bd;
  --accent: #4f8cff;
  --accent-ink: #fff;
  --green: #34c759;
  --red: #ff5f57;
  --radius: 16px;
  --composer-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, textarea { font: inherit; color: inherit; }

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login-body { display: grid; place-items: center; padding: 24px; }
.login-card { text-align: center; max-width: 320px; width: 100%; }
.login-logo { font-size: 56px; }
.login-card h1 { margin: 8px 0 4px; font-size: 30px; letter-spacing: -.02em; }
.login-sub { margin: 0 0 28px; color: var(--text-dim); }
.login-error {
  background: rgba(255, 95, 87, .12);
  border: 1px solid rgba(255, 95, 87, .4);
  color: #ffb4b0;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 18px; font-size: 14px;
}
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #1f1f1f; text-decoration: none; font-weight: 600;
  padding: 13px 18px; border-radius: 999px;
}
.btn-google:active { transform: scale(.98); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.view { display: flex; flex-direction: column; height: 100dvh; }
.view[hidden] { display: none; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; margin: 0; flex: 1; letter-spacing: -.01em; }

.icon-btn {
  background: transparent; border: 0; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px; color: var(--text-dim);
}
.icon-btn:active { background: var(--bg-elev-2); }

.filter-btn {
  background: var(--bg-elev-2); border: 1px solid var(--border); cursor: pointer;
  color: var(--text-dim); border-radius: 999px; padding: 6px 14px; font-size: 13px;
}

/* ─── Grid de apps ───────────────────────────────────────────────────────── */
.apps-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px;
  padding: 18px; overflow-y: auto;
}
.app-card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 12px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform .12s ease, border-color .12s ease;
}
.app-card:active { transform: scale(.97); border-color: var(--accent); }
.app-card .emoji { font-size: 40px; line-height: 1; }
.app-card .name { font-size: 14px; font-weight: 600; }

/* ─── Lista de issues ────────────────────────────────────────────────────── */
.issues-list {
  flex: 1; overflow-y: auto;
  padding: 14px 14px calc(var(--composer-h) + 14px);
  display: flex; flex-direction: column; gap: 10px;
}
.issue {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px;
}
.issue.closed { opacity: .55; }
.issue-top { display: flex; align-items: flex-start; gap: 10px; }
.issue-title { flex: 1; font-weight: 600; font-size: 15px; word-break: break-word; }
.issue.closed .issue-title { text-decoration: line-through; }
.issue-body {
  margin: 6px 0 0; color: var(--text-dim); font-size: 14px;
  white-space: pre-wrap; word-break: break-word;
}
.issue-meta {
  margin-top: 8px; display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-dim);
}
.issue-meta a { color: var(--text-dim); }
.check {
  width: 24px; height: 24px; flex: none; cursor: pointer;
  border-radius: 50%; border: 2px solid var(--border); background: transparent;
  display: grid; place-items: center; font-size: 13px; color: transparent; padding: 0;
}
.issue.closed .check { border-color: var(--green); color: var(--green); }

.empty, .loading, .error-box {
  text-align: center; color: var(--text-dim); padding: 40px 20px; font-size: 15px;
}
.error-box { color: #ffb4b0; }

/* ─── Composer estilo WhatsApp ───────────────────────────────────────────── */
.composer {
  position: sticky; bottom: 0;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1; resize: none; max-height: 140px;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 10px 14px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.icon-btn.send { background: var(--accent); color: var(--accent-ink); flex: none; }
.icon-btn.send:disabled { opacity: .4; }
.icon-btn.mic { flex: none; }
.icon-btn.mic[data-pending="true"] { opacity: .5; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6);
  display: grid; place-items: center; padding: 20px; z-index: 20;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; width: 100%; max-width: 400px;
}
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.confirm-repo { margin: 0 0 14px; font-size: 13px; color: var(--text-dim); }
.confirm-title { margin: 0; font-weight: 600; word-break: break-word; }
.confirm-body {
  margin: 6px 0 0; font: inherit; font-size: 14px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow-y: auto;
}
.confirm-body:empty { display: none; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.btn { border: 0; border-radius: 999px; padding: 10px 20px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { opacity: .5; }
.btn-ghost { background: transparent; color: var(--text-dim); }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  background: var(--bg-elev-2); border: 1px solid var(--border);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 30;
}
.toast[hidden] { display: none; }
.toast.error { border-color: var(--red); color: #ffb4b0; }
