:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --text: #17211d;
  --muted: #65716c;
  --line: #d9e0dc;
  --accent: #16745b;
  --accent-dark: #0f5946;
  --accent-soft: #dff1eb;
  --warn: #b45d18;
  --danger: #ad3434;
  --blue: #275f9f;
  --shadow: 0 14px 38px rgba(28, 42, 37, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
textarea,
input {
  font: inherit;
}

input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary:hover:not(:disabled) {
  background: var(--accent-dark);
  color: #ffffff;
}

.update-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: min(520px, calc(100% - 24px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #17211d;
  box-shadow: var(--shadow);
  color: #ffffff;
  padding: 10px 12px 10px 14px;
  transform: translateX(-50%);
}

.update-banner span {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.update-banner button {
  min-height: 34px;
  white-space: nowrap;
}

.guide-button {
  border-radius: 999px;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 800;
}

.guide-dialog {
  width: min(680px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(23, 33, 29, 0.22);
  color: var(--text);
  padding: 0;
}

.guide-dialog::backdrop {
  background: rgba(23, 33, 29, 0.34);
  backdrop-filter: blur(4px);
}

.guide-content {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.guide-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.guide-header h2,
.guide-section h3 {
  margin: 0;
  letter-spacing: 0;
}

.guide-header h2 {
  font-size: 24px;
  line-height: 1.2;
}

.guide-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.guide-section h3 {
  font-size: 16px;
  line-height: 1.3;
}

.guide-section p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.profile-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 247, 249, 0.88);
  backdrop-filter: blur(8px);
}

.profile-dialog {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 22px;
}

.profile-dialog h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: 0;
}

.profile-copy {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.profile-list {
  display: grid;
  gap: 10px;
}

.profile-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  text-align: left;
  padding: 12px;
}

.profile-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.profile-option strong,
.profile-option span {
  display: block;
}

.profile-option span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.profile-form {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.profile-form label {
  font-weight: 700;
  font-size: 14px;
}

.profile-form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.profile-switch {
  display: flex;
  align-items: center;
  gap: 7px;
  border-color: var(--accent);
  border-radius: 999px;
  min-height: 34px;
  padding: 6px 12px;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.profile-switch span {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-switch strong {
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
}

.topbar h1,
.panel h2,
.question-box h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 32px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.session-meta > span,
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns:
    minmax(250px, 0.85fr)
    minmax(260px, 0.95fr)
    minmax(360px, 1.35fr)
    minmax(280px, 0.85fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 20px;
  line-height: 1.2;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 18px;
}

.topic-list {
  display: grid;
  gap: 10px;
}

.topic-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 64px;
  padding: 12px;
  text-align: left;
}

.topic-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.topic-option strong,
.topic-option span {
  display: block;
}

.topic-option span span,
.topic-option > span:nth-child(2) > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.topic-score {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.topic-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.traffic-light {
  display: inline-block;
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(173, 52, 52, 0.12);
}

.traffic-light.practising {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(180, 93, 24, 0.13);
}

.traffic-light.mastered {
  background: #138a5a;
  box-shadow: 0 0 0 3px rgba(19, 138, 90, 0.14);
}

.lesson-box {
  display: grid;
  gap: 12px;
}

.lesson-block {
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  padding: 12px;
}

.lesson-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.lesson-block p,
.lesson-block li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.lesson-block p {
  margin: 0;
}

.lesson-block ol {
  margin: 0;
  padding-left: 20px;
}

.teacher-actions,
.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.session-log {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  max-height: 300px;
  overflow: auto;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.log-item strong {
  display: block;
  margin-bottom: 4px;
}

.question-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 16px;
}

.question-box h3 {
  font-size: 18px;
}

.question-box pre {
  margin: 12px 0 0;
  white-space: pre-wrap;
  color: var(--text);
  font-family: inherit;
  line-height: 1.55;
}

.answer-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0;
}

.tab {
  border: 0;
  border-radius: 0;
  background: var(--surface);
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.photo-area {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.upload-zone {
  display: grid;
  gap: 5px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  padding: 16px;
  cursor: pointer;
}

.upload-zone span {
  font-weight: 700;
  color: var(--accent-dark);
}

.upload-zone small {
  color: var(--muted);
}

#photoInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.photo-preview {
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf9;
}

.transcription {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
  color: var(--muted);
  line-height: 1.5;
}

.answer-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #ffffff;
  line-height: 1.5;
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(22, 116, 91, 0.22);
  outline-offset: 2px;
}

.feedback {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 14px;
}

.feedback h3 {
  margin: 0;
  font-size: 16px;
}

.feedback p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.feedback-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.feedback-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.score {
  font-weight: 800;
  color: var(--accent-dark);
}

.mastery-list {
  display: grid;
  gap: 12px;
}

.skill-row {
  display: grid;
  gap: 7px;
}

.skill-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.skill-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}

.skill-score {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: #e7ebe8;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar-fill.low {
  background: var(--danger);
}

.bar-fill.mid {
  background: var(--warn);
}

.bar-fill.high {
  background: var(--blue);
}

.hidden {
  display: none !important;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .mastery-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .update-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .session-meta {
    justify-content: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .feedback-grid {
    grid-template-columns: 1fr;
  }

  .profile-form-row {
    grid-template-columns: 1fr;
  }
}
