/* ================================================================
   CodePreview.live — premium glass UI redesign
   Same structure + same functionality: upload, paste, clear, run,
   line numbers, stats, tab indentation, responsive layout.
   Removed: "main.html" tab label, hero section, help chips, footer.
   Preview close button: classy, minimal, smaller.
================================================================= */

:root {
  --bg-0: #030713;
  --bg-1: #07111f;
  --bg-2: #101a2e;
  --glass: rgba(255, 255, 255, .075);
  --glass-2: rgba(255, 255, 255, .105);
  --glass-3: rgba(255, 255, 255, .14);
  --stroke: rgba(255, 255, 255, .13);
  --stroke-strong: rgba(151, 206, 255, .34);
  --text: #eef6ff;
  --text-soft: #b9c8dc;
  --muted: #74849c;
  --muted-2: #536176;
  --cyan: #63e6ff;
  --blue: #6aa6ff;
  --violet: #a78bfa;
  --mint: #86efac;
  --rose: #fb7185;
  --amber: #f7c873;
  --shadow: 0 30px 90px rgba(0, 0, 0, .55);
  --shadow-soft: 0 18px 50px rgba(2, 8, 23, .42);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --display: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 18% -10%, rgba(99, 230, 255, .19), transparent 33%),
    radial-gradient(circle at 82% 8%, rgba(167, 139, 250, .19), transparent 30%),
    radial-gradient(circle at 58% 88%, rgba(106, 166, 255, .13), transparent 34%),
    linear-gradient(135deg, var(--bg-0) 0%, var(--bg-1) 45%, #050916 100%);
}

body::selection { background: rgba(99, 230, 255, .28); color: #fff; }

/* Ambient animated canvas */
.bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  isolation: isolate;
}

.bg-grid {
  position: absolute;
  inset: 0;
  opacity: .46;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(circle at 50% 18%, black, transparent 76%);
  animation: gridDrift 18s linear infinite;
}

@keyframes gridDrift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(54px, 54px, 0); }
}

.bg-canvas::before {
  content: "";
  position: absolute;
  inset: -2px;
  background:
    linear-gradient(115deg, transparent 0 24%, rgba(99,230,255,.08) 25%, transparent 26% 58%, rgba(167,139,250,.07) 59%, transparent 60%),
    radial-gradient(circle at 50% 50%, transparent 0 42%, rgba(3,7,19,.82) 76%);
  opacity: .72;
}

.orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(68px);
  opacity: .78;
  transform: translateZ(0);
  animation: orbFloat 14s var(--ease) infinite alternate;
}
.orb-1 { width: 390px; height: 390px; left: -90px; top: 95px; background: rgba(99, 230, 255, .18); }
.orb-2 { width: 470px; height: 470px; right: -140px; top: 210px; background: rgba(167, 139, 250, .16); animation-delay: -5s; }
.orb-3 { width: 310px; height: 310px; left: 42%; bottom: -120px; background: rgba(106, 166, 255, .14); animation-delay: -9s; }

@keyframes orbFloat {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(34px, -42px, 0) scale(1.12); }
}

/* =============================== NAVBAR =============================== */
nav {
  position: sticky;
  top: 14px;
  z-index: 100;
  width: min(1160px, calc(100% - 32px));
  height: 74px;
  margin: 14px auto 0;
  padding: 0 16px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.13), rgba(255,255,255,.065));
  box-shadow: 0 18px 65px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.16);
  backdrop-filter: blur(26px) saturate(170%);
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  animation: navEnter .8s var(--spring) both;
}

nav::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(105deg, rgba(99,230,255,.65), transparent 28%, rgba(167,139,250,.42) 55%, transparent 74%, rgba(247,200,115,.4));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: .72;
  pointer-events: none;
}

nav::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 8%;
  width: 28%;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--violet), transparent);
  box-shadow: 0 0 26px rgba(99,230,255,.7);
  animation: navBeam 4.8s var(--ease) infinite;
  opacity: .85;
}

@keyframes navEnter {
  from { opacity: 0; transform: translateY(-26px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes navBeam {
  0%, 100% { transform: translateX(-14%); opacity: .3; }
  45%, 60% { transform: translateX(230%); opacity: 1; }
}

.nav-logo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  user-select: none;
}

.nav-logo-icon {
  position: relative;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 17px;
  color: #06101e;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -.08em;
  background: linear-gradient(135deg, var(--cyan), var(--blue) 52%, var(--violet));
  box-shadow: 0 16px 36px rgba(99, 230, 255, .22), inset 0 1px 0 rgba(255,255,255,.55);
  transition: transform .35s var(--spring), filter .35s var(--ease);
}

.nav-logo-icon::after {
  content: "";
  position: absolute;
  inset: -35%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.75), transparent);
  transform: translateX(-120%) rotate(18deg);
  animation: logoShine 4.2s ease-in-out infinite;
}

.nav-logo:hover .nav-logo-icon { transform: translateY(-2px) rotate(-3deg) scale(1.04); filter: saturate(1.12); }

@keyframes logoShine {
  0%, 35% { transform: translateX(-130%) rotate(18deg); }
  55%, 100% { transform: translateX(130%) rotate(18deg); }
}

.nav-logo-text {
  display: flex;
  align-items: baseline;
  gap: 0;
  min-width: 0;
  font-family: var(--display);
  font-size: clamp(1rem, 2vw, 1.18rem);
  font-weight: 850;
  letter-spacing: -.045em;
  color: #fff;
  text-shadow: 0 0 24px rgba(99,230,255,.16);
  white-space: nowrap;
}
.nav-logo-text span {
  background: linear-gradient(90deg, var(--cyan), #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nav-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid rgba(134, 239, 172, .26);
  border-radius: 999px;
  color: #dfffea;
  background: rgba(134, 239, 172, .08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .13em;
}
.nav-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 6px rgba(134,239,172,.08), 0 0 24px rgba(134,239,172,.75);
  animation: livePulse 2s ease-in-out infinite;
}
@keyframes livePulse {
  50% { transform: scale(.72); opacity: .62; box-shadow: 0 0 0 11px rgba(134,239,172,0), 0 0 18px rgba(134,239,172,.42); }
}

/* =============================== LAYOUT =============================== */
.wrapper {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 48px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* =============================== EDITOR CARD =============================== */
.editor-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.055));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.14);
  backdrop-filter: blur(26px) saturate(155%);
  -webkit-backdrop-filter: blur(26px) saturate(155%);
  animation: riseIn .82s var(--ease) .08s both;
  transition: border-color .28s var(--ease), box-shadow .28s var(--ease), transform .28s var(--ease);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(28px); filter: blur(10px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.editor-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 0%, rgba(99,230,255,.15), transparent 34%),
    radial-gradient(circle at 86% 12%, rgba(167,139,250,.13), transparent 30%),
    linear-gradient(120deg, transparent 0%, rgba(255,255,255,.055) 44%, transparent 56%);
  opacity: .9;
}

.editor-card:focus-within {
  border-color: rgba(99,230,255,.32);
  box-shadow: 0 36px 110px rgba(0,0,0,.62), 0 0 0 1px rgba(99,230,255,.14), 0 0 70px rgba(99,230,255,.08);
}

.editor-topbar,
.editor-body,
.status-bar { position: relative; z-index: 1; }

.editor-topbar {
  min-height: 78px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  background: rgba(2, 8, 23, .32);
}

.dots {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
  margin-right: auto;
}
.dots span {
  width: 12px;
  height: 12px;
  display: block;
  border-radius: 999px;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.45), 0 0 18px rgba(255,255,255,.08);
}
.dot-r { background: #ff6b7a; }
.dot-y { background: #ffd166; }
.dot-g { background: #55ef9a; }

.btn-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  position: relative;
  min-height: 42px;
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  color: #d9e6f7;
  background: linear-gradient(180deg, rgba(255,255,255,.115), rgba(255,255,255,.055));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.13), 0 10px 28px rgba(0,0,0,.18);
  font: 800 .78rem/1 var(--sans);
  letter-spacing: .01em;
  white-space: nowrap;
  transition: transform .24s var(--spring), border-color .24s var(--ease), background .24s var(--ease), box-shadow .24s var(--ease), color .24s var(--ease);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% -10%, rgba(255,255,255,.25), transparent 46%);
  opacity: 0;
  transition: opacity .24s var(--ease);
  pointer-events: none;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(99,230,255,.24); color: #fff; box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 16px 34px rgba(0,0,0,.24); }
.btn:hover::before { opacity: 1; }
.btn:active { transform: translateY(0) scale(.99); }
.btn:focus-visible { box-shadow: 0 0 0 4px rgba(99,230,255,.16), inset 0 1px 0 rgba(255,255,255,.18); }

.btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-clear:hover {
  color: #ffdce2;
  border-color: rgba(251, 113, 133, .34);
  background: linear-gradient(180deg, rgba(251,113,133,.16), rgba(255,255,255,.045));
}

.btn-run {
  color: #06101e;
  border-color: rgba(255,255,255,.26);
  background: linear-gradient(135deg, var(--cyan), var(--blue) 52%, var(--violet));
  box-shadow: 0 18px 40px rgba(99,230,255,.21), 0 10px 26px rgba(167,139,250,.15), inset 0 1px 0 rgba(255,255,255,.55);
}
.btn-run:hover {
  color: #030713;
  border-color: rgba(255,255,255,.45);
  box-shadow: 0 22px 55px rgba(99,230,255,.26), 0 15px 34px rgba(167,139,250,.19), inset 0 1px 0 rgba(255,255,255,.65);
}

#file-input { display: none; }

.editor-body {
  display: flex;
  height: min(62vh, 620px);
  min-height: 470px;
  background:
    linear-gradient(180deg, rgba(3, 7, 19, .26), rgba(3, 7, 19, .44)),
    radial-gradient(circle at 75% 12%, rgba(99,230,255,.06), transparent 24%);
}

.line-nums {
  width: 66px;
  flex: 0 0 auto;
  overflow: hidden;
  user-select: none;
  padding: 20px 13px 20px 8px;
  border-right: 1px solid rgba(255,255,255,.1);
  color: rgba(185, 200, 220, .42);
  background: rgba(0, 0, 0, .18);
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.72;
}
.line-nums span { display: block; min-height: 22.36px; }
.line-nums span:first-child { color: var(--cyan); }

#main-editor {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 20px 22px;
  border: 0;
  outline: none;
  resize: none;
  color: #e6f0ff;
  background: transparent;
  caret-color: var(--cyan);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.72;
  tab-size: 4;
  scrollbar-gutter: stable;
}
#main-editor::placeholder { color: rgba(185, 200, 220, .34); }

#main-editor::-webkit-scrollbar,
.line-nums::-webkit-scrollbar { width: 9px; height: 9px; }
#main-editor::-webkit-scrollbar-track,
.line-nums::-webkit-scrollbar-track { background: transparent; }
#main-editor::-webkit-scrollbar-thumb,
.line-nums::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  background-clip: padding-box;
}
#main-editor::-webkit-scrollbar-thumb:hover { background: rgba(99,230,255,.34); background-clip: padding-box; }

.status-bar {
  min-height: 44px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(255,255,255,.11);
  color: rgba(185, 200, 220, .78);
  background: rgba(2, 8, 23, .38);
  font-family: var(--mono);
  font-size: .72rem;
}
.status-left, .status-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.status-item { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--mint);
  box-shadow: 0 0 20px rgba(134,239,172,.8);
  animation: livePulse 2.1s ease-in-out infinite;
}

/* =============================== RESPONSIVE =============================== */
@media (max-width: 920px) {
  nav { height: 68px; top: 10px; width: min(100% - 24px, 1120px); }
  .wrapper { padding-top: 32px; }
  .editor-topbar { align-items: flex-start; flex-direction: column; }
  .dots { margin-right: 0; }
  .btn-group { width: 100%; justify-content: flex-start; }
  .editor-body { height: 58vh; min-height: 430px; }
}

@media (max-width: 640px) {
  body { background-attachment: fixed; }
  nav { padding: 0 12px; height: 62px; }
  .nav-logo { gap: 9px; }
  .nav-logo-icon { width: 40px; height: 40px; border-radius: 14px; font-size: 12px; }
  .nav-logo-text { font-size: .98rem; }
  .nav-badge { padding: 8px 10px; font-size: .63rem; letter-spacing: .08em; }
  .wrapper { padding: 24px 14px 44px; gap: 22px; }
  .editor-card { border-radius: 24px; }
  .editor-topbar { padding: 13px; min-height: auto; }
  .btn-group { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .btn { width: 100%; min-height: 43px; padding: 10px 12px; font-size: .74rem; }
  .editor-body { min-height: 410px; height: 56vh; }
  .line-nums { width: 46px; padding: 16px 8px 16px 4px; font-size: 11.5px; }
  #main-editor { padding: 16px 14px; font-size: 12.5px; }
  .status-bar { align-items: flex-start; flex-direction: column; gap: 7px; padding: 10px 14px; }
  .status-left, .status-right { width: 100%; justify-content: space-between; gap: 8px; font-size: .66rem; }
}

@media (max-width: 420px) {
  .nav-badge { display: none; }
  .dots { display: none; }
  .btn svg { width: 14px; height: 14px; }
  .btn-group { grid-template-columns: 1fr 1fr; }
  .status-right span:nth-child(3) { display: none; }
}

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