:root {
  --bg: #a51f30;
  --bg-deep: #8f1929;
  --surface: #f1e5d2;
  --surface-2: #e9dac4;
  --text: #382b27;
  --muted: #806f65;
  --accent: #f5e9d8;
  --line: rgba(65, 35, 33, 0.15);
  --editor-bg: #2c2424;
  --editor-text: #f1e5d2;
  --success: #78c69a;
  --danger: #d85a5a;
  --shadow: 0 18px 50px rgba(52, 9, 17, 0.15);
}

body.light-theme {
  --bg: #f5f5f2;
  --bg-deep: #e9e9e5;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --text: #171717;
  --muted: #777771;
  --accent: #a51f30;
  --line: rgba(0, 0, 0, 0.12);
  --editor-bg: #f5f5f2;
  --editor-text: #171717;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.06);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--accent);
  font-family: "Manrope", sans-serif;
  transition: background 0.35s ease, color 0.35s ease;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, calc(100% - 48px));
  margin: auto;
}

/* HEADER */

.topbar {
  height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.19);
}

.light-theme .topbar {
  border-color: var(--line);
}

.brand,
.header-actions,
.brand-name,
.connection-status {
  display: flex;
  align-items: center;
}

.brand {
  text-decoration: none;
  color: var(--accent);
  gap: 11px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  background: var(--accent);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 19px;
  border-radius: 8px;
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -1px;
}

.brand-name span {
  color: var(--accent);
  opacity: 0.65;
}

.brand-divider {
  height: 23px;
  width: 1px;
  background: currentColor;
  opacity: 0.3;
  margin: 0 5px;
}

.brand-product {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  opacity: 0.8;
}

.header-actions {
  gap: 24px;
}

.connection-status {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 1px;
  gap: 8px;
  opacity: 0.85;
}

.status-dot,
.live-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  box-shadow: 0 0 0 4px rgba(120,198,154,0.12);
}

.theme-toggle {
  width: 39px;
  height: 39px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.35);
  background: transparent;
  color: var(--accent);
  font-size: 20px;
  transition: 0.25s ease;
}

.light-theme .theme-toggle {
  border-color: var(--line);
}

.theme-toggle:hover {
  transform: rotate(25deg);
  background: var(--surface);
  color: var(--text);
}

/* INTRO */

.main-content {
  padding: 72px 0 55px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 2px;
  opacity: 0.75;
  margin-bottom: 25px;
}

.eyebrow-line {
  width: 27px;
  height: 1px;
  background: currentColor;
}

.intro-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 48px;
}

.intro h1 {
  font-size: clamp(42px, 7vw, 72px);
  line-height: 1.04;
  letter-spacing: -4px;
  font-weight: 800;
}

.intro h1 span {
  color: var(--accent);
  opacity: 0.67;
}

.intro-description {
  margin-top: 19px;
  font-size: 14px;
  opacity: 0.78;
  line-height: 1.7;
}

.language-badge {
  display: flex;
  align-items: center;
  gap: 13px;
  opacity: 0.8;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  line-height: 1.7;
  letter-spacing: 1px;
}

.badge-symbol {
  font-size: 30px;
  font-weight: 500;
}

/* WORKSPACE */

.workspace {
  background: var(--surface);
  color: var(--text);
  border-radius: 18px;
  padding: 25px;
  box-shadow: var(--shadow);
  animation: riseIn 0.7s ease both;
}

.workspace-header,
.workspace-controls,
.editor-toolbar,
.editor-actions,
.file-tab,
.editor-footer,
.panel-heading,
.run-section,
.output-header,
.output-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.workspace-header {
  margin-bottom: 20px;
}

.workspace-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
}

.live-indicator {
  background: #4b9c70;
}

.workspace-controls {
  gap: 12px;
}

.language-label,
.optional-label {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--muted);
}

#languageSelect {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 9px 28px 9px 12px;
  border-radius: 7px;
  outline: none;
  font-size: 12px;
  font-weight: 700;
}

/* EDITOR */

.editor-card {
  overflow: hidden;
  background: var(--editor-bg);
  border-radius: 11px;
  color: var(--editor-text);
}

.editor-toolbar {
  min-height: 49px;
  padding: 0 15px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.file-tab {
  justify-content: flex-start;
  gap: 9px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.file-icon {
  opacity: 0.7;
}

.file-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c38b55;
}

.editor-actions {
  gap: 7px;
}

.tool-button {
  background: transparent;
  color: var(--editor-text);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 5px;
  padding: 7px 10px;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.5px;
  transition: 0.2s ease;
}

.tool-button:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.editor-wrap {
  min-height: 370px;
}

.CodeMirror {
  height: 370px;
  padding: 15px 0;
  background: var(--editor-bg);
  color: var(--editor-text);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  line-height: 1.8;
}

.CodeMirror-gutters {
  background: var(--editor-bg);
  border-right: 1px solid rgba(255,255,255,0.1);
}

.CodeMirror-linenumber {
  color: #93827a;
  padding: 0 13px 0 8px;
}

.CodeMirror-cursor {
  border-left: 2px solid #d8a58b;
}

.CodeMirror-selected {
  background: rgba(200,160,140,0.2) !important;
}

.CodeMirror-focused .CodeMirror-selected {
  background: rgba(200,160,140,0.23) !important;
}

.cm-keyword {
  color: #e4a1a1 !important;
}

.cm-atom,
.cm-number {
  color: #d8bd87 !important;
}

.cm-def {
  color: #a9c8ad !important;
}

.cm-string {
  color: #c5d49d !important;
}

.cm-comment {
  color: #9a9489 !important;
}

.cm-operator {
  color: #e3c5a4 !important;
}

.editor-footer {
  padding: 11px 15px;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: #a99a91;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 1px;
}

/* INPUT */

.input-card {
  margin-top: 25px;
}

.panel-heading {
  margin-bottom: 13px;
}

.panel-heading > div {
  display: flex;
  align-items: center;
  gap: 11px;
}

.panel-index {
  color: #a51f30;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 500;
}

.panel-heading h3 {
  font-size: 14px;
  font-weight: 800;
}

.custom-input {
  width: 100%;
  height: 90px;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  outline: none;
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  transition: border 0.2s ease;
}

.custom-input:focus {
  border-color: #a51f30;
}

.custom-input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.input-hint {
  margin-top: 8px;
  font-size: 10px;
  color: var(--muted);
}

/* RUN */

.run-section {
  margin: 26px 0;
}

.run-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.run-key {
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  font-weight: 500;
}

.run-button {
  min-width: 155px;
  padding: 14px 17px;
  background: #a51f30;
  color: #fff0df;
  border: none;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  transition: 0.25s ease;
}

.run-button:hover {
  background: #801726;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(165,31,48,0.2);
}

.run-button:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.run-icon {
  font-size: 10px;
}

.run-arrow {
  font-size: 15px;
}

/* OUTPUT */

.output-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.output-header {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.output-header .panel-heading {
  margin: 0;
}

.output-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 1px;
}

.status-dot.muted {
  background: #a49a8e;
  box-shadow: none;
}

.console {
  min-height: 170px;
  padding: 20px;
  background: var(--editor-bg);
  color: var(--editor-text);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  line-height: 1.8;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: auto;
}

.console-placeholder {
  min-height: 125px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #a99a91;
  text-align: center;
  gap: 6px;
}

.console-placeholder p {
  font-size: 12px;
}

.console-placeholder span:last-child {
  font-size: 10px;
  opacity: 0.7;
}

.console-symbol {
  color: #d7a18e;
  font-size: 24px;
  margin-bottom: 4px;
}

.console-error {
  color: #ff9d9d;
}

.console-success {
  color: #a6d8b2;
}

.output-footer {
  min-height: 44px;
  padding: 0 15px;
  gap: 15px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.output-footer button {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  font-weight: 700;
}

.output-footer button:hover {
  color: #a51f30;
}

/* NOTE AND FOOTER */

.bottom-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 22px;
  opacity: 0.8;
}

.note-symbol {
  width: 17px;
  height: 17px;
  border: 1px solid currentColor;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  flex-shrink: 0;
}

.bottom-note p {
  max-width: 650px;
  font-size: 10px;
  line-height: 1.7;
}

.footer {
  min-height: 70px;
  border-top: 1px solid rgba(255,255,255,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 1px;
  opacity: 0.8;
}

.light-theme .footer {
  border-color: var(--line);
}

.footer-heart {
  padding: 0 5px;
}

/* ANIMATIONS */

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

button,
.workspace,
.editor-card,
.output-card {
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    border-color 0.3s ease;
}

/* RESPONSIVE */

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 28px, 1120px);
  }

  .topbar {
    height: 70px;
  }

  .brand-product,
  .brand-divider {
    display: none;
  }

  .connection-status {
    font-size: 8px;
  }

  .header-actions {
    gap: 12px;
  }

  .main-content {
    padding-top: 48px;
  }

  .intro-row {
    margin-bottom: 30px;
  }

  .intro h1 {
    letter-spacing: -2.5px;
  }

  .intro-description {
    font-size: 12px;
    max-width: 260px;
  }

  .language-badge {
    display: none;
  }

  .workspace {
    padding: 15px;
    border-radius: 12px;
  }

  .editor-toolbar {
    padding: 0 9px;
  }

  .editor-actions {
    gap: 4px;
  }

  .tool-button {
    padding: 7px 6px;
    font-size: 8px;
  }

  .CodeMirror {
    font-size: 11px;
    height: 330px;
  }

  .editor-wrap {
    min-height: 330px;
  }

  .run-info {
    font-size: 9px;
  }

  .run-button {
    min-width: 130px;
    padding: 13px 10px;
    gap: 8px;
    font-size: 9px;
  }

  .output-footer {
    flex-wrap: wrap;
    padding: 12px;
    font-size: 8px;
  }

  .footer {
    font-size: 8px;
  }
}

@media (max-width: 390px) {
  .brand-name {
    font-size: 17px;
  }

  .connection-status {
    display: none;
  }

  .workspace-controls {
    gap: 6px;
  }

  .language-label {
    font-size: 8px;
  }

  .tool-button {
    font-size: 7px;
  }
}