:root {
  --bg: #f3efe7;
  --paper: #fffaf2;
  --ink: #1f2a1f;
  --muted: #667066;
  --line: #d8cfbf;
  --accent: #1e5c4c;
  --accent-strong: #10392f;
  --warn: #874b2a;
  --pass: #1d6a42;
  --shadow: 0 20px 50px rgba(69, 54, 35, 0.12);
  --editor-height: 420px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(211, 177, 121, 0.28), transparent 32%),
    linear-gradient(180deg, #f6f1e8 0%, #efe6d7 100%);
  color: var(--ink);
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
}

.page-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px;
}

.sidebar,
.question-panel,
.editor-panel,
.feedback-panel {
  background: rgba(255, 250, 242, 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(216, 207, 191, 0.8);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.sidebar {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.eyebrow,
.question-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  color: var(--muted);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1;
}

.intro {
  color: var(--muted);
  line-height: 1.6;
}

.tab-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.picker-label {
  font-size: 13px;
  color: var(--muted);
}

#questionSearch,
#sortSelect,
#statusFilter {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: #fffdf8;
  color: var(--ink);
  font: inherit;
}

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

.picker-group {
  display: grid;
  gap: 8px;
}

.question-list {
  flex: 1;
  min-height: 320px;
  max-height: calc(100vh - 350px);
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.question-option {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
  padding: 12px;
  font: inherit;
  cursor: pointer;
}

.question-option.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(30, 92, 76, 0.3);
}

.question-option-head,
.question-option-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.question-option-head {
  margin-bottom: 6px;
  align-items: flex-start;
}

.question-option-title {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
}

.question-option-meta {
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  background: #ece3d3;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
}

.status-pill.done {
  background: rgba(29, 106, 66, 0.12);
  color: var(--pass);
}

.status-pill.skipped {
  background: rgba(102, 112, 102, 0.14);
  color: var(--muted);
}

.status-pill.wrong {
  background: rgba(135, 75, 42, 0.12);
  color: var(--warn);
}

.status-pill.undone {
  background: #ece3d3;
  color: var(--muted);
}

.question-list-empty {
  padding: 16px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: rgba(255, 253, 248, 0.7);
}

.tab,
.primary-button,
.ghost-button,
.submit-button {
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.tab {
  background: #ece3d3;
  color: var(--muted);
}

.tab.is-active {
  background: var(--accent);
  color: #f7f1e8;
}

.primary-button,
.submit-button {
  background: var(--accent-strong);
  color: #f8f4ed;
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.ghost-button.is-active {
  background: #ece3d3;
  border-color: #cfc2ab;
}

.ghost-button.small {
  padding: 8px 12px;
}

.tab:hover,
.primary-button:hover,
.ghost-button:hover,
.submit-button:hover {
  transform: translateY(-1px);
}

.stats-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: #f0e5d3;
}

.stats-card div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-card span {
  color: var(--muted);
}

.main-panel {
  display: grid;
  gap: 20px;
}

.question-panel,
.editor-panel,
.feedback-panel {
  padding: 22px;
}

.question-head,
.editor-head,
.feedback-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.editor-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.editor-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.editor-stack.has-answer {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.draft-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.source-link {
  color: var(--accent);
  text-decoration: none;
}

.question-body,
#feedbackText {
  width: 100%;
  margin: 0;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 18px;
  line-height: 1.6;
  overflow: auto;
}

.question-body {
  min-height: 260px;
  max-height: 420px;
}

.markdown-body {
  line-height: 1.7;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body > :last-child {
  margin-bottom: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre,
.markdown-body blockquote,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 0 0 14px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 22px;
}

.markdown-body code {
  padding: 2px 6px;
  border-radius: 8px;
  background: #f2eadc;
  font-size: 13px;
}

.markdown-body pre {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
  overflow: auto;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.markdown-body a {
  color: var(--accent);
}

.markdown-body img {
  max-width: 100%;
  border-radius: 14px;
}

#codeEditor {
  height: var(--editor-height);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.answer-panel {
  height: var(--editor-height);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fffdf8;
  overflow: hidden;
}

.answer-panel[hidden] {
  display: none;
}

.answer-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f7f0e5;
}

.answer-code {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 16px;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
  color: #14271f;
  white-space: pre-wrap;
}

.hint-panel-body {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow: auto;
  line-height: 1.7;
  color: #14271f;
}

.hint-panel-body p {
  margin: 0;
  white-space: pre-wrap;
}

.cm-editor {
  height: 100%;
  font-size: 14px;
}

.cm-scroller {
  height: 100%;
  font-family: "SF Mono", "Menlo", "Monaco", monospace;
  overflow: auto;
}

.cm-focused {
  outline: none;
}

.cm-editor.cm-focused {
  box-shadow: inset 0 0 0 1px rgba(30, 92, 76, 0.25);
}

.cm-tooltip-ts-quickinfo {
  max-width: min(640px, 80vw);
  padding: 10px 12px;
  border-radius: 12px;
  white-space: pre-wrap;
}

.cm-tooltip-ts-signature {
  margin: 0;
  font: inherit;
  color: #f3f4f6;
}

.cm-tooltip-ts-docs {
  margin-top: 8px;
  color: #cbd5e1;
  line-height: 1.5;
}

#feedbackText {
  min-height: 120px;
}

.explanation {
  margin-top: 16px;
  padding: 16px;
  border-radius: 16px;
  background: #f2eadc;
  border: 1px solid var(--line);
}

.explanation h4 {
  margin-bottom: 8px;
}

.feedback-panel.is-pass #feedbackText {
  border-color: rgba(29, 106, 66, 0.45);
  color: var(--pass);
}

.feedback-panel.is-fail #feedbackText {
  border-color: rgba(135, 75, 42, 0.45);
  color: var(--warn);
}

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

  .sidebar {
    order: 2;
  }

  .main-panel {
    order: 1;
  }

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

  .editor-stack,
  .editor-stack.has-answer {
    grid-template-columns: 1fr;
  }
}
