:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-muted: #f7fafc;
  --ink: #142033;
  --muted: #5d6a7c;
  --line: #d7e0ea;
  --brand: #1769aa;
  --brand-strong: #0f4f84;
  --success: #117a4f;
  --warning: #a85f00;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(20, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.topbar h1,
.panel-header h2,
.workspace-toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions,
.toolbar-actions,
.panel-header,
.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.language-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.compact-select {
  width: auto;
  min-width: 132px;
  padding: 9px 10px;
}

.primary-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.primary-button {
  background: var(--brand);
  color: white;
}

.primary-button:hover {
  background: var(--brand-strong);
}

.secondary-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: #aebed0;
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.status-pill,
.difficulty,
.status-dot {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e9f4ff;
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 800;
}

.muted-pill {
  background: #f1f5f9;
  color: var(--muted);
}

.status-dot {
  background: #eef7f2;
  color: var(--success);
}

.api-key-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.api-key-input {
  width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
}

.api-key-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.14);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.45fr) minmax(320px, 0.9fr);
  gap: 18px;
  padding: 18px;
}

.question-panel,
.workspace-panel,
.interviewer-panel,
.report-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.question-panel,
.interviewer-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 116px);
  padding: 18px;
}

.workspace-panel {
  min-height: calc(100vh - 116px);
  padding: 18px;
}

.field-label {
  display: block;
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.select,
#candidateInput {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.select {
  padding: 10px 12px;
}

.select:focus,
#candidateInput:focus,
.code-editor:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.14);
}

.question-copy {
  color: var(--muted);
  line-height: 1.58;
}

.question-copy h3,
.rubric-card h3,
.result-card h3 {
  margin: 18px 0 10px;
  color: var(--ink);
  font-size: 15px;
}

.question-copy ul,
.compact-list {
  padding-left: 18px;
}

.examples {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.example {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.rubric-card,
.result-card {
  margin-top: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.rubric-card p,
.compact-list li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.workspace-toolbar {
  margin-bottom: 14px;
}

.code-editor,
.monaco-editor-shell {
  width: 100%;
  min-height: 430px;
  border-radius: 8px;
}

.code-editor {
  resize: vertical;
  border: 1px solid #b8c5d4;
  background: #101827;
  color: #e6edf7;
  padding: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
}

.monaco-editor-shell {
  overflow: hidden;
  border: 1px solid #b8c5d4;
  background: #101827;
}

.fallback-editor {
  display: none;
}

.monaco-unavailable .monaco-editor-shell {
  display: none;
}

.monaco-unavailable .fallback-editor {
  display: block;
}

.results-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 14px;
}

.test-summary {
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}

.test-results {
  display: grid;
  gap: 8px;
}

.program-output {
  margin-top: 12px;
  border: 1px solid #c6d2df;
  border-radius: 8px;
  background: #101827;
  color: #e6edf7;
  padding: 12px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.program-output strong {
  display: block;
  margin-bottom: 8px;
  color: #a7d2ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.test-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  color: var(--muted);
  font-size: 14px;
}

.test-row strong {
  color: var(--ink);
}

.test-pass {
  color: var(--success);
}

.test-fail {
  color: var(--danger);
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.score-strip div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-muted);
}

.score-strip span {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.score-strip small {
  color: var(--muted);
  font-weight: 700;
}

.conversation {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-height: 280px;
  max-height: 46vh;
  padding-right: 4px;
}

.action-log-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 10px;
}

.action-log-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.action-log {
  display: grid;
  gap: 6px;
  max-height: 130px;
  overflow: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.action-log div {
  border-bottom: 1px solid rgba(215, 224, 234, 0.8);
  padding-bottom: 6px;
}

.action-log div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.bubble {
  border-radius: 8px;
  padding: 11px 12px;
  line-height: 1.45;
  font-size: 14px;
}

.bubble small {
  display: block;
  margin-bottom: 4px;
  color: inherit;
  font-weight: 900;
  opacity: 0.74;
}

.bubble.ai {
  background: #e9f4ff;
  color: #0d355b;
}

.bubble.user {
  background: #eff8f1;
  color: #163d2b;
}

.bubble.system {
  background: var(--surface-muted);
  color: var(--muted);
  border: 1px solid var(--line);
}

.message-form {
  margin-top: 14px;
}

#candidateInput {
  display: block;
  min-height: 88px;
  padding: 12px;
  resize: vertical;
}

.full-width {
  width: 100%;
  margin-top: 10px;
}

.report-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 15, 26, 0.52);
}

.report-card {
  width: min(820px, 100%);
  max-height: min(780px, 90vh);
  overflow: auto;
  padding: 20px;
}

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

.report-section h3 {
  margin: 0 0 8px;
}

.report-section p {
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .question-panel,
  .workspace-panel,
  .interviewer-panel {
    min-height: auto;
  }

  .conversation {
    max-height: 360px;
  }
}

@media (max-width: 720px) {
  .topbar,
  .workspace-toolbar,
  .topbar-actions,
  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .app-shell {
    padding: 10px;
  }

  .results-grid,
  .score-strip {
    grid-template-columns: 1fr;
  }

  .code-editor {
    min-height: 320px;
  }

  .monaco-editor-shell {
    min-height: 320px;
  }
}

.add-question-button {
  margin-top: 8px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 51, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 18px;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: min(620px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-help {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  margin: 0;
}

.modal-card textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font: inherit;
  resize: vertical;
  background: var(--surface-muted);
  color: var(--ink);
}

.modal-card textarea:focus {
  outline: none;
  border-color: var(--brand);
}

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

.modal-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px;
  font: inherit;
  background: var(--surface-muted);
  color: var(--ink);
}

.modal-input:focus {
  outline: none;
  border-color: var(--brand);
}

.modal-status {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.modal-status.progress {
  background: #eef6fd;
  color: var(--brand-strong);
  border: 1px solid #c9e2f5;
}

.modal-status.error {
  background: #fdf0ef;
  color: var(--danger);
  border: 1px solid #f3cfcb;
}

.modal-status.success {
  background: #eefaf4;
  color: var(--success);
  border: 1px solid #c9ecd9;
}

@media (max-width: 720px) {
  .modal-row {
    grid-template-columns: 1fr;
  }
}
