:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #202124;
  --bright: #111111;
  --dim: #4a4a4a;
  --card: #ffffff;
  --border: #d5d5d5;
  --divider: #e0ebf5;
  --code-bg: #ffffd8;
  --gutter-bg: #f5f5dc;
  --accent: #007d9c;
  --run: #375eab;
  --value-bg: #e0ebf5;
  --value-fg: #375eab;
  --tour-width: 1440px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 Arial, Helvetica, sans-serif;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 20;
  padding: 0.5rem 1rem;
  background: var(--run);
  color: #ffffff;
}

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.topbar {
  height: 48px;
  background: var(--accent);
  color: #ffffff;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--tour-width);
  height: 48px;
  margin: 0 auto;
  padding: 0 18px;
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 18px;
  color: #ffffff;
  text-decoration: none;
}

.go-logo {
  display: block;
  width: 66px;
  height: auto;
}

.topbar h1 {
  margin: 0;
  overflow: hidden;
  color: #ffffff;
  font: 700 22px/1.1 Arial, Helvetica, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar h1 span {
  color: #ffffff;
  font-weight: 400;
  opacity: 0.82;
}

.project-links {
  display: flex;
  align-self: stretch;
}

.project-links a {
  display: grid;
  min-width: 72px;
  padding: 0 12px;
  place-items: center;
  color: #ffffff;
  font-size: 13px;
  text-decoration: none;
}

.project-links a:hover {
  background: rgba(255, 255, 255, 0.12);
}

button,
select {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #f7f7f7;
  color: var(--fg);
  cursor: pointer;
  font: 14px/1.2 Arial, Helvetica, sans-serif;
}

button:hover:not(:disabled),
select:hover {
  border-color: var(--run);
}

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

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--run);
  outline-offset: 2px;
}

main {
  display: grid;
  grid-template-columns: minmax(360px, 40%) minmax(0, 60%);
  width: 100%;
  max-width: var(--tour-width);
  min-height: calc(100vh - 78px);
  min-height: calc(100dvh - 78px);
  margin: 0 auto;
}

.lesson-pane {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 24px 28px 20px;
  border-right: 6px solid var(--divider);
  background: var(--card);
}

.lesson-copy {
  max-width: 42rem;
}

.lesson-pane h2 {
  margin: 0 0 14px;
  color: var(--bright);
  font: 700 clamp(25px, 2vw, 31px)/1.18 Arial, Helvetica, sans-serif;
  word-break: break-word;
}

.lesson-value {
  display: inline-block;
  margin: 0 0 18px;
  padding: 3px 8px;
  background: var(--value-bg);
  color: var(--value-fg);
  font-size: 13px;
  font-weight: 700;
}

.lesson-summary {
  margin: 0;
  max-width: 36em;
  color: var(--dim);
  font: 16px/1.68 Arial, Helvetica, sans-serif;
}

.lesson-summary code {
  font-family: Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.84em;
  background: #eef2f6;
  color: #2f5c8f;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

.lesson-gopher {
  margin: auto auto 0;
  text-align: center;
}

.lesson-gopher img {
  display: block;
  width: 200px;
  max-width: 45vw;
  height: auto;
  margin: 0 auto;
}

.lesson-gopher figcaption {
  margin-top: 4px;
  color: #777777;
  font-size: 10px;
}

.lesson-gopher a {
  color: inherit;
}

.lesson-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 7px;
  margin: 4px 0 20px;
}

.lesson-select-label,
#lesson-select {
  min-width: 0;
  width: 100%;
}

.playground {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(130px, 20%);
  min-width: 0;
  background: #ffffff;
}

.editor-section {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.editor-toolbar,
.editor-actions {
  display: flex;
  min-height: 35px;
  align-items: center;
  background: #fafafa;
}

.editor-toolbar {
  border-bottom: 1px solid var(--border);
}

.file-label {
  align-self: stretch;
  display: flex;
  min-width: 118px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-top: 0;
  border-bottom: 0;
  background: #ffffff;
  color: var(--bright);
  font: 14px/1 Arial, Helvetica, sans-serif;
}

#imports-btn {
  min-height: 29px;
  margin: 3px 4px 3px auto;
}

.editor-code {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: var(--code-bg);
}

#line-numbers {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 2;
  width: 42px;
  margin: 0;
  padding: 10px 7px;
  overflow: hidden;
  border-right: 1px solid #e5e5c7;
  background: var(--gutter-bg);
  color: #999999;
  pointer-events: none;
  text-align: right;
  font: 13px/1.5 Consolas, "Liberation Mono", monospace;
  user-select: none;
}

#editor-highlight,
#editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 10px 16px 10px 52px;
  border: 0;
  border-radius: 0;
  font: 13px/1.5 Consolas, "Liberation Mono", "SFMono-Regular", monospace;
  tab-size: 4;
  white-space: pre;
}

#editor-highlight {
  overflow: hidden;
  background: var(--code-bg);
  color: var(--fg);
  pointer-events: none;
}

#editor {
  z-index: 1;
  overflow: auto;
  background: transparent;
  caret-color: var(--fg);
  color: transparent;
  outline-offset: -2px;
  resize: none;
  -webkit-text-fill-color: transparent;
}

#editor::selection {
  background: rgba(55, 94, 171, 0.25);
}

.tok-keyword {
  color: #a000a0;
}

.tok-type,
.tok-builtin {
  color: #0000cc;
}

.tok-constant,
.tok-number {
  color: #6600cc;
}

.tok-string {
  color: #cc0000;
}

.tok-comment {
  color: #a85d00;
}

.editor-actions {
  justify-content: flex-end;
  gap: 4px;
  padding: 4px;
  border-top: 6px solid var(--divider);
}

.status-msg {
  overflow: hidden;
  margin-right: auto;
  padding-left: 6px;
  color: var(--dim);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-actions button {
  min-height: 29px;
}

#run-btn {
  min-width: 58px;
  border-color: var(--run);
  background: var(--run);
  color: #ffffff;
  font-weight: 700;
}

.output-section {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

.output-section h3 {
  margin: 0;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#output {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: var(--dim);
  white-space: pre-wrap;
  word-break: break-word;
  font: 13px/1.5 Consolas, "Liberation Mono", monospace;
}

#output[data-state="error"] {
  background: #fff1f1;
  color: #991b1b;
}

#output[data-state="success"] {
  background: #effaf1;
  color: #166534;
}

.statusbar {
  display: flex;
  min-height: 30px;
  align-items: center;
  border-top: 1px solid var(--border);
  background: #fafafa;
  color: var(--dim);
  font-size: 11px;
}

#conn-status {
  display: flex;
  min-height: 29px;
  align-items: center;
  width: 100%;
  max-width: var(--tour-width);
  margin: 0 auto;
  padding: 3px 14px;
}

@media (max-height: 720px) and (min-width: 761px) {
  .lesson-gopher {
    display: none;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    padding: 0 10px;
  }

  .go-logo {
    width: 54px;
  }

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

  .topbar h1 span,
  .project-links {
    display: none;
  }

  main {
    display: block;
    min-height: 0;
  }

  .lesson-pane {
    min-height: 0;
    padding: 22px 16px 16px;
    border-right: 0;
    border-bottom: 6px solid var(--divider);
  }

  .lesson-pane h2 {
    font-size: 25px;
  }

  .lesson-summary {
    font-size: 14.5px;
    line-height: 1.62;
  }

  .lesson-gopher {
    display: none;
  }

  .lesson-nav {
    margin: 2px 0 18px;
  }

  .playground {
    display: block;
  }

  .editor-section {
    height: min(62dvh, 440px);
    min-height: min(340px, 62dvh);
  }

  .editor-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
  }

  .output-section {
    min-height: min(160px, 30dvh);
  }

  #line-numbers {
    width: 22px;
    font-size: 6.4pt;
  }

  #editor-highlight,
  #editor {
    padding-left: 29px;
    font-size: 6.4pt;
  }

  #editor {
    -webkit-overflow-scrolling: touch;
  }

  #output {
    font-size: 7pt;
  }
}

@media (max-width: 390px) {
  .brand {
    gap: 10px;
  }

  .go-logo {
    width: 50px;
  }

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

  .lesson-nav {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
  }

  #prev-btn,
  #next-btn {
    overflow: hidden;
    padding-inline: 9px;
    font-size: 0;
    white-space: nowrap;
  }

  #prev-btn::before,
  #next-btn::before {
    font-size: 14px;
  }

  #prev-btn::before {
    content: "\2190";
  }

  #next-btn::before {
    content: "\2192";
  }
}
