:root {
  --bg-deep: #0a0a0f;
  --bg-panel: #0f0f1a;
  --bg-editor: #0d0d1a;
  --bg-label: #080812;
  --accent-html: #e44d26;
  --accent-css: #4a7ef7;
  --accent-js: #f7df1e;
  --accent-out: #00e5a0;
  --border: rgba(255, 255, 255, 0.06);
  --text-muted: #5a5a8a;
  --text-dim: #3a3a5a;
  --topbar-h: 50px;
}

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

html,
body {
  height: 100%;
  background: var(--bg-deep);
  color: #dde1f0;
  font-family: 'Rajdhani', sans-serif;
  overflow: hidden;
}

/* ══ TOP BAR ══ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 500;
}

.logo {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 3px;
  white-space: nowrap;
}

.logo .c1 {
  color: #00e5a0;
}

.logo .c3 {
  color: #e44d26;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: 7px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .18s, box-shadow .18s;
  -webkit-tap-highlight-color: transparent;
}

.btn-label {
  display: inline;
}

.btn-preview {
  background: linear-gradient(135deg, #00e5a0, #00b37a);
  color: #060610;
}

.btn-preview:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0, 229, 160, .35);
}

.btn-download {
  background: linear-gradient(135deg, #4a7ef7, #2655c4);
  color: #fff;
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(74, 126, 247, .4);
}

/* ══ WORKSPACE ══ */
.workspace {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  overflow: hidden;
}

.editors-col {
  display: flex;
  flex-direction: column;
  width: 50%;
  border-right: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.editor-block {
  display: flex;
  flex-direction: column;
  flex: 1;
  border-bottom: 1px solid var(--border);
  min-height: 0;
}

.editor-block:last-child {
  border-bottom: none;
}

/* ══ EDITOR LABEL BAR ══ */
.editor-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 12px;
  height: 36px;
  background: var(--bg-label);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  flex-shrink: 0;
  user-select: none;
}

.label-html {
  border-left: 3px solid var(--accent-html);
}

.label-css {
  border-left: 3px solid var(--accent-css);
}

.label-js {
  border-left: 3px solid var(--accent-js);
}

.label-out {
  border-left: 3px solid var(--accent-out);
}

.label-html .lbl {
  color: var(--accent-html);
}

.label-css .lbl {
  color: var(--accent-css);
}

.label-js .lbl {
  color: var(--accent-js);
}

.label-out .lbl {
  color: var(--accent-out);
}

.label-spacer {
  flex: 1;
}

/* ══ PER-EDITOR TOOLBAR ══ */
.ed-toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

.ed-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.ed-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #dde1f0;
}

.ed-btn:active {
  transform: scale(0.88);
}

.ed-btn.flash {
  color: #00e5a0 !important;
  background: rgba(0, 229, 160, 0.12) !important;
}

.ed-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.ed-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 2px;
  flex-shrink: 0;
}

/* Tooltip — below button */
.ed-btn::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%);
  background: #12122a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #dde1f0;
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
  padding: 3px 7px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 9999;
}

.ed-btn:hover::after {
  opacity: 1;
}

/* ══ TEXTAREA ══ */
.editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

textarea {
  width: 100%;
  height: 100%;
  background: var(--bg-editor);
  color: #c8d3f0;
  padding: 12px 16px;
  border: none;
  outline: none;
  resize: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.8;
  tab-size: 2;
  -moz-tab-size: 2;
  caret-color: #00e5a0;
  transition: box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}

#html-code:focus {
  box-shadow: inset 3px 0 0 var(--accent-html);
}

#css-code:focus {
  box-shadow: inset 3px 0 0 var(--accent-css);
}

#js-code:focus {
  box-shadow: inset 3px 0 0 var(--accent-js);
}

textarea::placeholder {
  color: var(--text-dim);
  font-style: italic;
  font-size: 11.5px;
}

textarea::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

textarea::-webkit-scrollbar-thumb {
  background: #1e1e38;
  border-radius: 3px;
}

/* ══ OUTPUT ══ */
.output-col {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* ══ FULLSCREEN ══ */
#fs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  flex-direction: column;
}

#fs-overlay.active {
  display: flex;
}

.fs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  height: 48px;
  background: #08080f;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fs-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-out);
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 2px;
}

#btn-close-fs {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #e44d26;
  background: #e44d26;
  cursor: pointer;
  transition: background .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}

#btn-close-fs:hover {
  background: #b8310f;
  transform: scale(1.1);
}

#fs-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* ══ TOAST ══ */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #12122a;
  border: 1px solid rgba(0, 229, 160, 0.35);
  color: #fff;
  padding: 11px 24px;
  border-radius: 9px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 1px;
  transition: transform .32s cubic-bezier(.4, 0, .2, 1);
  z-index: 99999;
  white-space: nowrap;
  pointer-events: none;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ══ MOBILE TAB BAR ══ */
.tab-bar {
  display: none;
  flex-shrink: 0;
}

/* ══ TABLET ≤900px ══ */
@media (max-width:900px) {
  .workspace {
    flex-direction: column;
  }

  .editors-col {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    height: 50%;
    flex-shrink: 0;
  }

  .editor-block {
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex: 1;
    min-width: 0;
  }

  .editor-block:last-child {
    border-right: none;
  }

  .output-col {
    height: 50%;
    flex-shrink: 0;
  }

  .btn-label {
    display: none;
  }

  .btn {
    padding: 7px 10px;
  }

  .lbl {
    display: none;
  }

  textarea {
    font-size: 12px;
  }

  .ed-btn {
    width: 24px;
    height: 24px;
  }
}

/* ══ MOBILE ≤600px ══ */
@media (max-width:600px) {
  :root {
    --topbar-h: 46px;
  }

  .logo {
    font-size: 16px;
    letter-spacing: 2px;
  }

  .workspace {
    flex-direction: column;
    bottom: 46px;
  }

  .editors-col {
    flex-direction: column;
    width: 100%;
    height: 100%;
    border-bottom: none;
  }

  .editor-block {
    display: none;
  }

  .editor-block.active {
    display: flex;
    flex: 1;
  }

  .output-col {
    width: 100%;
    height: 100%;
    display: none;
  }

  .output-col.active {
    display: flex;
  }

  .lbl {
    display: inline;
  }

  textarea {
    font-size: 12px;
  }

  .tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 46px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    z-index: 300;
  }

  .tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: none;
    border: none;
    border-top: 2px solid transparent;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    -webkit-tap-highlight-color: transparent;
  }

  .tab-btn[data-tab="html"].active-tab {
    border-top-color: var(--accent-html);
    color: var(--accent-html);
  }

  .tab-btn[data-tab="css"].active-tab {
    border-top-color: var(--accent-css);
    color: var(--accent-css);
  }

  .tab-btn[data-tab="js"].active-tab {
    border-top-color: var(--accent-js);
    color: var(--accent-js);
  }

  .tab-btn[data-tab="out"].active-tab {
    border-top-color: var(--accent-out);
    color: var(--accent-out);
  }
}

@media (max-width:380px) {
  .logo {
    font-size: 14px;
  }

  textarea {
    font-size: 11.5px;
  }

  .ed-btn {
    width: 22px;
    height: 22px;
  }
}