:root {
  --navy: #0F1B2D;
  --navy-light: #16233A;
  --navy-lighter: #1E2E47;
  --border: #26374F;
  --amber: #F5A623;
  --amber-dim: #B87F1A;
  --green: #1A5C38;
  --green-light: #2A8055;
  --red: #C0453A;
  --text: #EAEFF5;
  --text-dim: #9AAAC0;
  --white: #FFFFFF;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--navy);
  color: var(--text);
  min-height: 100vh;
}

.screen {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}

.screen.active {
  display: flex;
}

/* ---------- Shared ---------- */

.app-shell {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--amber), var(--amber-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--navy);
  font-size: 1.2rem;
}

.brand-text h1 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--white);
}

.brand-text span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.85rem 1.4rem;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.1s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--amber);
  color: var(--navy);
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-secondary {
  background: var(--navy-lighter);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-block {
  width: 100%;
}

input, select, textarea {
  font-family: inherit;
  background: var(--navy-lighter);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
}

label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  margin-top: 1rem;
}

.card {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
}

/* ---------- Screen 1: Welcome ---------- */

.welcome-card {
  margin-top: 1rem;
}

.welcome-card h2 {
  margin-top: 0;
  color: var(--white);
}

.welcome-sub {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
}

.unit-preview {
  background: var(--navy-lighter);
  border-radius: 10px;
  padding: 1rem;
  margin: 1.2rem 0;
  border-left: 3px solid var(--amber);
}

.unit-preview .unit-title {
  color: var(--amber);
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.unit-preview .unit-meta {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}

.pill {
  display: inline-block;
  background: var(--navy);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-right: 0.4rem;
}

/* ---------- Screen 2: Conversation ---------- */

.convo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.convo-header .who h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--white);
}

.convo-header .who span {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat-box {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
}

.stat-box .num {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--amber);
}

.stat-box .label {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.message-feed {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 0.5rem 0;
  min-height: 200px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 85%;
}

.msg-row.alex {
  align-self: flex-start;
}

.msg-row.student {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-bubble {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 0.94rem;
  line-height: 1.45;
}

.msg-row.alex .msg-bubble {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-row.student .msg-bubble {
  background: var(--amber);
  color: var(--navy);
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

.msg-name {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
  padding: 0 0.2rem;
}

.mini-card {
  margin-top: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.83rem;
  line-height: 1.4;
  max-width: 100%;
}

.mini-card.correction {
  background: rgba(192, 69, 58, 0.12);
  border: 1px solid rgba(192, 69, 58, 0.35);
}

.mini-card.correction .cc-original {
  text-decoration: line-through;
  color: #E08A80;
}

.mini-card.correction .cc-arrow {
  color: var(--text-dim);
  margin: 0 0.3rem;
}

.mini-card.correction .cc-corrected {
  color: #7FD99A;
  font-weight: 600;
}

.mini-card.correction .cc-rule {
  color: var(--text-dim);
  margin-top: 0.25rem;
  font-size: 0.78rem;
}

.mini-card.vocab {
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.35);
}

.mini-card.vocab .vc-word {
  color: var(--amber);
  font-weight: 700;
}

.mini-card.vocab .vc-def {
  color: var(--text);
  margin-top: 0.15rem;
}

.mini-card.vocab .vc-example {
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.2rem;
}

.mini-card.fluency {
  background: rgba(26, 92, 56, 0.15);
  border: 1px solid rgba(26, 92, 56, 0.4);
  color: #8FE0AC;
}

.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 0 0.6rem;
  gap: 0.7rem;
}

.transcript-preview {
  min-height: 1.4rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
  text-align: center;
  padding: 0 1rem;
}

.mic-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: none;
  background: var(--amber);
  color: var(--navy);
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mic-btn:active {
  transform: scale(0.95);
}

.mic-btn.listening {
  background: var(--red);
  color: var(--white);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 69, 58, 0.5); }
  70% { box-shadow: 0 0 0 18px rgba(192, 69, 58, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 69, 58, 0); }
}

.mic-label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.convo-footer {
  display: flex;
  justify-content: center;
  margin-top: 0.8rem;
}

.thinking-indicator {
  align-self: flex-start;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
  padding: 0.5rem 0;
}

/* ---------- Screen 3: Feedback report ---------- */

.report-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.report-header h2 {
  color: var(--amber);
  margin-bottom: 0.2rem;
}

.report-header .report-meta {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin: 1rem 0 1.5rem;
}

.score-item .score-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.score-item .score-label b {
  color: var(--white);
}

.score-bar-track {
  height: 10px;
  background: var(--navy-lighter);
  border-radius: 999px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--amber-dim), var(--amber));
}

.score-item.overall .score-bar-fill {
  background: linear-gradient(90deg, var(--green), var(--green-light));
}

.report-section {
  margin-bottom: 1.4rem;
}

.report-section h3 {
  color: var(--amber);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
}

.well-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.well-list li {
  background: rgba(26, 92, 56, 0.15);
  border-left: 3px solid var(--green-light);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.error-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.error-table th, .error-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.error-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.error-table .wrong {
    color: #E08A80;
    text-decoration: line-through;
}

.error-table .right {
    color: #7FD99A;
}

.vocab-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.vocab-columns h4 {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin: 0 0 0.5rem;
}

.vocab-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.vocab-chip {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.vocab-chip.used {
  background: rgba(26, 92, 56, 0.2);
  color: #7FD99A;
  border: 1px solid rgba(127, 217, 154, 0.4);
}

.vocab-chip.missed {
  background: rgba(192, 69, 58, 0.12);
  color: #E08A80;
  border: 1px solid rgba(224, 138, 128, 0.4);
}

.priority-box {
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.18), rgba(245, 166, 35, 0.06));
  border: 1px solid var(--amber);
  border-radius: 12px;
  padding: 1.2rem;
}

.priority-box .priority-focus {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 0.4rem;
}

.priority-box .priority-why,
.priority-box .priority-tip {
  font-size: 0.9rem;
  margin-top: 0.4rem;
  color: var(--text);
}

.priority-box .priority-tip b {
  color: var(--amber);
}

.message-box {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem;
  font-size: 0.92rem;
  line-height: 1.55;
}

.message-box.teacher {
  background: rgba(15, 27, 45, 0.6);
  border-color: var(--green-light);
}

.message-box .signoff {
  margin-top: 0.6rem;
  color: var(--amber);
  font-weight: 600;
}

.report-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.report-actions .btn {
  flex: 1;
}

.hidden {
  display: none !important;
}

.error-banner {
  background: rgba(192, 69, 58, 0.15);
  border: 1px solid var(--red);
  color: #E08A80;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* ---------- Screen 4: Progress portal ---------- */

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  height: 140px;
  padding: 0.5rem 0.2rem 0;
  overflow-x: auto;
}

.trend-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 34px;
  height: 100%;
}

.trend-bar {
  width: 22px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--amber), var(--amber-dim));
  min-height: 4px;
}

.trend-bar-score {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.trend-bar-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
  white-space: nowrap;
}

.empty-note {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  background: var(--navy-lighter);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.history-row:hover {
  border-color: var(--amber);
}

.history-row .hr-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.history-row .hr-session {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.history-row .hr-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.history-row .hr-score {
  font-weight: 700;
  color: var(--amber);
  font-size: 1.1rem;
  white-space: nowrap;
}

.error-watch-item {
  background: rgba(192, 69, 58, 0.1);
  border-left: 3px solid var(--red);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.error-watch-item .ew-count {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---------- Print ---------- */

@media print {
  body { background: white; color: black; }
  .app-shell { max-width: 100%; }
  .report-actions, .brand { display: none !important; }
  .card, .message-box, .priority-box { border-color: #ccc !important; }
  .report-header h2, .report-section h3, .priority-box .priority-focus { color: #B87F1A !important; }
}

@media (max-width: 480px) {
  .vocab-columns { grid-template-columns: 1fr; }
  .score-grid { grid-template-columns: 1fr; }
}
