*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: system-ui, sans-serif;
  background: #f9fafb;
  color: #111827;
  min-height: 100vh;
}

a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Auth ─────────────────────────────────────────────── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 2rem;
  width: 100%;
  max-width: 22rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.auth-card h1 { font-size: 1.25rem; margin-bottom: 1.5rem; }

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.auth-tabs button {
  flex: 1;
  padding: 0.4rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: #f3f4f6;
  cursor: pointer;
  font-size: 0.875rem;
}

.auth-tabs button.active {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.875rem; }
.field label { font-size: 0.8125rem; font-weight: 500; color: #374151; }
.field input {
  padding: 0.5rem 0.625rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
}
.field input:focus { outline: 2px solid #4f46e5; outline-offset: 1px; border-color: transparent; }

.btn {
  display: block;
  width: 100%;
  padding: 0.6rem;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 0.25rem;
}
.btn:hover { background: #4338ca; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.error-msg { font-size: 0.8125rem; color: #dc2626; margin-top: 0.75rem; }

/* ── Orientation overlay ──────────────────────────────── */
.orientation-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}

.orientation-card {
  background: #fff;
  border-radius: 0.75rem;
  padding: 2rem;
  max-width: 36rem;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}

.orientation-card h2 { font-size: 1.125rem; margin-bottom: 0.75rem; }
.orientation-card p  { font-size: 0.9375rem; color: #374151; line-height: 1.6; margin-bottom: 0.6rem; }
.orientation-card ol { padding-left: 1.25rem; margin-bottom: 1.25rem; }
.orientation-card li { font-size: 0.9375rem; color: #374151; line-height: 1.7; }
.orientation-card .btn { margin-top: 0; }

/* ── App shell ────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 1.25rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.top-bar .logo { font-weight: 700; font-size: 1rem; color: #4f46e5; }

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8125rem;
}

.top-bar-right a, .top-bar-right button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  color: #6b7280;
}
.top-bar-right a:hover, .top-bar-right button:hover { color: #111827; }

/* ── Mode label ───────────────────────────────────────── */
.mode-label-bar {
  padding: 0.35rem 1.25rem;
  background: #eff6ff;
  border-bottom: 1px solid #dbeafe;
  font-size: 0.8rem;
  color: #1d4ed8;
  font-weight: 500;
  min-height: 1.875rem;
  flex-shrink: 0;
}

.mode-label-bar.hidden { display: none; }

/* ── Chat ─────────────────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.message {
  max-width: 42rem;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #4f46e5;
  color: #fff;
  border-bottom-right-radius: 0.125rem;
}

.message.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 0.125rem;
}

/* ── Input bar ────────────────────────────────────────── */
.input-bar {
  display: flex;
  gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.input-bar textarea {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-family: inherit;
  resize: none;
  height: 2.625rem;
  max-height: 8rem;
  overflow-y: auto;
  line-height: 1.5;
}
.input-bar textarea:focus { outline: 2px solid #4f46e5; outline-offset: 1px; border-color: transparent; }

.input-bar .send-btn {
  padding: 0.5rem 1.125rem;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-end;
  height: 2.625rem;
}
.input-bar .send-btn:hover { background: #4338ca; }
.input-bar .send-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Dashboard ────────────────────────────────────────── */
.dashboard-wrap {
  max-width: 48rem;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

.dashboard-wrap h1 { font-size: 1.25rem; margin-bottom: 1.5rem; }

.module-list { display: flex; flex-direction: column; gap: 0.75rem; }

.module-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.625rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.15s;
}
.module-card:hover { border-color: #4f46e5; }

.module-card .module-step { font-size: 0.8125rem; color: #6b7280; }

.new-module-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem 1rem;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
}
.new-module-btn:hover { background: #4338ca; }

.empty-state { color: #6b7280; font-size: 0.9375rem; }
