:root {
  --orange: #e85d04;
  --orange-dark: #c2410c;
  --orange-deep: #9a3412;
  --cream: #f3e5c3;
  --beige: #fff8e7;
  --panel: #f7ecd2;
  --ink: #3d2914;
  --muted: #7a5a32;
  --border: #c45c26;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: Tahoma, Verdana, Geneva, sans-serif;
}

body {
  background-image:
    linear-gradient(180deg, #f8d48b 0px, var(--cream) 120px);
}

.page {
  height: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 85vw;
  margin: 0 auto;
  border-left: 3px solid var(--border);
  border-right: 3px solid var(--border);
  background: var(--cream);
}

.chrome {
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
}

.logo {
  position: relative;
  align-self: stretch;
  flex: 0 0 auto;
  aspect-ratio: 1000 / 517;
  overflow: hidden;
  background: var(--cream);
}

.logo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.chrome-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--cream);
}

.topbar {
  display: flex;
  align-items: stretch;
  margin-right: 12px;
  background: linear-gradient(180deg, #f4a261 0%, var(--orange) 45%, var(--orange-dark) 100%);
  border-bottom: 3px outset #f4a261;
  border-left: 2px solid var(--orange-deep);
  border-right: 2px solid var(--orange-deep);
  color: #fff8e7;
}

.topbar nav {
  display: flex;
}

.topbar nav a {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  color: #fff8e7;
  text-decoration: none;
  font-weight: bold;
  border-right: 1px solid var(--orange-deep);
}

.topbar nav a:hover {
  background: rgba(255, 248, 231, 0.18);
}

.topbar nav a.current {
  background: var(--cream);
  color: var(--orange-deep);
  text-shadow: none;
  border-bottom: 3px solid var(--cream);
  margin-bottom: -3px;
}

.page.playground .topbar nav a.current {
  background: transparent;
  color: #fff8e7;
  border-bottom: 0;
  margin-bottom: 0;
}

.main {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.footer {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  background: #ead8a8;
  border-top: 2px inset #fff8e7;
  text-align: center;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  margin-right: 12px;
  background: var(--panel);
  border: 2px outset #fff8e7;
}

.run-btn {
  font-family: Tahoma, Verdana, sans-serif;
  font-weight: bold;
  font-size: 15px;
  color: #fff8e7;
  background: linear-gradient(180deg, #f4a261, var(--orange));
  border: 2px outset #f6b56a;
  padding: 6px 18px;
  cursor: pointer;
}

.run-btn:active {
  border-style: inset;
}

.run-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.flag {
  font-size: 14px;
  user-select: none;
}

.flag select {
  font-family: Tahoma, Verdana, sans-serif;
  font-size: 14px;
  font-weight: bold;
  color: var(--ink);
  background: var(--beige);
  border: 2px inset #ead8a8;
  padding: 3px 6px;
}

.status {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--beige);
  border: 2px outset #fff8e7;
  min-height: 0;
}

.editor-panel { flex: 1 1 auto; min-height: 280px; }
.terminal-panel {
  flex: 0 0 14rem;
  height: 14rem;
  min-height: 14rem;
  max-height: 14rem;
}

.panel-title {
  padding: 4px 8px;
  font-size: 12px;
  font-weight: bold;
  color: #fff8e7;
  background: linear-gradient(180deg, #e07a2f, var(--orange-dark));
  border-bottom: 1px solid var(--orange-deep);
}

.panel-tabs {
  display: flex;
  flex-shrink: 0;
  background: linear-gradient(180deg, #e07a2f, var(--orange-dark));
  border-bottom: 1px solid var(--orange-deep);
}

.panel-tab {
  font-family: Tahoma, Verdana, sans-serif;
  font-size: 12px;
  font-weight: bold;
  color: #fff8e7;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--orange-deep);
  padding: 6px 14px;
  cursor: pointer;
}

.panel-tab:hover {
  background: rgba(255, 248, 231, 0.18);
}

.panel-tab.current {
  background: var(--beige);
  color: var(--orange-deep);
}

.editor-stack {
  flex: 1;
  min-height: 0;
  position: relative;
}

.editor-pane {
  position: absolute;
  inset: 0;
}

.editor-pane.hidden {
  display: none;
}

.editor {
  flex: 1;
  min-height: 0;
}

.terminal {
  flex: 1;
  min-height: 0;
  padding: 6px;
  background: #3d2914;
}

.noscript {
  color: var(--orange-deep);
}

.prose {
  background: var(--beige);
  border: 2px outset #fff8e7;
  padding: 16px 22px 28px;
  line-height: 1.45;
}

.prose h1 {
  margin-top: 0;
  color: var(--orange-deep);
  border-bottom: 2px solid var(--orange);
  padding-bottom: 6px;
}

.prose h2 {
  color: var(--orange-dark);
}

.prose a { color: var(--orange-dark); }

.doc-back {
  margin: 0 0 12px;
  font-size: 14px;
}

.prose code {
  background: #f3e5c3;
  padding: 1px 4px;
  border: 1px solid #ead8a8;
  font-family: Consolas, "Courier New", monospace;
}

.prose pre {
  background: #3d2914;
  color: #fff8e7;
  padding: 12px;
  overflow: auto;
  border: 2px inset #c45c26;
}

.prose pre code {
  background: transparent;
  border: 0;
  color: inherit;
  padding: 0;
}

.lib-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 20px;
}

.lib-toc a {
  font-family: Consolas, "Courier New", monospace;
  font-weight: bold;
  padding: 2px 10px;
  background: var(--cream);
  border: 1px solid #ead8a8;
}

.lib h2 {
  scroll-margin-top: 12px;
}

.lib pre {
  max-height: 28rem;
}

@media (max-width: 700px) {
  .page { border: 0; }
  .editor-panel { min-height: 240px; }
}
