:root {
  color-scheme: dark;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 10% -20%, rgba(37, 99, 235, 0.24), transparent 55%),
    radial-gradient(circle at 90% 0%, rgba(14, 165, 233, 0.18), transparent 45%),
    linear-gradient(180deg, #04070f 0%, #0b1120 60%, #05070d 100%);
  color: #e2e8f0;
}

.page-header {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
  background: rgba(4, 7, 15, 0.82);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.15rem clamp(1.5rem, 4vw, 3rem);
}

.header-inner h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-inner nav {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.header-inner nav a {
  color: rgba(191, 219, 254, 0.78);
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.header-inner nav a:hover {
  color: #ffffff;
  opacity: 1;
}

.header-inner nav a[aria-current='page'] {
  color: #ffffff;
  font-weight: 600;
}

.page-main {
  flex: 1 1 auto;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(1.5rem, 3vw, 3rem) clamp(1.2rem, 4vw, 3rem) 3rem;
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
}

.status-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-banner {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(56, 189, 248, 0.08));
  border: 1px solid rgba(96, 165, 250, 0.35);
  color: #dbeafe;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.status-banner.error {
  border-color: rgba(248, 113, 113, 0.45);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(127, 29, 29, 0.12));
  color: #fecaca;
}

.unsaved-note {
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.assistant-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 2.2rem;
  align-items: start;
}

.settings-layout {
  display: contents;
}

.settings-sidebar,
.settings-main {
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
}

@media (max-width: 960px) {
  .assistant-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-sidebar,
  .settings-main {
    gap: 1.6rem;
  }
}

.settings-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  padding: clamp(1.5rem, 2.5vw, 2.2rem);
  box-shadow: 0 24px 48px rgba(3, 7, 18, 0.55);
}

.section-summary {
  margin: 0 0 1.4rem;
  color: rgba(226, 232, 240, 0.78);
  line-height: 1.55;
}

.assistant-form {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.95rem;
  color: rgba(226, 232, 240, 0.86);
}

.field span {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: rgba(191, 219, 254, 0.88);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.85);
  color: #e2e8f0;
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.color-field {
  align-items: flex-start;
}

.color-field input[type='color'] {
  width: 3.5rem;
  height: 2.5rem;
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.85);
  cursor: pointer;
}

.color-field input[type='color']::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

.color-field input[type='color']::-moz-color-swatch {
  border: none;
  border-radius: 8px;
}

.lighting-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  border-radius: 18px;
  overflow: hidden;
  margin: 1.2rem 0 1.6rem;
  background: radial-gradient(circle at 30% 20%, rgba(59, 130, 246, 0.28), transparent 60%),
    radial-gradient(circle at 75% 35%, rgba(14, 165, 233, 0.22), transparent 55%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.8) 0%, rgba(4, 6, 14, 0.9) 100%);
  box-shadow: inset 0 0 35px rgba(2, 6, 23, 0.75);
}

.lighting-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.lighting-preview-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.2rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.92);
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.78), rgba(2, 6, 23, 0.88));
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.lighting-preview-status[hidden] {
  opacity: 0;
  pointer-events: none;
}

.lighting-preview-status.error {
  color: #fecaca;
  background: linear-gradient(180deg, rgba(67, 10, 10, 0.8), rgba(15, 6, 6, 0.88));
}

.field textarea {
  min-height: 6.5rem;
  line-height: 1.5;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.field small {
  color: rgba(148, 163, 184, 0.8);
  font-size: 0.75rem;
}

.slider-field input[type='range'] {
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  outline: none;
  position: relative;
}

.slider-field input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(56, 189, 248, 0.9));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
  cursor: pointer;
}

.slider-field input[type='range']::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(56, 189, 248, 0.9));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
  cursor: pointer;
}

.viseme-editor-note {
  margin: 1.2rem 0 0.7rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: rgba(148, 163, 184, 0.82);
}

.viseme-editor {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.viseme-recipe {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  padding: 1rem 1.1rem 1.15rem;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.viseme-recipe-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.viseme-recipe-header h3 {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(191, 219, 254, 0.88);
}

.viseme-recipe-count {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.75);
}

.viseme-shape-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.viseme-shape-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.viseme-shape-name {
  flex: 1 1 160px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.88);
  color: #e2e8f0;
  padding: 0.55rem 0.7rem;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.viseme-shape-name:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.viseme-shape-slider {
  appearance: none;
  flex: 2 1 220px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  outline: none;
  position: relative;
}

.viseme-shape-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(56, 189, 248, 0.9));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
  cursor: pointer;
}

.viseme-shape-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(56, 189, 248, 0.9));
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.45);
  cursor: pointer;
}

.viseme-shape-value {
  flex: 0 0 auto;
  min-width: 58px;
  text-align: right;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(191, 219, 254, 0.88);
}

.viseme-shape-remove {
  flex: 0 0 auto;
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(248, 113, 113, 0.18);
  color: rgba(254, 226, 226, 0.92);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.viseme-shape-remove:hover {
  background: rgba(248, 113, 113, 0.28);
  color: #fee2e2;
  transform: translateY(-1px);
}

.viseme-add-button {
  align-self: flex-start;
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.18);
  color: rgba(191, 219, 254, 0.95);
  padding: 0.45rem 0.95rem;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.viseme-add-button:hover {
  background: rgba(59, 130, 246, 0.32);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}

.viseme-empty {
  margin: 0;
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.78);
  padding: 0.25rem 0;
}

@media (max-width: 720px) {
  .viseme-recipe {
    padding: 0.9rem 0.95rem 1.05rem;
  }

  .viseme-shape-row {
    flex-direction: column;
    align-items: stretch;
  }

  .viseme-shape-value,
  .viseme-shape-remove {
    align-self: flex-end;
  }

  .viseme-shape-value {
    margin-top: 0.1rem;
  }

  .viseme-add-button {
    width: 100%;
    text-align: center;
  }
}

.slider-field input[type='range']::-moz-range-track {
  background: transparent;
}

.field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.range-value {
  font-size: 0.85rem;
  color: rgba(191, 219, 254, 0.9);
  font-variant-numeric: tabular-nums;
}

.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.55);
  transition: border 0.2s ease, background 0.2s ease;
}

.toggle-field:hover {
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(15, 23, 42, 0.7);
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toggle-text span {
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  color: rgba(191, 219, 254, 0.92);
}

.toggle-text small {
  color: rgba(148, 163, 184, 0.78);
  font-size: 0.78rem;
}

.toggle-field input[type='checkbox'] {
  width: 2.6rem;
  height: 1.4rem;
  border-radius: 999px;
  appearance: none;
  position: relative;
  background: rgba(148, 163, 184, 0.35);
  transition: background 0.2s ease;
  cursor: pointer;
}

.toggle-field input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 0.15rem;
  left: 0.18rem;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: #0f172a;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.35);
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle-field input[type='checkbox']:checked {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(56, 189, 248, 0.85));
}

.toggle-field input[type='checkbox']:checked::after {
  transform: translateX(1.1rem);
  background: #0b1120;
}

.card-section {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.card-section + .card-section {
  margin-top: 1.8rem;
}

.section-summary.small {
  font-size: 0.85rem;
  color: rgba(203, 213, 225, 0.78);
  margin-bottom: 1rem;
}

.form-actions {
  margin-top: 1.6rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

button.primary,
button.secondary {
  border-radius: 999px;
  border: none;
  padding: 0.6rem 1.6rem;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
}

button.primary {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(56, 189, 248, 0.9));
  color: #0b1120;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.35);
}

button.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

button.primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.4);
}

button.secondary {
  background: rgba(15, 23, 42, 0.85);
  color: rgba(226, 232, 240, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

button.secondary:hover {
  opacity: 0.9;
}

.page-footer {
  padding: 1.8rem clamp(1.2rem, 4vw, 3rem);
  text-align: center;
  color: rgba(148, 163, 184, 0.8);
  font-size: 0.9rem;
}
