/* ══════════════════════════════════════════════════════════════
   TONALLIX · paleta de comandos, ajustes, avisos y adaptación
   ══════════════════════════════════════════════════════════════ */

/* ── Paleta de comandos ────────────────────────────────────── */

.palette-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 2, 0.62);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  animation: fadeIn 0.2s ease both;
}

.palette-card {
  position: relative;
  width: min(600px, calc(100vw - 28px));
  margin-top: 13vh;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: rgba(18, 15, 11, 0.98);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  animation: paletteIn 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.palette-search {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--faint);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.palette-input-row input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: var(--text);
  font: 400 13px var(--font-ui);
}

.palette-input-row input::placeholder {
  color: var(--faint);
}

.palette-list {
  max-height: min(432px, calc(100dvh - 220px));
  padding: 6px;
  overflow-y: auto;
}

.palette-group-label {
  padding: 8px 10px 5px;
  color: var(--faint);
  font: 500 7.5px var(--font-mono);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.palette-group-label:first-child {
  padding-top: 3px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-soft);
  text-align: left;
  cursor: pointer;
}

.palette-item.active {
  background: rgba(var(--accent-rgb), 0.09);
  color: var(--text);
}

.palette-item-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
}

.palette-item.active .palette-item-icon {
  border-color: rgba(var(--accent-rgb), 0.2);
  color: var(--accent);
}

.palette-item-icon svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.palette-item-copy {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.palette-item-copy strong {
  overflow: hidden;
  color: inherit;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.palette-item-copy small {
  overflow: hidden;
  color: var(--faint);
  font-size: 9px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.palette-item-hint {
  flex: none;
  color: var(--faint);
  font: 400 8px var(--font-mono);
}

.palette-empty {
  padding: 26px 14px;
  color: var(--faint);
  font-size: 10.5px;
  text-align: center;
}

.palette-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font: 400 8.5px var(--font-mono);
}

.palette-foot > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.palette-brand {
  margin-left: auto;
  color: var(--muted);
}

.palette-brand svg {
  width: 10px;
  height: 10px;
  color: var(--accent);
  fill: currentColor;
  stroke: none;
}

/* ── Ajustes ───────────────────────────────────────────────── */

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 2, 0.68);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease both;
}

.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(620px, 100%);
  max-height: min(86dvh, 780px);
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 18px;
  outline: none;
  background: linear-gradient(180deg, rgba(23, 19, 15, 0.99), rgba(13, 11, 9, 0.99));
  box-shadow: 0 50px 120px rgba(0, 0, 0, 0.7);
  animation: modalIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 21px 23px 17px;
  border-bottom: 1px solid var(--line);
}

.modal-kicker {
  color: var(--accent);
  font: 500 8px var(--font-mono);
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.modal-head h3 {
  margin: 6px 0 4px;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.032em;
}

.modal-head p {
  margin: 0;
  color: var(--muted);
  font-size: 10.5px;
}

.modal-body {
  padding: 6px 23px 18px;
  overflow-y: auto;
}

.setting-section {
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.setting-section:last-child {
  border-bottom: 0;
}

.setting-section h4 {
  margin: 0 0 11px;
  color: var(--faint);
  font: 500 8px var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.setting-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.setting-copy strong {
  color: var(--text);
  font-size: 11.5px;
  font-weight: 500;
}

.setting-copy small {
  max-width: 370px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.55;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.swatch {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-soft);
  font: 400 10px var(--font-ui);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}

.swatch:hover {
  border-color: var(--line-2);
}

.swatch.active {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(var(--accent-rgb), 0.06);
  color: var(--text);
}

.swatch-dot {
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.swatch-oro {
  background: radial-gradient(circle at 35% 30%, #fff3d0, #f7b955 45%, #ff7d3f);
}

.swatch-jade {
  background: radial-gradient(circle at 35% 30%, #d9fff4, #5fe3c0 45%, #14b8a6);
}

.swatch-plasma {
  background: radial-gradient(circle at 35% 30%, #f2e8ff, #b69cff 45%, #f472b6);
}

.swatch-check {
  width: 12px;
  height: 12px;
  flex: none;
  margin-left: auto;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.swatch.active .swatch-check {
  opacity: 1;
}

.setting-switch {
  width: 38px;
  height: 22px;
}

.setting-switch span {
  width: 16px;
  height: 16px;
}

.setting-switch[aria-checked="true"] span {
  transform: translateX(15px);
}

.api-fields {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 13px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > span {
  color: var(--faint);
  font: 500 7.5px var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field input {
  height: 33px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-soft);
  font: 400 10.5px var(--font-mono);
  transition: border-color 0.18s, background 0.18s;
}

.field input:focus {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: rgba(255, 255, 255, 0.04);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.setting-hint {
  display: flex;
  gap: 6px;
  margin: 0;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.5;
}

.setting-hint svg {
  width: 12px;
  height: 12px;
  flex: none;
  margin-top: 1px;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.danger-btn {
  height: 30px;
  flex: none;
  padding: 0 10px;
  border: 1px solid rgba(255, 107, 107, 0.22);
  border-radius: 7px;
  background: rgba(255, 107, 107, 0.05);
  color: #ff9a9a;
  font: 400 9.5px var(--font-ui);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}

.danger-btn:hover {
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.1);
}

.danger-btn.armed {
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.14);
  color: #ffc0c0;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 23px;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.12);
}

.modal-signature {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font: 400 8.5px var(--font-mono);
  letter-spacing: 0.04em;
}

.modal-signature svg {
  width: 11px;
  height: 11px;
  color: var(--accent);
  fill: currentColor;
  stroke: none;
}

.btn-primary {
  height: 34px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.2);
  color: #1c1306;
  font: 500 10.5px var(--font-ui);
  cursor: pointer;
  transition: filter 0.18s, transform 0.18s;
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

/* ── Toast ─────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 128px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 9px 13px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgba(26, 22, 17, 0.97);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  color: var(--text-soft);
  font: 400 10.5px var(--font-ui);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.toast-icon {
  width: 13px;
  height: 13px;
  flex: none;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast-action {
  margin-left: 2px;
  padding: 0 0 0 8px;
  border: 0;
  border-left: 1px solid var(--line-2);
  background: none;
  color: var(--accent);
  font: 500 9.5px var(--font-ui);
  cursor: pointer;
}

/* ── Animaciones ───────────────────────────────────────────── */

@keyframes sceneTurn {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulseRing {
  0% {
    opacity: 0.8;
    transform: scale(0.6);
  }
  75%,
  100% {
    opacity: 0;
    transform: scale(1.55);
  }
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.75;
    transform: scale(0.97);
  }
  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

@keyframes floatChip {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes spinSlow {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes heroIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes paletteIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -20% 0;
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@keyframes dotBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@keyframes micPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.22);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(var(--accent-rgb), 0);
  }
}

/* ── Responsive ────────────────────────────────────────────── */

@media (min-width: 901px) {
  .shell.nav-hidden .sidebar {
    margin-left: calc(-1 * var(--sidebar) - 1px);
  }

  .shell.nav-hidden .nav-toggle {
    display: inline-flex;
  }

  .sidebar-close {
    display: inline-flex;
  }
}

@media (max-width: 1060px) {
  .hero h1 {
    font-size: clamp(36px, 5.2vw, 52px);
  }

  .hero-visual {
    max-width: 380px;
  }

  .suggestions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .suggestion {
    min-height: 108px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(302px, 86vw);
    margin-left: 0;
    transform: translateX(-104%);
    box-shadow: 40px 0 100px rgba(0, 0, 0, 0.5);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-scrim {
    display: block;
  }

  body.nav-open .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .stage {
    padding: 22px 24px 10px;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0;
    text-align: center;
  }

  .hero-copy {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 600px;
  }

  .hero-visual {
    order: -1;
    width: min(255px, 62vw);
    max-width: none;
    margin-bottom: -2px;
    justify-self: center;
  }

  .orb-chip {
    display: none;
  }

  .hero h1 {
    max-width: 560px;
  }

  .hero-sub {
    max-width: 490px;
  }

  .hero-foot {
    justify-content: center;
  }

  .suggestions {
    width: 100%;
    max-width: 620px;
    margin-top: 26px;
  }

  .chat-heading h2 {
    max-width: 42vw;
  }

  .composer-wrap {
    padding-right: 20px;
    padding-left: 20px;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex: 0 0 60px;
    height: 60px;
    padding: 0 12px;
  }

  .topbar-actions {
    gap: 2px;
  }

  .chat-heading h2 {
    max-width: 36vw;
    font-size: 12px;
  }

  .chat-heading span {
    display: none;
  }

  .demo-pill {
    display: none;
  }

  .model-pill {
    height: 32px;
    padding: 0 8px;
  }

  .model-tag {
    display: none;
  }

  #shareBtn,
  #exportBtn {
    display: none;
  }

  .command-btn {
    border-color: transparent;
    background: none;
  }

  .stage {
    padding: 16px 14px 8px;
  }

  .hero {
    justify-content: flex-start;
    padding-top: 2px;
  }

  .hero h1 {
    margin-top: 15px;
    font-size: clamp(32px, 9.2vw, 43px);
  }

  .hero-sub {
    margin-top: 14px;
    font-size: 13px;
    line-height: 1.65;
  }

  .hero-foot {
    margin-top: 18px;
  }

  .hero-visual {
    width: min(218px, 58vw);
  }

  .eyebrow {
    font-size: 8.5px;
  }

  .suggestions {
    grid-template-columns: 1fr;
    gap: 7px;
    margin-top: 20px;
  }

  .suggestion {
    min-height: 0;
    padding: 12px;
  }

  .suggestion-top {
    display: none;
  }

  .suggestion {
    gap: 4px;
  }

  .suggestion-tag {
    font-size: 7px;
  }

  .suggestion-title {
    font-size: 11.5px;
  }

  .thread-wrap {
    padding: 12px 0 8px;
  }

  .thread {
    gap: 25px;
  }

  .user-bubble {
    max-width: 90%;
    padding: 11px 13px;
    font-size: 13px;
  }

  .msg-ai {
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 10px;
  }

  .ai-avatar {
    width: 26px;
    height: 26px;
  }

  .ai-avatar svg {
    width: 12px;
    height: 12px;
  }

  .ai-content {
    font-size: 13px;
    line-height: 1.7;
  }

  .ai-actions {
    opacity: 0.7;
  }

  .composer-wrap {
    padding: 6px 10px max(12px, env(safe-area-inset-bottom));
  }

  .composer {
    padding: 9px 9px 7px;
    border-radius: 16px;
  }

  #prompt {
    font-size: 13.5px;
  }

  .composer-note {
    display: none;
  }

  .composer-mode {
    display: none;
  }

  .composer-divider {
    display: none;
  }

  .tool-btn span {
    display: none;
  }

  .tool-btn {
    width: 30px;
    justify-content: center;
  }

  .toast {
    bottom: 104px;
  }

  .modal-head,
  .modal-body,
  .modal-foot {
    padding-right: 16px;
    padding-left: 16px;
  }

  .modal-head h3 {
    font-size: 19px;
  }

  .swatches {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .setting-row {
    gap: 12px;
  }

  .setting-copy small {
    font-size: 9.5px;
  }

  .palette-card {
    margin-top: 8vh;
  }

  .palette-foot {
    gap: 9px;
  }

  .palette-brand {
    display: none !important;
  }
}

@media (min-width: 641px) and (max-width: 900px) {
  .stage {
    padding-top: 14px;
  }

  .hero-visual {
    width: min(228px, 56vw);
  }

  .hero h1 {
    margin-top: 14px;
    font-size: clamp(34px, 5vw, 48px);
  }

  .hero-sub {
    margin-top: 14px;
  }

  .hero-foot {
    margin-top: 18px;
  }

  .suggestions {
    margin-top: 18px;
  }

  .suggestion {
    min-height: 92px;
  }
}

@media (max-width: 390px) {
  .chat-heading h2 {
    max-width: 45vw;
  }

  .hero-visual {
    width: 190px;
  }

  .hero h1 {
    font-size: 31px;
  }

  .model-pill {
    padding: 0 7px;
  }

  .topbar-left {
    gap: 6px;
  }
}

/* ── Movimiento reducido ───────────────────────────────────── */

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

html[data-motion="off"] *,
html[data-motion="off"] *::before,
html[data-motion="off"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 0.001ms !important;
}
