:root {
  --bg: #f5efff;
  --panel: #ffffff;
  --outline: #2d1b54;
  --accent: #7a5cff;
  --accent-2: #fcbf49;
  --text: #2d1b54;
  --subtle: #6e6590;
  --shadow: 0 16px 40px rgba(45, 27, 84, 0.12);
}

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

body {
  margin: 0;
  font-family: 'Nunito', 'Baloo 2', 'Trebuchet MS', system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #fdf7ff 0%, #f1e8ff 40%, #ebdff9 75%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.page-shell {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.hero-header {
  text-align: center;
  padding: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.hero-header h1 {
  margin: 0;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-size: clamp(20px, 3vw, 32px);
  letter-spacing: 0.2px;
}

.hero-header .tagline {
  margin: 0;
  font-size: 14px;
  color: var(--subtle);
}

.layout {
  background: transparent;
  box-shadow: none;
  display: flex;
  flex-direction: row;
  flex-grow: 1;
  overflow: hidden;
  padding: 0;
  gap: 0;
}

.hero-panel {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.svg-wrap {
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
  background: transparent;
  border-radius: 0;
  padding: 0;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

#head-svg {
  width: 100%;
  height: 100%;
  max-height: 90vh;
  display: block;
}

.control-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-left: 1px solid rgba(45, 27, 84, 0.1);
  z-index: 20;
  overflow-y: auto;
}

.note {
  color: var(--subtle);
  font-size: 14px;
  letter-spacing: 0.1px;
}

.input-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-weight: 700;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
}

#brain-input {
  width: 100%;
  border: 3px solid #2d1b54;
  border-radius: 16px;
  padding: 14px 12px;
  font-size: 16px;
  line-height: 1.4;
  resize: vertical;
  min-height: 120px;
  background: #fffdf8;
  font-family: 'Nunito', 'Baloo 2', sans-serif;
  color: var(--text);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

#brain-input:focus {
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(45, 27, 84, 0.12);
}

.input-hint {
  position: absolute;
  right: 10px;
  top: -18px;
  background: #2d1b54;
  color: #fdf7ff;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  opacity: 0.9;
}

.meter-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
}

.meter {
  width: 100%;
  height: 14px;
  background: #efe8ff;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid #2d1b54;
}

#gauge-fill {
  width: 12%;
  height: 100%;
  background: linear-gradient(90deg, #7a5cff, #fcbf49);
  transition: width 220ms ease, filter 220ms ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

#wiggle-toggle {
  border: 2px solid #2d1b54;
  background: var(--accent);
  color: #fefefe;
  border-radius: 12px;
  padding: 6px 12px;
  font-weight: 700;
  font-family: 'Baloo 2', sans-serif;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

#wiggle-toggle:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 10px 24px rgba(122, 92, 255, 0.24);
}

#wiggle-toggle:active {
  transform: translateY(1px) scale(0.99);
}

@media (max-width: 880px) {
  .layout {
    flex-direction: column;
  }

  .control-panel {
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid rgba(45, 27, 84, 0.1);
    padding: 16px;
  }

  .hero-panel {
    padding: 10px;
  }

  .input-hint {
    position: relative;
    right: auto;
    top: auto;
    align-self: flex-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
