/* Rənglər palitranın çalarından (--h) və doyğunluğundan (--c) yaranır */

:root {
  --h: 200;
  --c: 0.13;

  --bg: oklch(0.97 0.015 var(--h));
  --surface: oklch(0.995 0.004 var(--h));
  --surface-2: oklch(0.955 0.018 var(--h));
  --border: oklch(0.89 0.025 var(--h));
  --text: oklch(0.24 0.03 var(--h));
  --muted: oklch(0.5 0.03 var(--h));
  --accent: oklch(0.5 var(--c) var(--h));
  --accent-hover: oklch(0.44 var(--c) var(--h));
  --on-accent: #ffffff;
  --accent-soft: oklch(0.92 0.05 var(--h));
  --mark: oklch(0.84 0.09 var(--h));
  --warn: oklch(0.52 0.14 55);
  --warn-soft: oklch(0.94 0.06 85);
  --blob-1: oklch(0.88 0.08 var(--h) / 0.55);
  --blob-2: oklch(0.9 0.08 calc(var(--h) + 70) / 0.45);
  --dot: oklch(0.89 0.02 var(--h));
  --shadow: 0 1px 2px oklch(0.3 0.04 var(--h) / 0.06), 0 10px 28px -12px oklch(0.3 0.06 var(--h) / 0.22);

  --radius: 20px;
  --bounce: cubic-bezier(0.3, 1.5, 0.5, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: oklch(0.17 0.02 var(--h));
  --surface: oklch(0.215 0.022 var(--h));
  --surface-2: oklch(0.25 0.025 var(--h));
  --border: oklch(0.32 0.03 var(--h));
  --text: oklch(0.95 0.01 var(--h));
  --muted: oklch(0.74 0.025 var(--h));
  --accent: oklch(0.78 var(--c) var(--h));
  --accent-hover: oklch(0.85 var(--c) var(--h));
  --on-accent: oklch(0.2 0.04 var(--h));
  --accent-soft: oklch(0.33 0.06 var(--h));
  --mark: oklch(0.46 0.1 var(--h));
  --warn: oklch(0.82 0.14 75);
  --warn-soft: oklch(0.33 0.06 70);
  --blob-1: oklch(0.4 0.1 var(--h) / 0.35);
  --blob-2: oklch(0.4 0.1 calc(var(--h) + 70) / 0.25);
  --dot: oklch(0.28 0.025 var(--h));
  --shadow: 0 10px 28px -12px oklch(0 0 0 / 0.55);
  color-scheme: dark;
}

:root[data-palette="nar"] { --h: 20; --c: 0.18; }
:root[data-palette="zeferan"] { --h: 60; --c: 0.16; }
:root[data-palette="benovshe"] { --h: 300; --c: 0.16; }
:root[data-palette="cemen"] { --h: 145; --c: 0.15; }

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(42rem 32rem at -5% -10%, var(--blob-1), transparent 65%),
    radial-gradient(38rem 30rem at 105% 5%, var(--blob-2), transparent 65%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  transition: background-color 0.3s, color 0.3s;
}

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

/* Başlıq */

.apps-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}
.apps-link svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.apps-link:hover { color: var(--text); }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  display: grid;
  flex: none;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 15px;
  background: var(--accent);
  box-shadow: 0 8px 18px -8px var(--accent);
  color: var(--on-accent);
  font-size: 1rem;
  font-weight: 900;
  transform: rotate(-8deg);
  transition: transform 0.35s var(--bounce), background-color 0.3s;
}

.brand:hover .logo {
  transform: rotate(8deg) scale(1.08);
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.2rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.palettes {
  display: flex;
  gap: 8px;
}

.swatch {
  position: relative;
  display: block;
}

.swatch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch-dot {
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: oklch(0.64 var(--c) var(--h));
  box-shadow: inset 0 0 0 2px oklch(1 0 0 / 0.25);
  transition: transform 0.25s var(--bounce), box-shadow 0.2s;
}

.swatch input:hover + .swatch-dot {
  transform: scale(1.15);
}

.swatch input:checked + .swatch-dot {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}

.swatch input:focus-visible + .swatch-dot {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 1.15rem;
  cursor: pointer;
  transition: transform 0.4s var(--bounce), background-color 0.3s;
}

.theme-toggle:hover {
  transform: rotate(25deg) scale(1.08);
}

.settings-toggle {
  position: relative;
}

.settings-toggle span {
  display: inline-block;
  transition: transform 0.5s var(--bounce);
}

.settings-toggle[aria-expanded="false"] {
  background: var(--accent-soft);
}

.settings-toggle:hover {
  transform: scale(1.08);
}

.settings-toggle:hover span {
  transform: rotate(60deg);
}

.settings-toggle[aria-expanded="false"] span {
  transform: rotate(180deg);
}

.settings-toggle[aria-expanded="false"]:hover span {
  transform: rotate(240deg);
}

.options[hidden] {
  display: none;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hero-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 32px;
  margin-top: 18px;
}

.lead {
  flex: 1 1 auto;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.lead strong {
  color: var(--text);
}

/* Seçimlər */

/* Boşluq başlıqdadır ki, ayarlar gizlənəndə də panellərlə arası açıq qalsın */
.hero {
  margin-bottom: 26px;
}

.options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  margin: 0 0 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-letter {
  min-width: 1.1em;
  font-size: 1.35rem;
  font-weight: 800;
  text-align: center;
}

.arrow {
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.segmented label {
  position: relative;
}

.segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span {
  display: block;
  min-width: 46px;
  padding: 3px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  transition: background-color 0.15s, color 0.15s, transform 0.25s var(--bounce);
}

.segmented input:hover + span {
  color: var(--text);
}

.segmented input:active + span {
  transform: scale(0.9);
}

.segmented input:checked + span {
  background: var(--accent);
  color: var(--on-accent);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switches {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
}

.switch {
  position: relative;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  background: var(--border);
  border-radius: 999px;
  transition: background-color 0.2s;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--surface);
  border-radius: 50%;
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.25);
  transition: transform 0.3s var(--bounce);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.reset {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-left: auto;
  padding: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, transform 0.25s var(--bounce);
}

.reset:hover {
  color: var(--text);
}

.reset:active {
  transform: scale(0.9);
}

.reset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.reset-icon {
  display: inline-block;
  line-height: 1;
}

.reset.is-spinning .reset-icon {
  animation: spin-back 0.6s var(--bounce);
}

.option-fixed {
  flex-basis: 100%;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.option-fixed > span:first-child {
  margin-right: 2px;
}

.chip {
  padding: 2px 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  white-space: nowrap;
}

/* Mətn panelləri */

.panels {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

@media (min-width: 760px) {
  .panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background-color 0.3s;
}

.panel:focus-within {
  border-color: var(--accent);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 800;
}

.panel-actions {
  display: flex;
  gap: 6px;
}

.editor {
  flex: 1 0 auto;
  width: 100%;
  min-height: 280px;
  margin: 0;
  padding: 16px;
  border: 0;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1.6;
  resize: vertical;
}

.editor::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

/* Telefon */

.phone-stage {
  display: flex;
  flex: 1 0 auto;
  justify-content: center;
  padding: 20px 16px;
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.6px);
  background-size: 18px 18px;
}

.phone {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  background: var(--surface);
  border: 10px solid oklch(0.22 0.015 var(--h));
  border-radius: 44px;
  box-shadow: 0 0 0 1px var(--border), 0 18px 40px -18px oklch(0.2 0.05 var(--h) / 0.5);
}

.phone-status {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 4px 24px;
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.island {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 84px;
  height: 22px;
  background: oklch(0.15 0 0);
  border-radius: 999px;
  transform: translateX(-50%);
}

.phone-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.signal {
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 10px;
}

.signal i {
  width: 3px;
  background: currentColor;
  border-radius: 1px;
}

.signal i:nth-child(1) { height: 4px; }
.signal i:nth-child(2) { height: 6px; }
.signal i:nth-child(3) { height: 8px; }
.signal i:nth-child(4) { height: 10px; }

.battery {
  position: relative;
  width: 22px;
  height: 11px;
  padding: 1.5px;
  border: 1.5px solid currentColor;
  border-radius: 3.5px;
  opacity: 0.9;
}

.battery::before {
  content: "";
  display: block;
  width: 75%;
  height: 100%;
  background: currentColor;
  border-radius: 1.5px;
}

.battery::after {
  content: "";
  position: absolute;
  top: 2px;
  right: -4px;
  width: 2px;
  height: 4px;
  background: currentColor;
  border-radius: 0 1px 1px 0;
}

.phone-contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0 10px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: var(--accent-soft);
  border-radius: 50%;
  font-size: 1.2rem;
}

.contact-name {
  font-size: 0.75rem;
  font-weight: 800;
}

/* Telefon görünüşü söndürüləndə sadə çat qalır */
.phone-stage.is-plain {
  padding: 0;
}

.phone-stage.is-plain .phone {
  max-width: none;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.phone-stage.is-plain .phone-status,
.phone-stage.is-plain .phone-contact {
  display: none;
}

.phone-stage.is-plain .chat {
  min-height: 280px;
  padding: 18px 16px;
}

/* SMS çatı */

.chat {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-height: 240px;
  padding: 14px 12px 16px;
}

.bubble {
  max-width: 88%;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: 20px 20px 6px 20px;
  outline: none;
  font-size: 1.05rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: bubble-in 0.4s var(--bounce);
  transform-origin: bottom right;
}

.bubble:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.bubble mark {
  border-radius: 4px;
  background: var(--mark);
  color: inherit;
}

.chat.hide-changes .bubble mark.changed {
  background: transparent;
}

.bubble mark.unsupported {
  background: var(--warn-soft);
  box-shadow: inset 0 -2px 0 var(--warn);
}

.bubble.is-returning {
  animation: bubble-in 0.45s var(--bounce);
}

/* Növbəti SMS-in başladığı yer */
.sms-break {
  position: relative;
  display: block;
  margin: 14px -6px 10px;
  border-top: 1.5px dashed var(--accent);
}

.sms-break::after {
  content: attr(data-label);
  position: absolute;
  top: -10px;
  left: 50%;
  padding: 1px 8px;
  background: var(--accent);
  border-radius: 999px;
  color: var(--on-accent);
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
  transform: translateX(-50%);
}

.bubble-meta {
  padding-right: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.bubble-meta.is-sent .ticks {
  color: var(--accent);
}

/* Pasxa yumurtaları və göndərmə animasiyası */

.title-letter {
  display: inline-block;
  white-space: pre;
}

.logo {
  cursor: pointer;
  user-select: none;
}

.typing {
  display: inline-flex;
  gap: 5px;
  padding: 14px 16px;
  background: var(--accent-soft);
  border-radius: 20px 20px 6px 20px;
}

.typing i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing 1.2s ease-in-out infinite;
}

.typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

.chat-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.chat.is-empty .bubble,
.chat.is-empty .bubble-meta,
.chat:not(.is-empty) .typing,
.chat:not(.is-empty) .chat-hint {
  display: none;
}

/* Statistika */

.panel-foot {
  padding: 10px 16px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stats > span:not(.badge) + span:not(.savings)::before {
  content: "·";
  margin-right: 10px;
}

.badge {
  padding: 1px 9px;
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
}

.badge.is-unicode {
  background: var(--warn-soft);
  color: var(--warn);
}

.savings {
  margin-left: auto;
  padding: 1px 10px;
  background: var(--accent);
  border-radius: 999px;
  color: var(--on-accent);
  font-size: 0.8rem;
  font-weight: 800;
}

/* Düymələr */

.btn {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.25s var(--bounce);
}

.btn:not(:disabled):active {
  transform: scale(0.94);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.btn-primary {
  min-width: 9em;
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-ghost:not(:disabled):hover {
  background: var(--surface-2);
  color: var(--text);
}

.dice {
  display: inline-block;
}

.btn.is-rolling .dice {
  animation: roll 0.5s var(--bounce);
}

/* Xəbərdarlıq və qeyd */

.warning {
  margin: 16px 0 0;
  padding: 10px 14px;
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.tip {
  margin: 16px 0 0;
  padding: 10px 14px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.tip strong {
  color: var(--accent);
  font-weight: 900;
}

.warning code {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 0 6px;
  background: var(--surface);
  border-radius: 6px;
  font: inherit;
  font-weight: 800;
}

.note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
}

.footer .note {
  margin: 0;
  text-align: left;
}

.footer .social {
  flex: none;
}

.social {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  transition: color 0.15s, background-color 0.15s, transform 0.25s var(--bounce);
}

.social:hover {
  background: var(--surface-2);
  color: #0a66c2;
  transform: translateY(-2px);
}

.social:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.confetti {
  position: fixed;
  z-index: 50;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  pointer-events: none;
}

/* Animasiyalar */

@keyframes bubble-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
}

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

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

@keyframes roll {
  50% {
    transform: rotate(200deg) scale(1.25);
  }
  to {
    transform: rotate(360deg);
  }
}

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

@media (max-width: 480px) {
  .options {
    gap: 10px 16px;
    padding: 12px;
  }

  .option {
    gap: 6px;
  }

  .segmented span {
    min-width: 38px;
    padding: 3px 10px;
  }
}
