* { margin: 0; padding: 0; box-sizing: border-box; }

/* Reset all link colors globally */
a, a:link, a:visited, a:active { color: inherit; }

body {
  font-family: ui-monospace, 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #1e1e2e;
  color: #9399b2;
  -webkit-text-size-adjust: 100%;
}

header {
  background: #181825;
  border-bottom: 1px solid #313244;
  padding: 4px 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 12px;
  font-weight: 600;
  color: #a6adc8;
  white-space: nowrap;
}

header h1 a { text-decoration: none; }
header h1 a:hover { text-decoration: underline; }

header h1 .at-sign {
  color: #585b70;
  font-weight: 400;
}

.toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar button, .toolbar select {
  font-family: inherit;
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid #45475a;
  border-radius: 3px;
  background: #313244;
  color: #9399b2;
  cursor: pointer;
  -webkit-appearance: none;
}

.toolbar select {
  -webkit-appearance: menulist;
}

.toolbar button:hover:not(:disabled) {
  background: #45475a;
}

.toolbar button:disabled {
  opacity: 0.35;
  cursor: default;
}

#btn-run {
  background: #40a02b;
  color: #1e1e2e;
  font-weight: 600;
  border-color: #40a02b;
}
#btn-run:hover:not(:disabled) {
  background: #4cb838;
}

#btn-stop {
  background: #d20f39;
  color: #fff;
  font-weight: 600;
  border-color: #d20f39;
}
#btn-stop:hover:not(:disabled) {
  background: #e33e5a;
}

#sel-mode {
  font-weight: 600;
  color: #cdd6f4;
  border-color: #585b70;
}

#status-bar {
  font-size: 11px;
  color: #585b70;
  margin-left: auto;
  white-space: nowrap;
}

main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

.pane-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #585b70;
  padding: 2px 8px;
  background: #181825;
  border-bottom: 1px solid #313244;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

#input-area {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  padding: 8px;
  font-family: ui-monospace, 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-size: 12px;
  line-height: 1.4;
  background: #1e1e2e;
  color: #bac2de;
  tab-size: 4;
  -webkit-text-size-adjust: 100%;
}

#output-area, .race-output {
  flex: 1;
  overflow: auto;
  padding: 8px;
  font-family: ui-monospace, 'SF Mono', 'Menlo', 'Consolas', 'Liberation Mono', monospace;
  font-size: 12px;
  line-height: 1.4;
  background: #1e1e2e;
  color: #bac2de;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.divider {
  width: 3px;
  background: #313244;
  cursor: col-resize;
  flex-shrink: 0;
}
.divider:hover {
  background: #585b70;
}

footer {
  background: #181825;
  border-top: 1px solid #313244;
  padding: 3px 12px;
  font-size: 10px;
  color: #585b70;
  text-align: center;
  flex-shrink: 0;
}

footer a { text-decoration: none; color: #7f849c; }
footer a:hover { text-decoration: underline; }

/* ---- Tab bar (Race mode) ---- */

.tab-bar {
  display: inline-flex;
  gap: 2px;
  margin-left: 8px;
}

.tab-bar .tab {
  font-family: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 1px 8px;
  border: 1px solid #313244;
  border-radius: 3px 3px 0 0;
  background: transparent;
  color: #585b70;
  cursor: pointer;
  border-bottom: none;
}

.tab-bar .tab:hover {
  color: #9399b2;
  background: #1e1e2e;
}

.tab-bar .tab.active {
  color: #cdd6f4;
  background: #1e1e2e;
  border-color: #585b70;
}

.tab-bar .tab.winner {
  color: #40a02b;
  border-color: #40a02b;
}

.tab-bar .tab.loser {
  color: #585b70;
}

/* ---- Ivy Verification banners ---- */

#btn-verify {
  background: #89b4fa;
  color: #1e1e2e;
  font-weight: 600;
  border-color: #89b4fa;
}
#btn-verify:hover:not(:disabled) {
  background: #a6c8ff;
}
#btn-verify:disabled {
  opacity: 0.35;
  cursor: default;
}

.ivy-pass {
  display: block;
  margin: 8px 0 4px;
  padding: 6px 10px;
  background: #1a3a1a;
  color: #40a02b;
  border-left: 3px solid #40a02b;
  font-weight: 600;
}

.ivy-fail {
  display: block;
  margin: 8px 0 4px;
  padding: 6px 10px;
  background: #3a1a1a;
  color: #d20f39;
  border-left: 3px solid #d20f39;
  font-weight: 600;
}

/* ---- Mobile tab bar ---- */

.mobile-tabs {
  display: none;
}

/* ---- Mobile: full-screen tabbed layout ---- */

@media (max-width: 600px) {
  .mobile-tabs {
    display: flex;
    background: #181825;
    border-bottom: 1px solid #313244;
    flex-shrink: 0;
  }

  .mobile-tabs .mtab {
    flex: 1;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 0;
    border: none;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #585b70;
    cursor: pointer;
    text-align: center;
  }

  .mobile-tabs .mtab:hover {
    color: #9399b2;
  }

  .mobile-tabs .mtab.active {
    color: #cdd6f4;
    border-bottom-color: #89b4fa;
  }

  main {
    flex-direction: column;
  }

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

  .divider {
    display: none;
  }

  .mobile-hidden {
    display: none !important;
  }

  .tab-bar {
    display: none !important;
  }

  .pane-label {
    display: none !important;
  }

  #status-bar {
    margin-left: 0;
    width: 100%;
  }
}
