:root {
  color-scheme: dark;
  --bg: #08111b;
  --bg-soft: rgba(8, 17, 27, 0.72);
  --panel: rgba(14, 28, 42, 0.84);
  --panel-strong: rgba(19, 34, 49, 0.96);
  --stroke: rgba(149, 177, 203, 0.18);
  --stroke-strong: rgba(149, 177, 203, 0.34);
  --text: #f3f5f7;
  --muted: #a4b2c0;
  --accent: #ffd166;
  --accent-strong: #ff8a3d;
  --accent-soft: rgba(255, 209, 102, 0.12);
  --success: #76e3b2;
  --danger: #ff8a8a;
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.42);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 138, 61, 0.18), transparent 34%),
    radial-gradient(circle at top right, rgba(118, 227, 178, 0.16), transparent 28%),
    linear-gradient(180deg, #0b1220 0%, #08111b 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent 95%);
  opacity: 0.18;
}

.shell {
  position: relative;
  min-height: 100vh;
  padding: 32px;
}

.hero,
.workspace {
  width: min(1180px, calc(100vw - 64px));
  margin: 0 auto;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  padding: 28px 8px 22px;
  align-items: end;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0;
  font-size: clamp(2.7rem, 4vw, 5rem);
  line-height: 0.96;
}

.hero-text {
  margin: 18px 0 0;
  max-width: 700px;
  font-size: 1.06rem;
  line-height: 1.7;
  color: var(--muted);
}

.hero-status {
  max-width: 320px;
  padding: 18px 20px;
  border: 1px solid var(--stroke);
  border-radius: 24px;
  background: rgba(10, 20, 31, 0.7);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 16px rgba(118, 227, 178, 0.8);
}

#statusMessage {
  margin: 14px 0 0;
  line-height: 1.6;
  color: var(--muted);
}

.workspace {
  padding-bottom: 60px;
}

.composer-panel {
  position: relative;
  overflow: hidden;
  padding: 28px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(22, 39, 58, 0.96), rgba(10, 20, 31, 0.92)),
    var(--panel);
  box-shadow: var(--shadow);
}

.composer-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 90% 0%, rgba(255, 209, 102, 0.14), transparent 22%),
    radial-gradient(circle at 0% 100%, rgba(118, 227, 178, 0.12), transparent 20%);
  pointer-events: none;
}

.panel-header,
.editor-grid,
.meta-row {
  position: relative;
  z-index: 1;
}

.panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 320px);
  gap: 18px;
  align-items: end;
}

.field {
  display: grid;
  gap: 10px;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-caption {
  font-size: 0.9rem;
  color: var(--muted);
}

.title-input,
.language-select {
  width: 100%;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 16px 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  outline: none;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.language-select {
  color-scheme: dark;
}

.language-select option,
.language-select optgroup {
  color: #0f172a;
  background: #f8fafc;
}

.title-input:focus,
.language-select:focus,
textarea:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
}

.language-bar {
  display: grid;
  gap: 10px;
}

.language-bar-copy {
  display: grid;
  gap: 6px;
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 22px;
}

.editor-card {
  min-height: 560px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--stroke);
  border-radius: 24px;
  background: var(--panel-strong);
}

.panel-chip {
  display: inline-flex;
  width: fit-content;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e6eef7;
  background: rgba(255, 255, 255, 0.04);
}

textarea,
pre,
code {
  font-family: "JetBrains Mono", monospace;
}

.editor-card.viewer-focus {
  min-height: 680px;
}

.preview-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.detected-language {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
}

.editor-surface {
  position: relative;
  min-height: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(6, 13, 20, 0.66);
  overflow: hidden;
}

.editor-output,
.editor-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 18px 18px 30px;
  font-size: 0.95rem;
  line-height: 1.7;
  tab-size: 2;
  font-weight: 400;
  letter-spacing: 0;
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0;
}

.editor-output {
  overflow: auto;
  pointer-events: none;
  scrollbar-width: none;
}

.editor-output::-webkit-scrollbar {
  display: none;
}

.editor-output code {
  display: block;
  min-width: max-content;
  min-height: 100%;
  white-space: pre;
}

.editor-output .hljs {
  min-width: max-content;
  min-height: 100%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  line-height: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  font-kerning: inherit;
  font-variant-ligatures: inherit;
  font-feature-settings: inherit;
}

.editor-input {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  white-space: pre;
  overflow: auto;
  outline: none;
}

.editor-input:focus {
  background: transparent;
}

.editor-input::placeholder {
  color: transparent;
}

.editor-input::selection {
  background: rgba(255, 209, 102, 0.26);
}

.editor-empty {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  max-width: 540px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(164, 178, 192, 0.9);
  line-height: 1.6;
  pointer-events: none;
}

.editor-surface.readonly .editor-output {
  pointer-events: auto;
  scrollbar-width: thin;
}

.editor-surface.readonly .editor-output::-webkit-scrollbar {
  display: block;
  width: 10px;
  height: 10px;
}

.editor-surface.readonly .editor-output::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(149, 177, 203, 0.3);
}

.editor-surface.readonly .editor-input,
.editor-surface.readonly .editor-empty {
  display: none;
}

.meta-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.meta-block {
  padding: 16px 18px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.meta-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.corner-actions {
  position: fixed;
  z-index: 20;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  max-width: min(420px, calc(100vw - 32px));
}

.corner-actions.top-left {
  top: 16px;
  left: 16px;
  justify-content: flex-start;
}

.corner-actions.top-right {
  top: 16px;
  right: 16px;
  justify-content: flex-end;
}

.corner-actions.bottom-left {
  bottom: 16px;
  left: 16px;
  justify-content: flex-start;
}

.corner-actions.bottom-right {
  right: 16px;
  bottom: 16px;
  justify-content: flex-end;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  color: var(--text);
  background: rgba(9, 18, 29, 0.88);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.action-button:hover {
  transform: translateY(-2px);
  border-color: var(--stroke-strong);
}

.action-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.action-button.primary {
  color: #11151a;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: transparent;
}

.action-button.ghost {
  background: rgba(9, 18, 29, 0.74);
}

.action-button.success {
  color: #08111b;
  background: linear-gradient(135deg, #76e3b2, #4bd39a);
  border-color: transparent;
}

.action-button.danger {
  color: #fff5f5;
  background: rgba(255, 118, 118, 0.18);
  border-color: rgba(255, 138, 138, 0.45);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translate(-50%, 18px);
  min-width: 200px;
  max-width: min(90vw, 520px);
  padding: 14px 18px;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  color: var(--text);
  background: rgba(9, 18, 29, 0.94);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hidden {
  display: none !important;
}

@media (max-width: 1024px) {
  .shell {
    padding: 94px 18px 110px;
  }

  .hero,
  .workspace {
    width: min(1180px, calc(100vw - 36px));
  }

  .hero {
    flex-direction: column;
    align-items: start;
  }

  .panel-header,
  .meta-row {
    grid-template-columns: 1fr;
  }

  .editor-card {
    min-height: 380px;
  }

  .corner-actions {
    max-width: calc(100vw - 20px);
  }

  .corner-actions.top-left,
  .corner-actions.top-right,
  .corner-actions.bottom-left,
  .corner-actions.bottom-right {
    left: 10px;
    right: 10px;
  }

  .corner-actions.top-left,
  .corner-actions.bottom-left {
    justify-content: flex-start;
  }

  .corner-actions.top-right,
  .corner-actions.bottom-right {
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 104px 12px 116px;
  }

  h1 {
    font-size: clamp(2.2rem, 14vw, 3.3rem);
  }

  .composer-panel {
    padding: 18px;
  }

  .editor-card {
    padding: 14px;
    min-height: 300px;
  }

  .editor-output,
  .editor-input {
    padding: 14px;
    font-size: 0.9rem;
  }

  .editor-empty {
    top: 14px;
    left: 14px;
    right: 14px;
  }

  .action-button {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 0.92rem;
  }
}
