/* Zone application : auth, onboarding, chat */
#page-app {
  background: var(--gray, #f8fafb);
  min-height: 100vh;
}

.app-header {
  background: var(--navy, #0a1628);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: 1.2rem;
}

.app-header h1 em {
  color: #00c07f;
  font-style: normal;
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-status {
  font-size: 12px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  max-width: 280px;
  text-align: center;
}

.auth-status--idle {
  color: #cbd5e1;
}

.auth-status--loading {
  color: #fde68a;
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.4);
  animation: pulse 1.2s ease-in-out infinite;
}

.auth-status--ok {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
}

.auth-status--info {
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.4);
}

.auth-status--err {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.auth-feedback {
  font-size: 0.9rem;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
}

.auth-feedback--info {
  background: #eff6ff;
  color: #1d4ed8;
}

.auth-feedback--success {
  background: #ecfdf5;
  color: #047857;
}

.auth-feedback--error {
  background: #fef2f2;
  color: #b91c1c;
}

.auth-feedback.hidden {
  display: none;
}

#auth-mode.is-loading {
  opacity: 0.75;
  cursor: wait;
}

#auth-mode:disabled,
#toggle-auth-mode:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-status.ok {
  color: #a3e8d0;
}

.auth-status.err {
  color: #fca5a5;
}

.user-pill {
  font-size: 13px;
  font-weight: 600;
}

#quota-info {
  font-size: 12px;
  opacity: 0.85;
}

.app-main {
  max-width: 720px;
  margin: 24px auto;
  padding: 0 16px 48px;
}

.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(10, 22, 40, 0.06);
}

.card h2 {
  margin-bottom: 8px;
}

.card .sub {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  margin-bottom: 14px;
  background: #fff;
  color: #0f172a;
}

select option {
  background: #fff;
  color: #0f172a;
}

.btn-ghost {
  background: transparent;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.error {
  color: #b91c1c;
  font-size: 0.85rem;
}

#chat-messages {
  min-height: 260px;
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
  background: #f8fafb;
  border-radius: 12px;
  margin-bottom: 16px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.msg-user {
  margin-left: auto;
  background: #00c07f;
  color: #fff;
}

.msg-bot {
  background: #fff;
  border: 1px solid #e2e8f0;
}

.msg-bot strong {
  color: #0a1628;
}

.msg-bot p {
  margin: 0 0 8px;
}

.msg-bot p:last-child {
  margin-bottom: 0;
}

.msg-bot ul,
.msg-bot ol {
  margin: 0 0 8px 18px;
  padding: 0;
}

.msg-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.85rem;
}

.msg-table th,
.msg-table td {
  border: 1px solid #e2e8f0;
  padding: 6px 8px;
  text-align: left;
}

.msg-loading {
  font-style: italic;
  color: #64748b;
}

.chat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.chat-head h2 {
  margin-bottom: 4px;
}

.chat-head .sub {
  margin-bottom: 0;
}

.subject-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}

.subject-picker span {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
}

.subject-picker select {
  margin-bottom: 0;
}

.chat-input-row {
  display: flex;
  gap: 8px;
}

.chat-input-row input {
  margin-bottom: 0;
  flex: 1;
}

#ob-subjects {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
}

.chip input {
  width: auto;
  margin: 0;
}

.chip-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chip-disabled input {
  cursor: not-allowed;
}

.ob-hint {
  margin-top: -8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #64748b;
}

.dev-panel {
  margin-top: 16px;
  padding: 12px;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 10px;
  font-size: 12px;
  font-family: monospace;
}

.dev-panel button {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #00c07f;
  color: #fff;
  font-weight: 600;
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: #00a86b;
  font-size: 14px;
  cursor: pointer;
  background: none;
  border: none;
  font-weight: 600;
}

.pay-packs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.pay-pack {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  background: #fff;
}

.pay-pack--featured {
  border-color: #00c07f;
  box-shadow: 0 0 0 1px #00c07f;
}

.pay-pack h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.pay-pack-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0a1628;
  margin-bottom: 8px;
}

.pay-pack-desc {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 12px;
  min-height: 40px;
}

.pay-banner {
  background: #ecfdf5;
  border: 1px solid #00c07f;
  color: #065f46;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}

.pay-banner--om {
  background: #fff7ed;
  border-color: #fb923c;
  color: #9a3412;
}

.pay-banner--warn {
  background: #fef9c3;
  border-color: #eab308;
  color: #854d0e;
}

.pay-banner p {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.pay-pack-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pay-om-panel {
  background: #fff7ed;
  border: 1px solid #fb923c;
  border-radius: 12px;
  padding: 16px;
  margin: 16px 0;
}

.pay-om-panel h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.pay-om-step {
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 10px;
  color: #7c2d12;
}

.pay-om-code {
  display: inline-block;
  background: #fff;
  border: 1px dashed #fb923c;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #c2410c;
}

.pay-om-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.pay-om-panel--processing {
  background: #ecfdf5;
  border-color: #00c07f;
  color: #065f46;
}

.pay-om-meta {
  font-size: 13px;
  margin-top: 8px;
}

.pay-om-sms-tip {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.home-hero {
  margin-bottom: 24px;
}

.home-quota {
  font-weight: 600;
  color: #00a86b;
  margin-top: 8px;
}

.home-section-title {
  font-size: 1rem;
  margin: 20px 0 12px;
  color: #0a1628;
}

.home-subject-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.subject-stat-chip {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.subject-stat-chip:hover {
  border-color: #00c07f;
}

.home-features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.feature-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.feature-card:hover:not(.feature-card--soon) {
  border-color: #00c07f;
  box-shadow: 0 4px 12px rgba(0, 192, 127, 0.12);
}

.feature-card--soon {
  opacity: 0.65;
  cursor: default;
}

.feature-card-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.feature-card h4 {
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.feature-card p {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}

.feature-badge {
  display: inline-block;
  margin-top: 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #00a86b;
}

.feature-badge--soon {
  color: #94a3b8;
}

.history-list {
  margin: 16px 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.history-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
}

.history-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.history-subject-tag {
  background: #ecfdf5;
  color: #065f46;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.history-date {
  font-size: 12px;
  color: #94a3b8;
}

.history-q {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}

.history-a {
  font-size: 14px;
  color: #334155;
  line-height: 1.5;
}

.history-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.exam-question {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: #fff;
}

.exam-question legend {
  font-size: 14px;
  margin-bottom: 10px;
  padding: 0 4px;
}

.exam-option {
  display: block;
  margin: 8px 0;
  font-size: 14px;
  cursor: pointer;
}

.exam-option input {
  margin-right: 8px;
}

.exam-score-banner {
  background: #ecfdf5;
  border: 1px solid #00c07f;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 1.1rem;
  text-align: center;
}

.exam-result {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 14px;
}

.exam-result--ok {
  background: #ecfdf5;
  border: 1px solid #86efac;
}

.exam-result--ko {
  background: #fef2f2;
  border: 1px solid #fca5a5;
}

.exam-result-detail {
  font-size: 13px;
  color: #475569;
  margin: 4px 0;
}

.exam-result-explain {
  font-size: 13px;
  margin-top: 6px;
  color: #0f172a;
}

.exam-type-grid {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

@media (min-width: 640px) {
  .exam-type-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

.exam-type-card {
  text-align: left;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.exam-type-card:hover:not(:disabled) {
  border-color: #6366f1;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12);
}

.exam-type-card:disabled {
  opacity: 0.65;
  cursor: default;
  background: #f8fafc;
}

.exam-type-card--locked {
  opacity: 0.7;
  cursor: not-allowed;
  border-style: dashed;
}

.exam-cert-banner {
  margin-top: 12px;
  padding: 12px 14px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  border-radius: 10px;
  color: #065f46;
  font-size: 14px;
}

.exam-type-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.exam-type-card p {
  margin: 0 0 8px;
  font-size: 13px;
  color: #64748b;
}

.exam-type-meta {
  font-size: 12px;
  color: #6366f1;
  font-weight: 600;
}

.ranking-mine {
  padding: 12px 14px;
  background: #eef2ff;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
}

.ranking-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 14px;
}

.ranking-pos {
  font-weight: 700;
  color: #6366f1;
}

.ranking-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-pts {
  font-weight: 600;
  color: #0f172a;
}

.ranking-avg {
  font-size: 13px;
  color: #64748b;
}

.exercise-meta {
  font-size: 13px;
  font-weight: 600;
  color: #6366f1;
  margin-bottom: 12px;
}

.exercise-question {
  padding: 14px 16px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  margin-bottom: 16px;
  font-size: 15px;
  line-height: 1.55;
}

.exercise-hints {
  margin-bottom: 16px;
}

.exercise-hint {
  font-size: 13px;
  color: #475569;
  padding: 8px 12px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  margin-bottom: 8px;
  border-radius: 0 8px 8px 0;
}

#exercise-answer {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 12px;
}

.exercise-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.exercise-feedback {
  margin-top: 12px;
  padding: 14px;
  background: #f8fafc;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.55;
}

.exercise-correction {
  margin-top: 12px;
  font-size: 14px;
}

.exercise-correction-body {
  margin-top: 8px;
  padding: 12px;
  background: #ecfdf5;
  border-radius: 8px;
}

.exercise-result-banner {
  margin-bottom: 12px;
}

.photo-file-label {
  display: block;
  margin-top: 12px;
  font-weight: 600;
}

#photo-file {
  display: block;
  margin-top: 8px;
  width: 100%;
}

.photo-preview-wrap {
  margin-top: 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
  max-height: 280px;
}

.photo-preview-wrap img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: #f8fafc;
}

.photo-extracted {
  margin-bottom: 12px;
}

.photo-extracted-text {
  margin-top: 8px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  max-height: 180px;
  overflow: auto;
}

.photo-answer {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
}

.voice-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.voice-record-btn.recording {
  background: #dc2626;
  border-color: #dc2626;
}

.voice-record-btn.recording:hover {
  background: #b91c1c;
}

.voice-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #dc2626;
}

.voice-hint {
  margin-top: 8px;
}

.voice-file-label {
  display: block;
  margin-top: 16px;
  font-weight: 600;
}

#voice-file {
  display: block;
  margin-top: 8px;
  width: 100%;
}

.voice-playback-wrap {
  margin-top: 12px;
}

.voice-playback-wrap audio {
  width: 100%;
}

.voice-transcript {
  margin-bottom: 12px;
}

.voice-transcript-text {
  margin-top: 8px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  white-space: pre-wrap;
}

.voice-answer {
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
}

.input-lang-picker {
  margin-top: 8px;
  font-size: 0.88rem;
}

.chat-head .input-lang-picker {
  margin-top: 0;
}

.lang-understood {
  margin-bottom: 8px;
}

.lang-understood p {
  margin-top: 8px;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}

.voice-transcript-print h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.lang-pickers {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lang-local-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 0.92rem;
  cursor: pointer;
}

.lang-answer-block {
  margin-bottom: 8px;
}

.lang-answer-tag {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
  color: #64748b;
}

.lang-answer-local .lang-local-text {
  white-space: pre-wrap;
  line-height: 1.5;
}

#lang-messages {
  max-height: 420px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.exam-mode-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px;
}

.exam-mode-btn--active {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.08);
}

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
}

.chat-file-label {
  margin: 0;
  cursor: pointer;
}

.file-name-hint {
  margin: 0;
  flex: 1;
  min-width: 120px;
}

.premium-hint {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: #64748b;
}

.chat-file-label.disabled,
.photo-file-label.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
