:root {
  --bg0: #07070b;
  --bg1: #0c0c14;
  --ink: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --faint: rgba(255, 255, 255, 0.42);
  --line: rgba(255, 255, 255, 0.10);
  --line2: rgba(255, 255, 255, 0.14);

  --glass: rgba(255, 255, 255, 0.06);
  --glass2: rgba(255, 255, 255, 0.09);

  --accent: #b7ff57;
  --accent2: #65d8ff;
  --danger: #ff4f78;

  --tts-highlight: rgba(183, 255, 87, 0.30);
  --tts-highlight-ink: rgba(6, 8, 10, 0.92);

  --shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 12px;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(1200px 900px at 15% 10%, #17172e 0%, transparent 55%),
    radial-gradient(900px 700px at 90% 18%, #0d2a3a 0%, transparent 60%),
    radial-gradient(1200px 900px at 40% 110%, #23112a 0%, transparent 62%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  font-family:
    "Manrope",
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  letter-spacing: -0.01em;
  overflow-x: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.bg__mesh {
  position: absolute;
  inset: -20%;
  filter: blur(32px);
  opacity: 0.85;
  background: radial-gradient(closest-side at 20% 25%, rgba(183, 255, 87, 0.16), transparent 65%),
    radial-gradient(closest-side at 78% 22%, rgba(101, 216, 255, 0.13), transparent 70%),
    radial-gradient(closest-side at 55% 78%, rgba(255, 79, 120, 0.12), transparent 75%);
  animation: floatMesh 14s ease-in-out infinite alternate;
}

.bg__noise {
  position: absolute;
  inset: 0;
  opacity: 0.10;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

@keyframes floatMesh {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(-2%, 1.5%, 0) scale(1.02);
  }
}

.app {
  width: min(1180px, calc(100vw - 40px));
  margin: 28px auto 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, var(--accent), rgba(183, 255, 87, 0) 60%),
    radial-gradient(circle at 70% 70%, var(--accent2), rgba(101, 216, 255, 0) 65%),
    radial-gradient(circle at 60% 30%, rgba(255, 79, 120, 0.9), rgba(255, 79, 120, 0) 60%);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.03);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.brand__title {
  font-family:
    "DM Serif Display",
    ui-serif,
    Georgia,
    "Times New Roman",
    serif;
  font-size: 26px;
  letter-spacing: 0.01em;
}

.brand__subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--glass2), rgba(255, 255, 255, 0.04));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.pill__label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill__value {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  grid-template-columns: 1.35fr 0.65fr;
  gap: 16px;
  align-items: stretch;
}

.panel--controls {
  display: flex;
  flex-direction: column;
}

.panel--controls .controls {
  flex: 1;
}

.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--glass2), rgba(255, 255, 255, 0.03));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel__header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025));
}

.panel__title {
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
}

.panel__hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
}

.editorShell {
  padding: 14px;
}

/* Quill overrides */
#editor {
  height: 460px;
}

.ql-toolbar.ql-snow {
  border: 1px solid var(--line);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: rgba(0, 0, 0, 0.16);
}

.ql-container.ql-snow {
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: rgba(0, 0, 0, 0.20);
}

.ql-snow .ql-stroke {
  stroke: rgba(255, 255, 255, 0.78);
}

.ql-snow .ql-fill {
  fill: rgba(255, 255, 255, 0.78);
}

.ql-snow .ql-picker {
  color: rgba(255, 255, 255, 0.86);
}

.ql-snow .ql-picker-options {
  background: rgba(16, 16, 28, 0.98);
  border: 1px solid var(--line2);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.ql-snow .ql-tooltip {
  background: rgba(16, 16, 28, 0.98);
  border: 1px solid var(--line2);
  color: var(--ink);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

.ql-editor {
  color: rgba(255, 255, 255, 0.92);
  font-family:
    "Manrope",
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: -0.01em;
  font-weight: 470;
}

.ql-editor.ql-blank::before {
  color: rgba(255, 255, 255, 0.45);
  font-style: normal;
}

.ql-editor p {
  margin: 0 0 0.75em;
}

.ql-editor p:last-child {
  margin-bottom: 0;
}

/* Selection inside the editor */
.ql-container.ql-snow ::selection {
  background: rgba(101, 216, 255, 0.24);
  color: var(--ink);
}

/* Make Quill highlights look intentional */
.ql-editor span[style*="background-color"] {
  border-radius: 6px;
  padding: 0 0.12em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.ql-editor strong {
  font-weight: 800;
}

.ql-editor em {
  font-style: italic;
}

/* Subtle scrollbar styling (where supported) */
.ql-container.ql-snow {
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.05);
}

.ql-editor::-webkit-scrollbar {
  width: 12px;
}

.ql-editor::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border: 3px solid rgba(0, 0, 0, 0);
  background-clip: padding-box;
  border-radius: 999px;
}

.ql-editor::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
  border: 3px solid rgba(0, 0, 0, 0);
  background-clip: padding-box;
}

.controls {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border-radius: 14px;
  padding: 11px 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    opacity 140ms ease;
  user-select: none;
}

.btn:hover:enabled {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
}

.btn:active:enabled {
  transform: translateY(0);
}

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

.btn--primary {
  border-color: rgba(183, 255, 87, 0.35);
  background: linear-gradient(180deg, rgba(183, 255, 87, 0.22), rgba(183, 255, 87, 0.06));
}

.btn--soft {
  border-color: rgba(101, 216, 255, 0.28);
  background: linear-gradient(180deg, rgba(101, 216, 255, 0.14), rgba(101, 216, 255, 0.05));
}

.btn--danger {
  border-color: rgba(255, 79, 120, 0.35);
  background: linear-gradient(180deg, rgba(255, 79, 120, 0.18), rgba(255, 79, 120, 0.05));
}

.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.14);
  padding: 14px;
}

.card__title {
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.80);
  margin-bottom: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.field:first-child {
  margin-top: 0;
}

.field__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field__label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.field__value {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
}

.unit {
  margin-left: 2px;
  color: var(--faint);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.field__ticks {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--faint);
}

.selectWrap {
  position: relative;
  width: 100%;
}

.selectWrap select {
  width: 100%;
  border-radius: 14px;
  padding: 11px 44px 11px 12px;
  border: 1px solid var(--line2);
  background: rgba(0, 0, 0, 0.18);
  color: var(--ink);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.selectWrap select:hover:enabled {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.24);
}

.selectWrap select:focus-visible {
  border-color: rgba(101, 216, 255, 0.55);
  box-shadow:
    0 0 0 4px rgba(101, 216, 255, 0.15),
    0 18px 60px rgba(0, 0, 0, 0.45);
}

.selectWrap select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.selectWrap__chev {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.9;
  background: radial-gradient(circle at 30% 30%, rgba(183, 255, 87, 0.35), rgba(183, 255, 87, 0) 55%),
    radial-gradient(circle at 70% 70%, rgba(101, 216, 255, 0.28), rgba(101, 216, 255, 0) 60%);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='black' d='M5.3 7.7a1 1 0 0 1 1.4 0L10 11l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath fill='black' d='M5.3 7.7a1 1 0 0 1 1.4 0L10 11l3.3-3.3a1 1 0 1 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4Z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 18px 18px;
  mask-size: 18px 18px;
}

/* Where supported, make the opened dropdown match the theme */
.selectWrap select option {
  background: rgba(16, 16, 28, 0.98);
  color: var(--ink);
}

.field__help {
  font-size: 12px;
  color: var(--faint);
  line-height: 1.35;
}

.srOnly {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
}

/* Highlighting color */
::selection {
  background-color: rgba(101, 216, 255, 0.24);
  color: var(--ink);
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }
  #editor {
    height: 380px;
  }
  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 520px) {
  .app {
    width: calc(100vw - 28px);
    margin: 18px auto 32px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .actions {
    grid-template-columns: 1fr;
  }
}
