:root {
  --ide-bg: #101827;
  --ide-surface: #18243a;
  --ide-border: #2b3b56;
  --ide-accent: #78d6c6;
  --ide-text: #eff6ff;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--ide-bg);
  color: var(--ide-text);
}

* { box-sizing: border-box; }

html, body { width: 100%; min-height: 100%; margin: 0; }

body { min-height: 100dvh; overflow: hidden; }

button { font: inherit; }

.skip-link {
  position: fixed;
  z-index: 10;
  top: .5rem;
  left: .5rem;
  padding: .6rem .8rem;
  border-radius: .4rem;
  background: #fff;
  color: #101827;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); outline: 3px solid #78d6c6; }

.ide-shell {
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  background: #eef3f8;
}

.titlebar {
  z-index: 2;
  display: flex;
  align-items: center;
  gap: clamp(1rem, 4vw, 4rem);
  min-width: 0;
  padding: 0 1.25rem;
  background: linear-gradient(105deg, var(--ide-bg) 0%, var(--ide-surface) 100%);
  border-bottom: 1px solid var(--ide-border);
  box-shadow: 0 2px 12px rgb(10 20 35 / 28%);
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .55rem;
  color: #f8fbff;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -.02em;
  text-decoration: none;
  white-space: nowrap;
}

.brand strong { color: var(--ide-accent); font-weight: 760; }

.ide-switcher {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: .9rem;
  min-width: 0;
}

.language-tabs {
  display: flex;
  align-self: stretch;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 .75rem, #000 calc(100% - .75rem), transparent);
  mask-image: linear-gradient(to right, transparent, #000 .75rem, #000 calc(100% - .75rem), transparent);
}

.editor-mode {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid #3a4a63;
  border-radius: 9px;
  background: rgb(6 13 24 / 42%);
}

.mode-button {
  min-height: 29px;
  padding: 0 .65rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #b9c6da;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
}

.mode-button:hover { color: #fff; }
.mode-button.is-active { background: var(--ide-accent); color: #102038; }
.mode-button:focus-visible { outline: 3px solid var(--ide-accent); outline-offset: 2px; }

.ide-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  height: 100%;
  padding: 0 clamp(.75rem, 2vw, 1.35rem);
  border: 0;
  background: transparent;
  color: #b9c6da;
  cursor: pointer;
  font-size: .94rem;
  font-weight: 650;
  transition: color .16s ease, background-color .16s ease;
}

.ide-tab::after {
  position: absolute;
  right: .8rem;
  bottom: 0;
  left: .8rem;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--ide-accent);
  content: "";
  opacity: 0;
  transform: scaleX(.5);
  transition: opacity .16s ease, transform .16s ease;
}

.ide-tab:hover { background: rgb(255 255 255 / 6%); color: #fff; }
.ide-tab.is-active { color: #fff; }
.ide-tab.is-active::after { opacity: 1; transform: scaleX(1); }

.language-dot { width: .56rem; height: .56rem; border-radius: 50%; }
.python { background: #71c8ed; }
.miniworlds { background: #78d6c6; }
.sql { background: #bc8cf2; }
.java { background: #ffab70; }

.window-actions { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.active-label { color: #aab9cf; font-size: .79rem; font-weight: 600; white-space: nowrap; }

.icon-button, .fullscreen-button {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid #3a4a63;
  border-radius: 8px;
  background: #26354d;
  color: #eff6ff;
  cursor: pointer;
  transition: background-color .16s ease, transform .16s ease;
}
.icon-button:hover, .fullscreen-button:hover { background: #344866; transform: translateY(-1px); }
.icon-button:focus-visible, .fullscreen-button:focus-visible, .ide-tab:focus-visible { outline: 3px solid var(--ide-accent); outline-offset: -3px; }
.fullscreen-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.help-button { font-size: 1.05rem; font-weight: 800; }

.workspace { position: relative; min-height: 0; background: #fff; }
.ide-frames { position: relative; z-index: 1; width: 100%; height: 100%; }
.ide-frame { width: 100%; height: 100%; background: #fff; }
.ide-frame[hidden] { display: none; }
.h5p-host { overflow: auto; }
.h5p-host > iframe { width: 100%; min-height: 100%; border: 0; }

.loading-indicator {
  position: absolute;
  z-index: 0;
  top: 50%;
  left: 50%;
  color: #52627a;
  font-size: .9rem;
  transform: translate(-50%, -50%);
}

.shortcut-dialog {
  width: min(32rem, calc(100vw - 2rem));
  border: 0;
  border-radius: .75rem;
  box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 35%);
  color: #17243a;
  padding: 1.25rem;
}
.shortcut-dialog::backdrop { background: rgb(6 13 24 / 65%); }
.shortcut-dialog__header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.shortcut-dialog h2 { margin: 0; font-size: 1.15rem; }
.shortcut-dialog .icon-button { border: 1px solid #cbd5e1; background: #f1f5f9; color: #17243a; font-size: 1.5rem; line-height: 1; }
.shortcut-dialog p { margin: 1rem 0 0; color: #52627a; font-size: .9rem; }
.shortcut-list { display: grid; gap: .8rem; margin: 1.25rem 0 0; }
.shortcut-list div { display: grid; grid-template-columns: minmax(10rem, 1fr) 1.2fr; gap: 1rem; }
.shortcut-list dt, .shortcut-list dd { margin: 0; }
.shortcut-list dd { color: #52627a; font-size: .9rem; }
kbd { display: inline-block; padding: .15rem .35rem; border: 1px solid #cbd5e1; border-bottom-width: 2px; border-radius: .25rem; background: #f8fafc; font-family: inherit; font-size: .8rem; }

@media (max-width: 640px) {
  .ide-shell { grid-template-rows: 58px minmax(0, 1fr); }
  .titlebar { gap: .25rem; padding: 0 .55rem; }
  .brand { font-size: .9rem; }
  .ide-switcher { gap: .4rem; }
  .ide-tab { flex: 0 0 auto; padding: 0 .6rem; font-size: .82rem; }
  .ide-tab::after { right: .45rem; left: .45rem; }
  .ide-tab .language-dot { display: none; }
  .active-label { display: none; }
  .window-actions { gap: .35rem; }
  .editor-mode { padding: 2px; }
  .mode-button { min-height: 27px; padding: 0 .5rem; font-size: .72rem; }
  .icon-button, .fullscreen-button { width: 33px; height: 33px; }
  .shortcut-list div { grid-template-columns: 1fr; gap: .25rem; }
}

@media (max-width: 380px) {
  .titlebar { padding: 0 .35rem; }
  .ide-tab { padding: 0 .45rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
