/* ==========================================================================
   Cognitudo AI Planner — frontend styles (mobile-first)
   Primary #6541CC · Accent #A855F7 · Text #1a1a2e
   ========================================================================== */

:root {
  --primary:        #6541CC;
  --primary-dark:   #4f35a8;
  --primary-soft:   rgba(101, 65, 204, 0.08);
  --primary-softer: rgba(101, 65, 204, 0.04);
  --accent:         #A855F7;
  --text:           #1a1a2e;
  --text-secondary: #64748b;
  --text-muted:     #94a3b8;
  --bg:             #FAFAFA;
  --surface:        #FFFFFF;
  --surface-2:      #F4F4F8;
  --border:         #E2E8F0;
  --border-strong:  #CBD5E1;
  --success:        #10B981;
  --warning:        #F59E0B;
  --error:          #EF4444;
  --gradient:       linear-gradient(135deg, #6541CC 0%, #A855F7 100%);
  --gradient-soft:  linear-gradient(135deg, rgba(101,65,204,.08) 0%, rgba(168,85,247,.08) 100%);
  --shadow-sm:      0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md:      0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg:      0 12px 32px rgba(15, 23, 42, 0.12);
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      18px;
  --radius-xl:      24px;
  --safe-top:       env(safe-area-inset-top, 0px);
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { letter-spacing: -0.02em; line-height: 1.15; margin: 0 0 .6rem; }
h1 { font-size: clamp(1.8rem, 7vw, 3.4rem); font-weight: 800; }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 700; }
h3 { font-size: clamp(1.05rem, 2vw, 1.25rem); font-weight: 700; }
h4 { font-size: 1rem; font-weight: 600; }
p  { margin: 0 0 .9rem; }
code { font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace; font-size: 0.88em; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }
input, textarea, button, select { font-family: inherit; }
textarea, input { -webkit-appearance: none; appearance: none; }

.muted { color: var(--text-secondary); }
.tiny { font-size: .8rem; }
.sr-only { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.hidden { display: none !important; }
.grad {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem; cursor: pointer;
  font-family: inherit; font-size: .95rem; font-weight: 600;
  padding: .7rem 1.2rem; border-radius: var(--radius-md);
  border: 1px solid transparent; background: none; color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
  text-decoration: none; min-height: 44px; line-height: 1.2;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.98); }
.btn-primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 2px 8px rgba(101,65,204,.28);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(101,65,204,.4); color: #fff; text-decoration: none; }
.btn-outline { border-color: var(--border-strong); color: var(--text); background: var(--surface); }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn-ghost {
  border-color: transparent; background: transparent; color: var(--text-secondary);
  padding: .5rem .8rem; font-weight: 500; min-height: 40px;
}
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.btn-lg { padding: 1rem 1.8rem; font-size: 1rem; min-height: 52px; }
.btn.tiny { padding: .35rem .7rem; font-size: .8rem; border-radius: var(--radius-sm); min-height: 32px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: calc(.8rem + var(--safe-top));
  gap: .75rem;
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: saturate(180%) blur(8px);
  background: rgba(255,255,255,.85);
}
.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--text); font-weight: 700;
  min-width: 0; flex-shrink: 1;
}
.brand:hover { text-decoration: none; }
.brand img { height: 26px; width: auto; flex-shrink: 0; }
.brand span {
  letter-spacing: -0.01em; color: var(--text); font-size: .98rem;
  white-space: nowrap;
}
.topnav {
  display: inline-flex; align-items: center; gap: .25rem;
  flex-shrink: 0;
}
.topnav a, .topnav > span {
  color: var(--text-secondary); font-weight: 500; font-size: .88rem;
  padding: .45rem .7rem; border-radius: var(--radius-sm);
  white-space: nowrap;
}
.topnav a:hover { color: var(--primary); background: var(--primary-soft); text-decoration: none; }

@media (min-width: 640px) {
  .topbar { padding: 1rem 1.5rem; padding-top: calc(1rem + var(--safe-top)); }
  .brand img { height: 28px; }
  .brand span { font-size: 1.05rem; }
  .topnav { gap: .35rem; }
  .topnav a, .topnav > span { font-size: .9rem; padding: .45rem .85rem; }
}
@media (min-width: 900px) {
  .topbar { padding: 1rem 2rem; padding-top: calc(1rem + var(--safe-top)); }
}

/* Hide brand subtitle on very small screens to avoid wrap */
@media (max-width: 420px) {
  .brand span { display: none; }
}

/* Long nav label suffix — only visible on wider screens */
.nav-long { display: none; }
@media (min-width: 560px) {
  .nav-long { display: inline; }
}

/* ---------- Landing page ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 1200px; margin: 0 auto;
  padding: 1.8rem 1rem 3rem;
}
.hero-inner { min-width: 0; }
@media (min-width: 640px) { .hero { padding: 2.5rem 1.5rem 3rem; } }
@media (min-width: 900px) {
  .hero { grid-template-columns: 1.25fr 1fr; gap: 3rem; padding: 3.5rem 2rem 4rem; }
}
.kicker {
  display: inline-block;
  font-size: .72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--primary);
  background: var(--primary-soft);
  padding: .4rem .8rem; border-radius: 99px;
  margin-bottom: 1.1rem;
}
.hero h1 { margin-bottom: 1rem; }
.lede {
  font-size: clamp(1rem, 2.3vw, 1.15rem);
  color: var(--text);
  max-width: 56ch;
  margin-bottom: 1.8rem;
  font-weight: 500;
}

.start-form {
  display: flex; flex-direction: column; gap: .7rem;
  background: var(--surface); padding: 1.1rem;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
@media (min-width: 640px) { .start-form { padding: 1.5rem; } }

.start-form textarea {
  font-family: inherit; font-size: 1rem; line-height: 1.5;
  padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  resize: vertical; min-height: 110px;
  background: var(--surface-2); color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
  width: 100%;
}
.start-form textarea:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.opt-row { display: grid; grid-template-columns: 1fr; gap: .6rem; }
@media (min-width: 560px) { .opt-row { grid-template-columns: 1fr 1fr; gap: .7rem; } }
.opt-row input {
  font-family: inherit; font-size: .95rem;
  padding: .8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
  width: 100%; min-height: 48px;
}
.opt-row input:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.form-hint { margin: 0; font-size: .82rem; }

.trust-row {
  display: flex; flex-wrap: wrap; gap: .6rem 1.2rem;
  margin-top: 1.5rem; font-size: .88rem;
}

.resume-box {
  margin-top: 2rem; padding: 1.1rem 1.3rem; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px dashed var(--border);
}
.resume-q { margin: 0 0 .6rem 0; font-weight: 600; color: var(--text); font-size: .95rem; }
.resume-form { display: flex; gap: .55rem; flex-wrap: wrap; align-items: stretch; }
.resume-form input[type=email] {
  flex: 1 1 220px; min-width: 0;
  padding: .6rem .85rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); font: inherit; color: var(--text);
}
.resume-form input[type=email]:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.resume-form .btn { flex: 0 0 auto; padding: .55rem 1rem; }
.resume-hint { margin: .55rem 0 0 0; font-size: .82rem; }

.hero-side { align-self: start; }
@media (min-width: 900px) { .hero-side { align-self: center; } }
.hero-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.4rem; box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.hero-card::before {
  content: ""; position: absolute; inset: 0;
  background: var(--gradient-soft); opacity: .5; z-index: 0;
  pointer-events: none;
}
.hero-card > * { position: relative; z-index: 1; }
@media (min-width: 640px) { .hero-card { padding: 1.8rem; } }
.hero-card h3 { margin-bottom: 1rem; }
.hero-card ul { list-style: none; padding: 0; margin: 0; }
.hero-card li {
  padding: .6rem 0; border-bottom: 1px solid var(--border);
  color: var(--text-secondary); font-size: .92rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
}
.hero-card li:last-child { border-bottom: none; }
.hero-card code {
  color: var(--primary); font-weight: 600; background: var(--surface-2);
}

.foot {
  padding: 1.5rem 1rem;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
  text-align: center; color: var(--text);
  font-size: .85rem; font-weight: 500;
  border-top: 1px solid var(--border); margin-top: 2rem;
}

/* ---------- Auth page ---------- */
.page-auth {
  display: grid; place-items: center;
  min-height: 100vh; min-height: 100dvh;
  background: var(--surface-2);
  padding: 1rem;
  padding-top: calc(1rem + var(--safe-top));
  padding-bottom: calc(1rem + var(--safe-bottom));
}
.auth-card {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 1.8rem; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
  border: 1px solid var(--border);
}
@media (min-width: 480px) { .auth-card { padding: 2.5rem; } }
.auth-card .brand-logo { height: 32px; margin-bottom: 1rem; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: .4rem; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }
.auth-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; font-weight: 500; color: var(--text-secondary); }
.auth-card input {
  font-family: inherit; font-size: 1rem;
  padding: .8rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text);
  min-height: 48px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.auth-card input:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.alert { padding: .7rem 1rem; border-radius: var(--radius-md); font-size: .9rem; }
.alert.error { background: rgba(239, 68, 68, 0.08); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }

/* ---------- App / chat layout ---------- */
.page-app {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
.app-meta {
  display: none; /* hidden on mobile */
  gap: .8rem; align-items: center;
  font-size: .82rem; color: var(--text-secondary);
}
@media (min-width: 900px) { .app-meta { display: inline-flex; } }
.proj-id { font-family: 'JetBrains Mono', monospace; }

.app-layout {
  flex: 1;
  display: grid; grid-template-columns: 1fr;
  width: 100%;
  max-width: 1400px; margin: 0 auto;
}
@media (min-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr 360px;
    height: calc(100vh - 66px);
    height: calc(100dvh - 66px);
  }
}

.chat-col {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--surface);
}
@media (min-width: 900px) {
  .chat-col { border-right: 1px solid var(--border); height: 100%; }
}

.chat-stream {
  flex: 1; overflow-y: auto;
  padding: 1rem; display: flex; flex-direction: column; gap: .85rem;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) { .chat-stream { padding: 1.5rem 2rem; gap: 1rem; } }

.chat-turn {
  max-width: 90%; padding: .85rem 1.1rem; border-radius: var(--radius-lg);
  font-size: .94rem; line-height: 1.55; word-wrap: break-word;
  animation: fadeInUp .3s ease-out;
}
@media (min-width: 640px) { .chat-turn { max-width: 80%; padding: 1rem 1.3rem; font-size: .96rem; } }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-turn.role-assistant,
.chat-turn.role-coach { background: var(--surface-2); align-self: flex-start; border-bottom-left-radius: 4px; white-space: pre-wrap; }
.chat-turn.role-user { background: var(--gradient); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; box-shadow: 0 2px 8px rgba(101,65,204,.2); white-space: pre-wrap; }
.chat-turn.role-system {
  background: rgba(245, 158, 11, 0.08);
  color: #92400E; font-size: .86rem;
  border: 1px dashed rgba(245, 158, 11, 0.35);
  align-self: stretch; max-width: none; text-align: center;
}
.chat-turn.typing > div:last-child::after {
  content: ''; display: inline-block;
  width: 8px; height: 8px; margin-left: 4px;
  border-radius: 50%; background: var(--text-secondary);
  animation: typingPulse 1.1s infinite ease-in-out;
}
@keyframes typingPulse { 0%,100% { opacity: .3; transform: scale(1); } 50% { opacity: 1; transform: scale(1.3); } }
.pill { display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: .15rem .5rem; border-radius: 99px; margin-right: .4rem; vertical-align: middle; }
.pill-critical { background: rgba(220, 38, 38, .1); color: #B91C1C; border: 1px solid rgba(220, 38, 38, .25); }
.question-head .q-text { display: inline; }
.sub-questions li.blocked { opacity: .5; text-decoration: line-through; }
.sub-questions li.critical .dot { background: #B91C1C; }
.chat-turn .turn-tag {
  display: block; font-size: .68rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  opacity: .7; margin-bottom: .3rem;
}

.answer-form {
  border-top: 1px solid var(--border);
  padding: .8rem 1rem;
  padding-bottom: calc(.8rem + var(--safe-bottom));
  background: var(--surface);
  position: sticky; bottom: 0; z-index: 5;
}
@media (min-width: 640px) { .answer-form { padding: 1rem 2rem 1.2rem; padding-bottom: calc(1.2rem + var(--safe-bottom)); } }

.question-head {
  font-size: .86rem; font-weight: 600; color: var(--text-secondary);
  margin-bottom: .5rem; line-height: 1.4;
}
.question-head .section-pill {
  display: inline-block;
  background: var(--primary-soft); color: var(--primary);
  font-size: .68rem; padding: .2rem .55rem; border-radius: 99px; margin-right: .5rem;
  font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  vertical-align: middle;
}

.answer-row {
  display: flex; gap: .6rem; align-items: stretch;
  flex-direction: column;
}
@media (min-width: 640px) { .answer-row { flex-direction: row; gap: .7rem; } }

.answer-row textarea {
  flex: 1; font-family: inherit; font-size: 1rem; padding: .8rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius-md); resize: vertical;
  background: var(--surface-2); min-height: 72px; color: var(--text);
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.answer-row textarea:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.answer-actions {
  display: flex; gap: .4rem;
  flex-direction: row; flex-wrap: wrap;
}
@media (min-width: 640px) { .answer-actions { flex-direction: column; flex-wrap: nowrap; } }
.answer-actions .btn { white-space: nowrap; flex: 1; }
@media (min-width: 640px) { .answer-actions .btn { flex: 0 0 auto; } }

.shallow-banner {
  margin-top: .8rem; padding: .8rem 1rem;
  background: rgba(245, 158, 11, 0.06);
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md); font-size: .88rem; color: var(--text);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap;
}
.shallow-banner #shallow-msg { flex: 1; min-width: 200px; }

/* ---------- Right panel (progress) ---------- */
.panel-col {
  background: var(--surface-2); padding: 1rem;
  order: 2;
}
@media (min-width: 900px) {
  .panel-col { order: 0; overflow-y: auto; padding: 1.5rem; }
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; gap: .6rem; flex-wrap: wrap;
}
.progress-meta {
  display: flex; gap: .8rem; align-items: center;
  font-size: .85rem; color: var(--text-secondary);
}

.sections-panel { display: flex; flex-direction: column; gap: .5rem; }
.section-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: .85rem 1rem; cursor: default;
  transition: border-color .15s, box-shadow .15s;
}
.section-item.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.section-item.done { background: rgba(16, 185, 129, 0.04); border-color: rgba(16, 185, 129, 0.3); }
.section-item header {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  font-size: .9rem; font-weight: 600;
}
.section-item .progress-num { font-size: .78rem; color: var(--text-secondary); font-weight: 500; flex-shrink: 0; }
.section-item .sub-questions { margin: .5rem 0 0; padding: 0; list-style: none; }
.section-item .sub-questions li { padding: .3rem 0; font-size: .8rem; color: var(--text-secondary); }
.section-item .sub-questions li .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: .5rem; background: var(--border-strong); vertical-align: middle;
}
.section-item .sub-questions li.answered .dot { background: var(--success); }
.section-item .sub-questions li.current .dot { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.panel-card {
  margin-top: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 1rem;
}
.panel-card h4 { margin-bottom: .7rem; }
.panel-card ul { list-style: none; padding: 0; margin: 0 0 1rem; }
.panel-card li {
  display: flex; justify-content: space-between; align-items: center;
  padding: .4rem 0; border-bottom: 1px solid var(--border);
  font-size: .88rem; gap: .5rem;
}
.panel-card li:last-child { border-bottom: none; }
.panel-card li a { font-size: .82rem; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: grid; place-items: center; z-index: 100;
  padding: 1rem;
  backdrop-filter: blur(2px);
  animation: fadeIn .2s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }
.modal-card {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 1.4rem; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px; max-height: 85vh; max-height: 85dvh;
  display: flex; flex-direction: column; gap: 1rem;
  animation: modalIn .25s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 640px) { .modal-card { padding: 2rem; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.gen-status { display: flex; flex-direction: column; gap: .7rem; }
.gen-current-row {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  font-size: .9rem;
}
.gen-current-label { color: var(--text-secondary); font-weight: 500; flex-shrink: 0; }
.gen-current {
  font-family: 'JetBrains Mono', monospace; font-size: .88rem;
  color: var(--text); background: var(--surface-2);
  padding: .2rem .5rem; border-radius: var(--radius-sm);
  word-break: break-all; min-width: 0; flex: 1;
}
.gen-bar-big {
  height: 14px; background: var(--surface-2);
  border-radius: 99px; overflow: hidden; position: relative;
  border: 1px solid var(--border);
}
.gen-bar-big-fill {
  height: 100%; width: 0;
  background: var(--gradient);
  transition: width .35s cubic-bezier(.25,.1,.25,1);
  border-radius: 99px;
}
.gen-bar-big.working .gen-bar-big-fill {
  animation: barPulse 1.2s ease-in-out infinite;
}
@keyframes barPulse {
  0%,100% { opacity: 1; }
  50% { opacity: .75; }
}
.gen-step-info {
  font-size: .85rem; color: var(--text-secondary);
  font-weight: 500; text-align: right;
}
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }

/* ---------- Plan overlay (SSE loading) ---------- */
.plan-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.75);
  display: grid; place-items: center; z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease-out;
}
.plan-card {
  background: var(--surface); border-radius: var(--radius-xl);
  padding: 2rem 1.5rem; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; align-items: center; gap: .9rem;
  text-align: center;
  animation: modalIn .25s cubic-bezier(0.16, 1, 0.3, 1);
}
.plan-spinner {
  width: 52px; height: 52px; border-radius: 50%;
  border: 4px solid var(--surface-2);
  border-top-color: var(--primary);
  animation: planSpin .9s linear infinite;
}
@keyframes planSpin { to { transform: rotate(360deg); } }
.plan-card h3 { margin: 0; font-size: 1.15rem; }
.plan-card p { margin: 0; font-size: .92rem; }
.plan-progress {
  font-family: 'JetBrains Mono', monospace; font-size: .82rem;
  color: var(--text-secondary);
  padding: .5rem .9rem; background: var(--surface-2); border-radius: 99px;
  min-height: 1.6em;
}
.plan-error {
  color: var(--error); font-size: .9rem;
  display: none; margin: 0;
}
.plan-retry { display: none; }

/* ---------- Admin ---------- */
.admin-layout {
  max-width: 1200px; margin: 1.5rem auto;
  padding: 0 1rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}
@media (min-width: 640px) { .admin-layout { padding: 0 1.5rem; margin: 2rem auto; gap: 2rem; } }
@media (min-width: 900px) { .admin-layout { padding: 0 2rem; } }

.admin-list, .admin-detail {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.2rem; box-shadow: var(--shadow-sm);
}
@media (min-width: 640px) { .admin-list, .admin-detail { padding: 1.8rem; } }

.section-head { margin-bottom: 1rem; }
.section-head h2 { margin-bottom: .3rem; }

.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .5rem 1.5rem; margin-bottom: 1rem; font-size: .9rem;
}

.projects-table { width: 100%; border-collapse: collapse; }
.projects-table th, .projects-table td {
  padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem;
}
.projects-table th {
  font-weight: 600; color: var(--text-secondary); font-size: .75rem;
  text-transform: uppercase; letter-spacing: .05em;
}
.projects-table tbody tr:hover { background: var(--primary-softer); }
.projects-table td .status {
  display: inline-block; padding: .2rem .6rem; border-radius: 99px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.status.in_progress { background: rgba(245, 158, 11, 0.1); color: #B45309; }
.status.ready_to_generate { background: rgba(101, 65, 204, 0.1); color: var(--primary); }
.status.generated { background: rgba(16, 185, 129, 0.1); color: #047857; }
.status.abandoned { background: rgba(100, 116, 139, 0.1); color: var(--text-secondary); }

.artifact-list { list-style: none; padding: 0; margin: 1rem 0; }
.artifact-list li {
  display: grid;
  grid-template-columns: 1fr;
  gap: .3rem;
  padding: .8rem 1rem; background: var(--surface-2); border-radius: var(--radius-md); margin-bottom: .5rem;
}
@media (min-width: 640px) {
  .artifact-list li { grid-template-columns: 1fr auto auto; gap: 1rem; align-items: center; }
}
.file-name { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: .9rem; word-break: break-all; }

.answers-dump {
  margin-top: 1rem; padding: 1rem;
  background: var(--surface-2); border-radius: var(--radius-md);
  max-height: 500px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.ans-item { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
.ans-item:last-child { border-bottom: none; }
.ans-item b { display: block; margin-bottom: .3rem; font-size: .92rem; }

/* ---------- Mobile admin table: horizontal scroll wrapper ---------- */
#projects-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 600px) {
  .projects-table { font-size: .82rem; min-width: 560px; }
  .projects-table th, .projects-table td { padding: .5rem .7rem; }
}

/* ---------- Extra polish: focus visible, selection ---------- */
::selection { background: rgba(168, 85, 247, .25); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, a:focus-visible { outline-offset: 3px; }

/* ---------- Account login + dashboard ---------- */
.alert.info { background: var(--primary-soft); color: var(--primary); border: 1px solid rgba(99,85,255,0.2); }
.auth-form.hidden { display: none !important; }
.btn-sm { padding: .5rem .9rem; font-size: .9rem; min-height: 36px; }

.page-account { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.account-main { max-width: 1200px; width: 100%; margin: 0 auto; padding: 2rem 1.2rem 4rem; flex: 1; }
.account-head { margin-bottom: 1.8rem; }
.account-head h1 { font-size: 1.9rem; margin: 0 0 .4rem 0; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.2rem; }
.project-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 1.2rem;
  display: flex; flex-direction: column; gap: .8rem;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.project-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.project-card-head { display: flex; align-items: center; justify-content: space-between; }
.project-idea { font-size: 1rem; line-height: 1.4; margin: 0; color: var(--text); }
.project-tags { display: flex; gap: .4rem; flex-wrap: wrap; }
.project-tags .tag { font-size: .75rem; padding: .2rem .6rem; border-radius: 99px; background: var(--surface-2); color: var(--text-secondary); }
.project-progress { margin-top: .2rem; }
.project-artifacts { margin-top: .4rem; padding-top: .8rem; border-top: 1px solid var(--border); }
.project-artifacts h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); margin: 0 0 .5rem 0; font-weight: 600; }
.project-artifacts ul { list-style: none; padding: 0; margin: 0 0 .6rem 0; display: flex; flex-direction: column; gap: .3rem; }
.project-artifacts li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .88rem; }
.project-artifacts li code { flex: 1; min-width: 140px; }
.project-artifacts li a { color: var(--primary); text-decoration: none; font-weight: 500; }
.project-artifacts li a:hover { text-decoration: underline; }
.project-card-actions { margin-top: auto; display: flex; justify-content: flex-end; gap: .5rem; }

.pill.status-planning  { background: rgba(99,85,255,0.10); color: var(--primary); }
.pill.status-progress  { background: rgba(59,130,246,0.10); color: #2563eb; }
.pill.status-ready     { background: rgba(16,185,129,0.10); color: #059669; }
.pill.status-done      { background: rgba(16,185,129,0.15); color: #047857; }
.pill.status-blocked   { background: rgba(239,68,68,0.10); color: var(--error); }
.pill.status-abandon   { background: rgba(148,163,184,0.15); color: #64748b; }

.empty-state { text-align: center; padding: 4rem 1rem; }
.empty-state h2 { margin: 0 0 .5rem 0; }
.empty-state p { margin: 0 0 1.5rem 0; }

/* ---------- UX A2: Delete button (danger ghost) ---------- */
.btn-danger-ghost {
  border-color: transparent; background: transparent;
  color: #B91C1C; font-weight: 500; min-height: 36px;
  padding: .5rem .8rem;
}
.btn-danger-ghost:hover:not(:disabled) {
  background: rgba(220, 38, 38, .08);
  color: #991B1B;
  text-decoration: none;
}

/* ---------- UX A3: Right panel sticky scroll (desktop) ---------- */
@media (min-width: 900px) {
  .panel-col {
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    max-height: calc(100vh - 72px);
    overflow-y: auto;
    align-self: start;
  }
  .panel-col .panel-head {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface-2);
    margin: -1.5rem -1.5rem 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
  }
}

/* ---------- UX A4: Example bubble — distinct style ---------- */
.chat-turn.role-example {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-left: 4px solid #f59e0b;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: #78350f;
  white-space: pre-wrap;
  font-style: italic;
}
.chat-turn.role-example .turn-tag {
  color: #92400e;
  opacity: 1;
  font-style: normal;
  font-weight: 700;
}
.chat-turn.role-example::before {
  content: "💡 PÉLDAVÁLASZ";
  display: block;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: #b45309;
  margin-bottom: .4rem;
  border-bottom: 1px dashed rgba(180, 83, 9, .3);
  padding-bottom: .3rem;
}

/* ---------- UX A6: Download actions in generate modal ---------- */
.gen-downloads {
  display: none;
  flex-direction: column; gap: .5rem;
  padding: 1rem;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-md);
}
.gen-downloads.visible { display: flex; }
.gen-downloads h4 {
  margin: 0; font-size: .88rem; text-transform: uppercase;
  letter-spacing: .05em; color: #047857;
}
.gen-downloads ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.gen-downloads li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .88rem; }
.gen-downloads li code { font-family: 'JetBrains Mono', monospace; flex: 1; }
.gen-downloads .btn-zip { align-self: flex-start; margin-top: .3rem; }

.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }

/* ---------- Landing: projekt-típus választó ---------- */
.kind-picker {
  border: none; padding: 0; margin: 0 0 .4rem 0;
  display: grid; grid-template-columns: 1fr; gap: .5rem;
}
@media (min-width: 640px) { .kind-picker { grid-template-columns: 1fr 1fr; } }
.kind-picker legend {
  font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--primary); margin-bottom: .2rem; padding: 0;
}
.kind-opt {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .8rem 1rem .8rem 2.4rem; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  position: relative;
}
.kind-opt:hover { border-color: var(--primary); background: var(--primary-softer); }
.kind-opt input[type=radio] {
  position: absolute; left: .9rem; top: .95rem;
  width: 18px; height: 18px; accent-color: var(--primary); margin: 0;
}
.kind-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px var(--primary-softer); }
.kind-opt:has(input:checked) .kind-title { color: var(--primary); }
.kind-title { font-weight: 600; font-size: .95rem; color: var(--text); }
.kind-desc { font-size: .82rem; color: var(--text-secondary); line-height: 1.35; }
