:root {
  --primary-color: #FF4500;
  --bg-medium: #1e1e1e;
  --bg-light: #2c2c2c;
  --bg-white: #ffffff;
  --border-color: #444;
  --text-color: #222;
  --shadow-dark: rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background: var(--bg-white);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 16px;
}

/* HEADER */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg-white);
  box-shadow: 0 2px 10px var(--shadow-dark);
  position: sticky;
  top: 0;
  z-index: 1000;
}

header h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
}

header span {
  color: #000;
}

.navbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.navbar a {
  text-decoration: none;
  color: black;
  font-size: 1rem;
  font-weight: 600;
  transition: 0.2s;
}

.navbar a:hover {
  color: var(--primary-color);
  transform: translateY(-2px);
}

header select {
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  max-width: 150px;
  /* prevent stretching */
}

/* CONTAINER */
.container {
  display: flex;
  flex: 1;
  gap: 1.5rem;
  padding: 2rem;
  min-height: calc(100vh - 70px);
  flex-wrap: wrap;
  transition: padding 0.3s ease, gap 0.3s ease;
}

/* EDITOR */
.editor-container {
  flex: 2;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-medium);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 8px 16px var(--shadow-dark);
  min-width: 300px;
}

.editor-header {
  font-weight: 600;
  font-size: 1.2rem;
  margin-bottom: 0.8rem;
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
  width: fit-content;
}

.editor {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-light);
  width: 100%;
  min-height: 400px;
}

/* RIGHT PANEL */
.right-panel {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 250px;
}

#io-box {
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  font-family: 'Roboto Mono', monospace;
  font-size: 1rem;
  resize: none;
  min-height: 150px;
}

.run-btn {
  padding: 1rem 2.5rem;
  border-radius: 50px;
  background-color: var(--primary-color);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: 0.2s;
  min-width: 150px;
  align-items: center;
}

.run-btn:hover {
  background-color: #ff6b3d;
  transform: translateY(-2px);
}

/* IFRAME FIX */
iframe#htmlOutput {
  display: none;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
}

iframe#htmlOutput.show {
  display: block;
  min-height: 200px;
}

/* MOBILE MENU TOGGLER */
header label[for="toggler"] {
  font-size: 2.5rem;
  cursor: pointer;
  display: none;
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1100;
}

#toggler {
  display: none;
}

/* RESPONSIVE STYLES */
@media (max-width: 1024px) {
  .container {
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
  }

  .editor-container,
  .right-panel {
    width: 100%;
  }
}

@media (max-width: 880px) {
  .container {
    padding: 0.5rem 0.8rem;
    gap: 0.8rem;
  }

  .editor {
    min-height: 250px;
  }
}

@media (max-width: 768px) {
  header label[for="toggler"] {
    display: block;
  }

  .navbar {
    position: fixed;
    top: 30px;
    right: 0;
    width: min(80vw, 220px);
    height: calc(100dvh - 60px);
    background: white;
    flex-direction: column;
    padding: 3rem 0.8rem;
    gap: 0.8rem;
    z-index: 999;
    overflow: hidden;

    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  #toggler:checked~nav.navbar {
    transform: translateX(0);
    opacity: 1;
  }

  .navbar a {
    width: 100%;
    padding: 0.4rem 0;
    border-bottom: 1px solid #ddd;
  }
}

@media (max-width: 450px) {
  html {
    font-size: 50%;
  }

  .editor {
    min-height: 200px;
  }

  .run-btn {
    width: 100%;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
  }
}

@media (max-width: 400px) {
  body {
    font-size: 13px;
  }

  .editor-container,
  .right-panel {
    padding: 0.5rem;
  }

  #io-box {
    font-size: 0.9rem;
  }

  .run-btn {
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
  }
}