:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #0b0b0b;
  --panel-soft: #101010;
  --ink: #f4f4f4;
  --muted: #9a9a9a;
  --line: rgba(255, 255, 255, 0.13);
  --ok: #7cff9f;
  --bad: #ff6b6b;
  --warn: #ffd37a;
}

* {
  box-sizing: border-box;
}

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

button,
textarea {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
}

h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 850;
}

h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.lead {
  max-width: 560px;
  margin: 8px 0 0;
  color: #d2d2d2;
  line-height: 1.5;
}

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

.progress span,
.points {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #e8e8e8;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.tab-button {
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
}

.tab-button strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.tab-button span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tab-button:hover,
.tab-button:focus-visible {
  border-color: rgba(124, 255, 159, 0.7);
  outline: none;
}

.tab-button.active {
  border-color: var(--ok);
  background: rgba(124, 255, 159, 0.08);
}

.tab-button.solved {
  color: var(--ok);
}

.lab-grid {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(420px, 0.88fr);
  gap: 12px;
  align-items: stretch;
}

.console-pane,
.task-pane {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.console-pane {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto minmax(190px, 0.48fr);
  min-height: calc(100vh - 178px);
}

.pane-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.ghost-button {
  min-width: 86px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  border-color: var(--ok);
  outline: none;
}

#code-editor {
  width: 100%;
  height: 100%;
  min-height: 360px;
  resize: vertical;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #070707;
  color: #e8ffeF;
  caret-color: var(--ok);
  padding: 14px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

#code-editor:focus {
  outline: 1px solid var(--ok);
  outline-offset: -1px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.action-row button {
  min-height: 42px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 850;
}

#run-sample {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

#submit-code {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.action-row button:hover,
.action-row button:focus-visible {
  border-color: var(--ok);
  outline: none;
}

.action-row button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.output-panel {
  min-height: 190px;
  background: #070707;
  color: #e8ffeF;
}

.output-title {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#judge-output {
  min-height: 156px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

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

.summary {
  margin: 0;
  color: #d2d2d2;
  line-height: 1.6;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.code-card {
  min-height: 56px;
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: #f0f0f0;
  padding: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  color: #e6e6e6;
  line-height: 1.6;
  list-style: none;
}

ol li {
  position: relative;
  min-height: 34px;
  padding: 6px 0 6px 42px;
}

ol li::before {
  content: attr(data-number);
  position: absolute;
  left: 0;
  top: 4px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ok);
  background: #070707;
  font-size: 12px;
  font-weight: 900;
}

.pass {
  color: var(--ok);
}

.fail {
  color: var(--bad);
}

.flag {
  color: var(--warn);
  font-weight: 850;
}

.flag-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.flag-modal.open {
  display: grid;
}

.flag-dialog {
  position: relative;
  width: min(620px, 100%);
  border: 1px solid rgba(124, 255, 159, 0.45);
  border-radius: 8px;
  background: #080808;
  padding: 28px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
  text-align: center;
}

.flag-dialog h2 {
  margin-bottom: 16px;
  font-size: 30px;
}

.flag-value {
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050505;
  color: var(--warn);
  padding: 18px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(20px, 4.5vw, 34px);
  line-height: 1.25;
  font-weight: 900;
}

.flag-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.flag-close:hover,
.flag-close:focus-visible {
  border-color: var(--ok);
  outline: none;
}

@media (max-width: 980px) {
  .tabs,
  .lab-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .console-pane {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 18px, 620px);
    padding-top: 12px;
  }

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

  .brand-logo {
    width: 40px;
    height: 40px;
  }

  .progress {
    justify-content: start;
  }

  h1 {
    font-size: 28px;
  }

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