/* ── Reverse Drill — Chat + Canvas layout ──────────────────────── */

/* Setup screen */
.reverse-setup {
  max-width: 480px;
  margin: 2rem auto;
  padding: 0 1rem;
}
.reverse-setup h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}
.reverse-setup p {
  color: var(--text-secondary, #8b949e);
  margin-bottom: 1.5rem;
}
.reverse-setup .setup-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.reverse-setup .setup-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.reverse-setup .setup-field label {
  font-size: 0.85rem;
  color: var(--text-secondary, #8b949e);
}

/* Split-pane main area */
.reverse-main {
  display: grid;
  grid-template-columns: 1fr 280px;
  height: calc(100vh - 56px);          /* navbar height */
  overflow: hidden;
}

/* Chat pane (left) */
.reverse-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: 1px solid var(--border, #30363d);
}
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border, #30363d);
  background: var(--bg-surface, #161b22);
}
.chat-input textarea {
  flex: 1;
  resize: none;
  background: var(--bg-input, #0d1117);
  color: var(--text, #e6edf3);
  border: 1px solid var(--border, #30363d);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  min-height: 40px;
  max-height: 120px;
}
.chat-input textarea:focus {
  outline: none;
  border-color: var(--accent, #58a6ff);
}
.chat-input button {
  align-self: flex-end;
}

/* Chat messages */
.chat-msg {
  display: flex;
  gap: 0.5rem;
  max-width: 90%;
}
.chat-msg-system {
  align-self: flex-start;
}
.chat-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
}
.chat-msg-system .chat-msg-avatar {
  background: var(--accent, #58a6ff);
  color: #fff;
}
.chat-msg-user .chat-msg-avatar {
  background: #238636;
  color: #fff;
}
.chat-msg-body {
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.chat-msg-user .chat-msg-body {
  background: var(--bg-surface, #1c2128);
}

/* Feedback styling inside messages */
.chat-msg-body .feedback-correct {
  color: #3fb950;
  font-weight: 500;
}
.chat-msg-body .feedback-incorrect {
  color: #f85149;
  font-weight: 500;
}
.chat-msg-body .feedback-close {
  color: #d29922;
  font-weight: 500;
}
.chat-msg-body .expected-sentence {
  display: block;
  margin-top: 0.5rem;
  padding: 6px 10px;
  background: rgba(88, 166, 255, 0.08);
  border-left: 3px solid var(--accent, #58a6ff);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
}
.chat-msg-body .verb-info {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--text-secondary, #8b949e);
}

/* Gloss diff rendering (shows changed slots only) */
.gloss-diff {
  display: block;
  margin-top: 0.5rem;
  padding: 8px 10px;
  background: rgba(63, 185, 80, 0.08);
  border-left: 3px solid var(--green, #3fb950);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  line-height: 1.4;
}
.gloss-diff-slot {
  display: inline-block;
  min-width: 45px;
  font-weight: 600;
  color: var(--text, #e6edf3);
  margin-right: 0.5rem;
}
.gloss-diff-prev {
  text-decoration: line-through;
  color: var(--red, #f85149);
  margin-right: 0.25rem;
}
.gloss-diff-arrow {
  color: var(--text-secondary, #8b949e);
  margin: 0 0.25rem;
}
.gloss-diff-curr {
  color: var(--green, #3fb950);
  font-weight: 500;
  margin-right: 0.5rem;
}
.gloss-label {
  display: inline;
  font-size: 0.75rem;
  color: var(--text-secondary, #8b949e);
  margin-left: 0.5rem;
}

/* Interlinear gloss table */
.interlinear-gloss {
  width: 100%;
  margin-top: 0.5rem;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.interlinear-gloss td {
  padding: 4px 6px;
  border: 1px solid var(--border, #30363d);
  text-align: center;
}
.gloss-tokens {
  background: var(--bg-input, #0d1117);
  font-weight: 500;
}
.gloss-roles {
  background: rgba(88, 166, 255, 0.05);
  color: var(--accent, #58a6ff);
  font-size: 0.75rem;
}
.gloss-english {
  background: var(--bg-input, #0d1117);
  font-size: 0.75rem;
  color: var(--text-secondary, #8b949e);
}

/* Translation bridge (code literacy: shows English equivalent) */
.translation-bridge {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--text-secondary, #8b949e);
  padding: 0 0.5rem;
  border-left: 2px solid var(--accent, #58a6ff);
  padding-left: 0.75rem;
}

/* Canvas pane (right) */
.reverse-canvas {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-surface, #161b22);
}
.reverse-canvas .canvas-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border, #30363d);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary, #8b949e);
}
#canvas-container {
  flex: 1;
  overflow: hidden;
}

/* Canvas wrapper for confidence state (ghosted/solid/committed) */
.canvas-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  transition: all 200ms ease;
}
.canvas-wrapper.canvas-ghost {
  border: 2px solid var(--yellow, #d29922);
  border-radius: 8px;
  padding: 2px;
  background: rgba(210, 153, 34, 0.05);
}
.canvas-wrapper.canvas-ghost .canvas-iframe {
  opacity: 0.7;
  border-radius: 6px;
}
.canvas-wrapper.canvas-solid {
  border: 2px solid var(--green, #3fb950);
  border-radius: 8px;
  padding: 2px;
}
.canvas-wrapper.canvas-solid .canvas-iframe {
  opacity: 1;
}
.canvas-wrapper.canvas-committed {
  border: 2px solid var(--green-dark, #238636);
  border-radius: 8px;
  padding: 2px;
  box-shadow: inset 0 0 8px rgba(63, 185, 80, 0.1);
}
.canvas-wrapper.canvas-committed::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 1.2rem;
  color: var(--green-dark, #238636);
  font-weight: 700;
}

.canvas-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.canvas-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border, #30363d);
  font-size: 0.8rem;
  color: var(--text-secondary, #8b949e);
}
.canvas-controls .drill-counter {
  flex: 1;
}

/* Mobile canvas toggle */
.canvas-toggle {
  display: none;
  position: fixed;
  bottom: 70px;
  right: 16px;
  z-index: 100;
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--accent, #58a6ff);
  color: #fff;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Summary screen */
.reverse-summary {
  max-width: 480px;
  margin: 2rem auto;
  padding: 0 1rem;
  text-align: center;
}
.reverse-summary .score-big {
  font-size: 3rem;
  font-weight: 700;
  margin: 1rem 0;
}
.reverse-summary .score-label {
  font-size: 1rem;
  color: var(--text-secondary, #8b949e);
}

/* ── Mobile responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  .reverse-main {
    grid-template-columns: 1fr;
  }
  .reverse-canvas {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50vh;
    z-index: 90;
    border-top: 2px solid var(--accent, #58a6ff);
    border-radius: 12px 12px 0 0;
  }
  .reverse-canvas.visible {
    display: flex;
  }
  .canvas-toggle {
    display: block;
  }
}
