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

:root {
  --bg: #0f1117;
  --warm: #161a24;
  --white: #1a1f2e;
  --ink: #e8eaf2;
  --ink2: #c2c6d8;
  --terra: #7c5cfc;
  --terra-light: #1e1a38;
  --terra-mid: #a08af8;
  --moss: #2ec4a0;
  --moss-light: #0d2a24;
  --sky: #4a9eff;
  --sky-light: #0d1e30;
  --amber: #f5a623;
  --amber-light: #271e0a;
  --border: #262c3e;
  --border2: #1e2334;
  --muted: #5a6180;
  --shadow: 0 2px 8px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4), 0 2px 6px rgba(0,0,0,0.25);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', sans-serif;
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 58px;
  display: flex;
  align-items: center;
  padding: 0 32px;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-logo { display: flex; align-items: center; gap: 10px; }

.nav-logo-icon {
  width: 32px; height: 32px;
  background: var(--terra);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.nav-logo-name {
  font-family: 'Lora', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.nav-logo-sub { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.nav-right    { font-size: 12px; color: var(--muted); }

/* ── LAYOUT ── */
.app {
  display: grid;
  grid-template-columns: 400px 1fr;
  min-height: calc(100vh - 58px);
}

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE & TABLET
   ══════════════════════════════════════════ */

/* ── Mobile tab bar ── */
.mobile-tabs {
  display: none;
  position: sticky;
  top: 58px;
  z-index: 90;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.mobile-tab {
  flex: 1;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 11px 8px;
  text-align: center;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.mobile-tab.active { color: var(--terra-mid); border-bottom-color: var(--terra); }

/* ── Tablet (≤ 860px) ── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }

  nav { padding: 0 20px; }
  .nav-right { display: none; }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 22px 20px 36px;
  }

  .output {
    padding: 24px 20px 40px;
    min-height: 60vh;
  }

  .result-bar { flex-wrap: wrap; gap: 8px; }
}

/* ── Mobile (≤ 650px) ── */
@media (max-width: 650px) {
  body { overflow-x: hidden; }

  /* Nav: compact */
  nav {
    height: 50px;
    padding: 0 12px;
  }
  .nav-logo-name { font-size: 16px; }
  .nav-logo-icon { width: 28px; height: 28px; font-size: 14px; }

  /* Mobile tabs: visible */
  .mobile-tabs {
    display: flex;
    top: 50px;
  }

  /* App: stack, height-managed */
  .app {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 50px - 40px);
  }

  /* Sidebar: scrollable, hidden by default */
  .sidebar {
    padding: 16px 14px 32px;
    overflow-y: auto;
    max-height: calc(100dvh - 50px - 40px);
    border-bottom: none;
  }
  .sidebar.hidden { display: none; }

  .sidebar-title { font-size: 17px; }
  .sidebar-sub   { font-size: 11px; margin-bottom: 20px; }

  /* Output: scrollable, hidden by default */
  .output {
    padding: 14px 12px 36px;
    overflow-y: auto;
    max-height: calc(100dvh - 50px - 40px);
    min-height: unset;
  }
  .output.hidden { display: none; }

  /* Prevent iOS zoom */
  input[type="text"],
  input[type="date"],
  textarea,
  select {
    font-size: 1rem;
    padding: 10px 12px;
  }
  select { padding-right: 34px; }
  textarea { min-height: 76px; font-size: 1rem; }

  /* Row2: single col on very small */
  .row2 { grid-template-columns: 1fr 1fr; gap: 8px; }

  /* Checkboxes: 2 cols */
  .check-group { grid-template-columns: 1fr 1fr; gap: 6px; }
  .check-item  { padding: 7px 8px; font-size: 11px; }

  /* Tone buttons: wrap */
  .tone-group { gap: 5px; }
  .tone-btn   { font-size: 10px; padding: 5px 10px; }

  /* Generate button */
  .btn-gen { font-size: 14px; padding: 13px 18px; }

  /* Form sections */
  .form-section { margin-bottom: 20px; }

  /* Empty state */
  .empty { min-height: 300px; }
  .empty-visual { width: 60px; height: 60px; font-size: 26px; border-radius: 14px; }
  .empty h2 { font-size: 18px; }
  .empty p  { font-size: 12px; }

  /* Loading */
  .loading { min-height: 300px; }

  /* Result bar */
  .result-bar { margin-bottom: 16px; }
  .result-bar-title { font-size: 14px; }
  .result-actions { flex-wrap: wrap; gap: 5px; }
  .btn-sm { font-size: 11px; padding: 6px 10px; }

  /* Stats grid */
  .progress-summary { grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 16px; }
  .progress-card    { padding: 10px 8px; border-radius: 8px; }
  .progress-num     { font-size: 1.4rem; }
  .progress-label   { font-size: 8px; }

  /* Onboarding doc */
  .ob-header { padding: 22px 18px 18px; }
  .ob-header-name { font-size: 1.3rem; margin-bottom: 4px; }
  .ob-header-role { font-size: 0.9rem; margin-bottom: 16px; }
  .ob-meta-row { gap: 8px; }
  .ob-meta-chip { font-size: 10px; padding: 4px 9px; }

  .ob-intro { padding: 16px 18px; font-size: 13px; }
  .ob-body  { padding: 18px 14px 24px; }

  .phase-card   { margin-bottom: 12px; border-radius: 10px; }
  .phase-header { padding: 12px 14px; gap: 9px; }
  .phase-number { width: 28px; height: 28px; font-size: 12px; border-radius: 7px; }
  .phase-title  { font-size: 13px; }
  .phase-body   { padding: 12px 14px; }

  .task-item { padding: 9px 10px; font-size: 12px; }
  .task-dot  { width: 18px; height: 18px; font-size: 10px; }
  .task-name { font-size: 12px; }
  .task-desc { font-size: 11px; }
  .task-badge { font-size: 9px; padding: 2px 6px; }

  .ob-footer { padding: 14px 18px; font-size: 10px; }
}

/* ── Very small (≤ 380px) ── */
@media (max-width: 380px) {
  nav { padding: 0 8px; }
  .sidebar { padding: 14px 10px 28px; }
  .output  { padding: 12px 10px 28px; }
  .row2    { grid-template-columns: 1fr; }
  .progress-summary { grid-template-columns: repeat(2, 1fr); }
  .ob-header { padding: 16px 14px; }
  .ob-body   { padding: 14px 12px; }
}

/* Print */
@media print {
  nav, .sidebar, .result-bar, .mobile-tabs { display: none !important; }
  body { display: block; background: white; }
  .output { padding: 0; max-height: none; overflow: visible; }
  .phase-body { display: block !important; }
  .ob-doc { box-shadow: none; border: none; }
}

/* ── SIDEBAR ── */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 28px 28px 48px;
  overflow-y: auto;
}

.sidebar-title {
  font-family: 'Lora', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.sidebar-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* Sections */
.form-section { margin-bottom: 26px; }

.form-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  gap: 7px;
}

.form-section-icon { font-size: 13px; }

/* Fields */
.field { margin-bottom: 13px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink2);
  margin-bottom: 5px;
}

input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 13px;
  padding: 9px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  resize: none;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--terra);
  box-shadow: 0 0 0 3px rgba(124,92,252,0.15);
  background: var(--warm);
}

textarea { min-height: 88px; line-height: 1.6; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%239a9284' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Checkbox group */
.check-group { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.check-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s;
  background: var(--bg);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
  user-select: none;
}

.check-item:hover { border-color: var(--terra-mid); }
.check-item.checked { border-color: var(--terra); background: var(--terra-light); color: var(--terra); }
.check-item input { display: none; }
.check-icon { font-size: 14px; }

/* Tone selector */
.tone-group { display: flex; gap: 7px; flex-wrap: wrap; }

.tone-btn {
  padding: 6px 13px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--ink2);
  transition: all 0.12s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tone-btn:hover { border-color: var(--terra); }
.tone-btn.active { background: var(--terra); border-color: var(--terra); color: white; }

/* Button */
.btn-gen {
  width: 100%;
  padding: 14px 20px;
  background: var(--terra);
  color: white;
  border: none;
  border-radius: 11px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 6px;
  letter-spacing: 0.01em;
}

.btn-gen:hover { background: #6a4afc; transform: translateY(-1px); box-shadow: 0 4px 20px rgba(124,92,252,0.35); }
.btn-gen:active { transform: translateY(0); }
.btn-gen:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── OUTPUT ── */
.output { padding: 36px 40px; overflow-y: auto; }

/* Empty */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  text-align: center;
  gap: 16px;
  animation: fadeIn 0.4s ease;
}

.empty-visual {
  width: 80px; height: 80px;
  background: var(--terra-light);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: 0 0 40px rgba(124,92,252,0.15);
}

.empty h2 { font-family: 'Lora', serif; font-size: 22px; font-weight: 700; color: var(--ink); }
.empty p  { font-size: 13px; color: var(--muted); max-width: 320px; line-height: 1.7; }

/* Loading */
.loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  gap: 24px;
}

.loading.show { display: flex; }

.loader-track {
  width: 200px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--terra), var(--moss));
  border-radius: 2px;
  animation: loadBar 2.5s ease-in-out infinite;
}

@keyframes loadBar {
  0%   { width: 0%; transform: translateX(0); }
  50%  { width: 70%; }
  100% { width: 100%; transform: translateX(200px); }
}

.load-label { font-size: 13px; color: var(--muted); font-style: italic; font-family: 'Lora', serif; }

/* Result */
.result { display: none; animation: fadeUp 0.5s ease; }
.result.show { display: block; }

.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 10px;
}

.result-bar-title { font-family: 'Lora', serif; font-size: 16px; font-weight: 700; color: var(--ink); }
.result-actions { display: flex; gap: 8px; }

.btn-sm {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--white);
  color: var(--ink2);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-sm:hover { border-color: var(--terra); color: var(--terra); }
.btn-sm.primary { background: var(--terra); border-color: var(--terra); color: white; }
.btn-sm.primary:hover { background: #6a4afc; }

/* ── ONBOARDING DOCUMENT ── */
.ob-doc {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.ob-header {
  padding: 36px 36px 28px;
  background: linear-gradient(135deg, #0a0d16 0%, #141828 100%);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.ob-header::before {
  content: '';
  position: absolute;
  bottom: -60px; right: -60px;
  width: 200px; height: 200px;
  background: rgba(124,92,252,0.12);
  border-radius: 50%;
}

.ob-header::after {
  content: '';
  position: absolute;
  top: -30px; right: 120px;
  width: 100px; height: 100px;
  background: rgba(46,196,160,0.06);
  border-radius: 50%;
}

.ob-header-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--terra-mid);
  margin-bottom: 10px;
}

.ob-header-name {
  font-family: 'Lora', serif;
  font-size: clamp(1.5rem, 3.5vw, 2.4rem);
  font-weight: 700;
  color: white;
  margin-bottom: 6px;
  line-height: 1.15;
}

.ob-header-role {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 1rem;
  color: rgba(255,255,255,0.55);
  margin-bottom: 22px;
}

.ob-meta-row { display: flex; flex-wrap: wrap; gap: 16px; }

.ob-meta-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  color: rgba(255,255,255,0.65);
}

/* Intro */
.ob-intro {
  padding: 24px 36px;
  background: var(--warm);
  border-bottom: 1px solid var(--border2);
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink2);
  line-height: 1.8;
}

/* Body */
.ob-body { padding: 28px 36px 36px; }

/* Phase cards */
.phase-card {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.2s;
  animation: fadeUp 0.4s ease both;
}

.phase-card:hover { box-shadow: var(--shadow-md); }

.phase-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.phase-header:hover { background: #1a1f30; }

.phase-number {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.phase-info { flex: 1; }
.phase-title   { font-weight: 700; font-size: 14px; color: var(--ink); margin-bottom: 2px; }
.phase-subtitle { font-size: 11px; color: var(--muted); }

.phase-toggle { font-size: 18px; color: var(--muted); transition: transform 0.2s; }
.phase-toggle.open { transform: rotate(180deg); }

.phase-body { padding: 16px 20px; display: none; }
.phase-body.open { display: block; }

/* Tasks */
.task-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink2);
  border: 1px solid transparent;
  transition: all 0.15s;
}

.task-item:hover { background: var(--bg); border-color: var(--border2); }

.task-dot {
  width: 20px; height: 20px;
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  margin-top: 1px;
}

.task-content { flex: 1; }
.task-name { font-weight: 600; margin-bottom: 2px; }
.task-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }

.task-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

/* Type color classes */
.type-admin     { background: #0d1e30; color: #4a9eff; }
.type-technique { background: #271e0a; color: #f5a623; }
.type-culture   { background: #1e1a38; color: #a08af8; }
.type-social    { background: #0d2a24; color: #2ec4a0; }
.type-formation { background: #1a1028; color: #d07af0; }

.dot-admin     { background: #0d1e30; color: #4a9eff; }
.dot-technique { background: #271e0a; color: #f5a623; }
.dot-culture   { background: #1e1a38; color: #a08af8; }
.dot-social    { background: #0d2a24; color: #2ec4a0; }
.dot-formation { background: #1a1028; color: #d07af0; }

/* Footer */
.ob-footer {
  padding: 18px 36px;
  border-top: 1px solid var(--border2);
  background: var(--warm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}

.ob-footer-brand {
  font-family: 'Lora', serif;
  font-weight: 700;
  color: var(--terra);
  text-shadow: 0 0 12px rgba(124,92,252,0.4);
}

/* Stats */
.progress-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.progress-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}

.progress-num {
  font-family: 'Lora', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--terra);
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 0 0 20px rgba(124,92,252,0.3);
}

.progress-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Animations */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }


