/* MathScribble — type anything, watch math dance */

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background:
    radial-gradient(1200px 800px at 85% -10%, #2a1456 0%, transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, #062a3a 0%, transparent 55%),
    #05030d;
  color: #f1edff;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection {
  background: #ff7de0;
  color: #140024;
}

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(6px);
  z-index: 2;
}

.brand {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, #8a7dff, #ff7de0, #64e5ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0;
  font-size: 0.85rem;
  color: #b9b3d6;
}

.tagline b {
  color: #f1edff;
}

/* ---------- layout ---------- */

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
}

#canvas {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.panel {
  flex: 0 0 360px;
  max-width: 90vw;
  height: 100%;
  overflow-y: auto;
  padding: 18px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(18, 14, 36, 0.65);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
}

.panel::-webkit-scrollbar {
  width: 8px;
}

.panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
}

/* ---------- form field ---------- */

.field-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9d96c4;
}

textarea#mathInput {
  width: 100%;
  resize: vertical;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(5, 3, 13, 0.6);
  color: #f1edff;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea#mathInput:focus {
  outline: none;
  border-color: #8a7dff;
  box-shadow: 0 0 0 3px rgba(138, 125, 255, 0.25);
}

/* ---------- chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: #d9d4f5;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: rgba(138, 125, 255, 0.18);
  border-color: #8a7dff;
  color: #fff;
  transform: translateY(-1px);
}

/* ---------- buttons ---------- */

.btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #f1edff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  width: 100%;
  background: linear-gradient(90deg, #8a7dff, #ff7de0);
  border: none;
  color: #140024;
  padding: 12px 14px;
  font-size: 0.95rem;
  box-shadow: 0 6px 20px rgba(138, 125, 255, 0.35);
}

.btn.primary:hover {
  box-shadow: 0 8px 26px rgba(255, 125, 224, 0.45);
}

.status {
  margin: 0;
  font-size: 0.8rem;
  color: #b9b3d6;
  min-height: 1.2em;
}

/* ---------- controls ---------- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.ctrl label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #cfc9ec;
  margin-bottom: 4px;
}

.ctrl span {
  color: #ff9fe8;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8a7dff, #ff7de0);
  border: 2px solid #140024;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(138, 125, 255, 0.6);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8a7dff, #ff7de0);
  border: 2px solid #140024;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(138, 125, 255, 0.6);
}

.checkbox-row {
  display: flex;
  align-items: center;
}

.checkbox-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  accent-color: #ff7de0;
  width: 15px;
  height: 15px;
}

/* ---------- actions ---------- */

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.actions .btn {
  padding: 10px 6px;
  font-size: 0.78rem;
}

.hint {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.5;
  color: #8e87b3;
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .layout {
    flex-direction: column;
  }

  #canvas {
    height: 52vh;
  }

  .panel {
    flex: 1;
    width: 100%;
    max-width: 100%;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
}
