/* ==========================================================================
   style.css — Sohbet arayüzü, tomatos.lol ("Grumpy Tomato") tasarım dilinde.
   Renk, ölçü ve hareket değerleri tokens.css'ten gelir; burada ham renk yok.
   Butonlar "reçel kavanozu etiketi": tam hap, 3px kenarlık, bulanıksız sert gölge.
   ========================================================================== */

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

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  transition: background-color var(--dur-slow) var(--ease-out);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-label);
  font-weight: 400;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-strong);
}

p {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-surface-alt) transparent;
}

/* ---- metin alanları ---- */
input,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--bg-inset);
  color: var(--text-strong);
  transition: border-color var(--dur-fast) linear;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:focus,
textarea:focus {
  border-color: var(--accent-2);
  outline: none;
}

input[type='checkbox'] {
  width: auto;
}

/* ==========================================================================
   Butonlar
   ========================================================================== */

/* Birincil: dolu kavanoz. Ekranda en fazla bir tane. */
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: 0 var(--space-5);
  border: 3px solid var(--ring);
  border-radius: var(--r-pill);
  background: var(--accent-solid);
  color: var(--cream-100);
  box-shadow: var(--shadow-jar);
  font-family: var(--font-label);
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  white-space: nowrap;
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam),
    background-color var(--dur-fast) linear;
}

.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-jar-lift);
  background: var(--tomato-500);
}

.primary:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: var(--shadow-jar-press);
}

.primary:disabled {
  filter: grayscale(0.6);
  opacity: 0.55;
}

/* İkincil: boş kavanoz */
.ghost {
  --shadow-hard: var(--accent-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 3px solid var(--accent);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--accent);
  box-shadow: var(--shadow-pill);
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  white-space: nowrap;
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam),
    background-color var(--dur-fast) linear;
}

.ghost:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 0 var(--shadow-hard);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.ghost:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 0 var(--shadow-hard);
}

.ghost.small {
  min-height: 34px;
  padding: 0 var(--space-3);
  font-size: 0.6875rem;
}

.wide {
  width: 100%;
}

/* Sahne üstü kontrol hapı (tomatos ControlPill) — ikonlu yuvarlak düğmeler */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 3px solid var(--ring);
  border-radius: var(--r-pill);
  background: var(--bg-surface-alt);
  color: var(--text-strong);
  box-shadow: var(--shadow-pill);
  font-size: 1rem;
  line-height: 1;
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam);
}

.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 0 var(--shadow-hard);
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 0 var(--shadow-hard);
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

/* Etiketli hap (tema anahtarı gibi) */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 3px solid var(--ring);
  border-radius: var(--r-pill);
  background: var(--bg-surface-alt);
  color: var(--text-strong);
  box-shadow: var(--shadow-pill);
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam);
}

.pill-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 0 var(--shadow-hard);
}

.pill-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 0 var(--shadow-hard);
}

.theme-float {
  position: fixed;
  top: max(var(--space-4), env(safe-area-inset-top));
  right: var(--space-4);
  z-index: 5;
}

/* ==========================================================================
   Kâğıt not (tomatos Quip): krem kâğıt, amber bant, hafif eğik, el yazısı
   ========================================================================== */

.note,
.toast,
.list-empty,
.seen-line.theirs,
.chat-placeholder p {
  position: relative;
  background: var(--note-bg);
  color: var(--note-ink);
  border: 3px solid var(--note-edge);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 0 0 var(--note-shadow);
  font-family: var(--font-hand);
  font-size: var(--fs-hand);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
  rotate: -1.4deg;
}

.toast::before,
.list-empty::before,
.chat-placeholder p::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  translate: -50% 0;
  width: 58px;
  height: 20px;
  background: var(--note-tape);
  opacity: 0.85;
  rotate: 2deg;
}

@keyframes pop {
  from {
    opacity: 0;
    translate: 0 10px;
    scale: 0.96;
  }
  to {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
}

.form-error {
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--accent);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-surface));
  color: var(--text-strong);
  font-size: var(--fs-sm);
  font-weight: 600;
}

/* ==========================================================================
   Açılış ve giriş: arka plan oda fotoğrafının kendisi
   ========================================================================== */

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  background: var(--bg-page);
}

.boot p {
  color: var(--text-muted);
  font-family: var(--font-hand);
  font-size: 1.5rem;
}

.auth {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-7) var(--space-4);
  background: var(--bg-page) var(--scene) center / cover no-repeat;
}

.auth::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--scrim);
  pointer-events: none;
}

.auth-card {
  position: relative;
  width: min(410px, 100%);
  padding: var(--space-5);
  border: 3px solid var(--ring);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.brand img {
  width: 56px;
  height: 56px;
  rotate: -6deg;
}

.brand h1 {
  font-size: 1.75rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  padding: var(--space-1);
  border: 3px solid var(--ring);
  border-radius: var(--r-pill);
  background: var(--bg-inset);
}

.tabs button {
  min-height: 38px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  transition: background-color var(--dur-fast) linear;
}

.tabs button[aria-selected='true'] {
  background: var(--accent-solid);
  color: var(--cream-100);
}

#auth-form {
  display: grid;
  gap: var(--space-4);
}

#auth-form label {
  display: grid;
  gap: var(--space-2);
}

#auth-form label > span {
  font-family: var(--font-label);
  font-size: 0.6875rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

#auth-form small {
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
}

.hint {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ==========================================================================
   Uygulama iskeleti
   ========================================================================== */

.app {
  display: grid;
  /* minmax(0, …): uzun tek satırlık metinler sütunu ekrandan taşırmasın */
  grid-template-columns: minmax(290px, 370px) minmax(0, 1fr);
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-surface);
  border-right: 3px solid var(--bg-page-deep);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) var(--space-2);
  padding-top: max(var(--space-3), env(safe-area-inset-top));
}

.me {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  transition: background-color var(--dur-fast) linear;
}

.me:hover {
  background: var(--bg-surface-alt);
}

.me-text,
.chat-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.me-text strong,
.me-text small,
.chat-title strong,
.chat-title small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-text strong,
.chat-title strong {
  color: var(--text-strong);
  font-weight: 700;
}

.me-text small,
.chat-title small {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.filter {
  padding: var(--space-2) var(--space-3) var(--space-3);
}

.filter input {
  border-radius: var(--r-pill);
  padding: 8px 16px;
}

.conversation-list {
  list-style: none;
  flex: 1;
  margin: 0;
  padding: 0 var(--space-2) var(--space-3);
  overflow-y: auto;
}

.conversation {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
  transition: background-color var(--dur-fast) linear;
}

.conversation:hover {
  background: var(--bg-surface-alt);
}

.conversation[aria-current='true'] {
  background: var(--bg-surface-alt);
  box-shadow: inset 4px 0 0 var(--accent-solid);
}

/* Sabit bot sohbeti: altında kesik çizgi */
.conversation.bot {
  margin-bottom: var(--space-2);
}

.conversation.bot::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -6px;
  border-bottom: 2px dashed var(--border-soft);
}

.conv-main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* uzun önizleme sütunu genişletmesin, "…" ile kısalsın */
  gap: 2px;
}

.conv-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.conv-title,
.conv-preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-title {
  color: var(--text-strong);
  font-weight: 700;
}

.conv-time {
  flex: none;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.conv-preview {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.conversation.unread .conv-time {
  color: var(--text-accent);
  font-weight: 700;
}

.conversation.unread .conv-preview {
  color: var(--text-body);
  font-weight: 600;
}

.typing-text {
  color: var(--text-accent) !important;
  font-style: italic;
}

.pin {
  display: inline-grid;
  flex: none;
  align-self: center;
  color: var(--text-accent);
}

.pin svg {
  width: 13px;
  height: 13px;
}

.badge {
  flex: none;
  min-width: 24px;
  height: 22px;
  padding: 0 6px;
  border: 2px solid var(--ring);
  border-radius: var(--r-pill);
  background: var(--accent-solid);
  color: var(--cream-100);
  font-family: var(--font-label);
  font-size: 0.625rem;
  line-height: 18px;
  text-align: center;
}

.list-empty {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  margin: var(--space-6) var(--space-4);
  padding: var(--space-5) var(--space-4) var(--space-4);
  animation: pop var(--dur-slow) var(--ease-jam);
}

/* ==========================================================================
   Avatarlar: paletten tonlar, krem kenarlık
   ========================================================================== */

.avatar {
  --av-bg: var(--tone-1-bg);
  --av-ink: var(--tone-1-ink);
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ring);
  border-radius: 50%;
  background: var(--av-bg);
  color: var(--av-ink);
  font-family: var(--font-label);
  font-size: 0.875rem;
  user-select: none;
}

.avatar[data-tone='2'] {
  --av-bg: var(--tone-2-bg);
  --av-ink: var(--tone-2-ink);
}
.avatar[data-tone='3'] {
  --av-bg: var(--tone-3-bg);
  --av-ink: var(--tone-3-ink);
}
.avatar[data-tone='4'] {
  --av-bg: var(--tone-4-bg);
  --av-ink: var(--tone-4-ink);
}
.avatar[data-tone='5'] {
  --av-bg: var(--tone-5-bg);
  --av-ink: var(--tone-5-ink);
}
.avatar[data-tone='6'] {
  --av-bg: var(--tone-6-bg);
  --av-ink: var(--tone-6-ink);
}
.avatar[data-tone='7'] {
  --av-bg: var(--tone-7-bg);
  --av-ink: var(--tone-7-ink);
}

.avatar.small {
  width: 38px;
  height: 38px;
  font-size: 0.75rem;
}

.avatar.large {
  width: 92px;
  height: 92px;
  border-width: 3px;
  box-shadow: var(--shadow-pill);
  font-size: 1.75rem;
}

.avatar.group {
  border-radius: var(--r-md);
}

.avatar.bot {
  background: var(--bubble-bot-bg);
  font-family: var(--font-body);
  font-size: 1.375rem;
}

.avatar.bot.small {
  font-size: 1.125rem;
}

.avatar.has-img {
  background: var(--bg-inset);
  color: transparent;
}

.avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.avatar.online::after {
  content: '';
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 13px;
  height: 13px;
  border: 2px solid var(--bg-surface);
  border-radius: 50%;
  background: var(--online);
}

.avatar-slot {
  display: contents;
}

/* ==========================================================================
   Sohbet alanı
   ========================================================================== */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--chat-bg);
}

/* Sohbet seçilmemişken: oda fotoğrafı ve üstünde kâğıt not */
.chat-placeholder {
  position: relative;
  flex: 1;
  display: grid;
  align-content: end;
  justify-items: center;
  padding: var(--space-7) var(--space-5);
  background: var(--chat-bg) var(--scene) center / cover no-repeat;
}

.chat-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--scrim);
  pointer-events: none;
}

.chat-placeholder p {
  max-width: 30ch;
  padding: var(--space-4) var(--space-5) var(--space-3);
}

.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 64px;
  padding: var(--space-2) var(--space-4);
  padding-top: max(var(--space-2), env(safe-area-inset-top));
  background: var(--bg-surface);
  border-bottom: 3px solid var(--bg-page-deep);
}

.chat-title {
  flex: 1;
}

.back-btn {
  display: none;
}

.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.messages-top {
  min-height: 1em;
  margin: var(--space-3) 0;
  color: var(--text-muted);
  font-family: var(--font-hand);
  font-size: 1.25rem;
  text-align: center;
}

.message-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  max-width: 900px;
  margin: 0 auto;
  padding: 0;
}

.day-sep {
  align-self: center;
  margin: var(--space-4) 0 var(--space-2);
  padding: 3px 14px;
  border: 2px solid var(--border-soft);
  border-radius: var(--r-pill);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-label);
  font-size: 0.625rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.msg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: var(--space-3);
}

.msg.grouped {
  margin-top: 5px;
}

.msg.mine {
  align-items: flex-end;
}

.msg-sender {
  margin: 0 0 3px 10px;
  color: var(--text-strong);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.bot-sender {
  color: var(--bot-label);
  font-family: var(--font-label);
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.bot-read {
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  letter-spacing: 0;
  text-transform: none;
}

/* Balonlar: karşı taraf krem kâğıt, ben domates kavanozu, bot nane etiketi */
.bubble {
  --meta: var(--bubble-theirs-meta);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: 10px;
  max-width: min(78%, 600px);
  padding: 7px 12px 6px 13px;
  border: 2px solid var(--bubble-theirs-edge);
  border-radius: var(--r-md);
  background: var(--bubble-theirs-bg);
  color: var(--bubble-theirs-ink);
  box-shadow: 0 3px 0 0 var(--bubble-theirs-shadow);
}

.msg.mine .bubble {
  --meta: var(--bubble-mine-meta);
  border-color: var(--bubble-mine-edge);
  background: var(--bubble-mine-bg);
  color: var(--bubble-mine-ink);
  box-shadow: 0 3px 0 0 var(--bubble-mine-shadow);
}

.msg.from-bot .bubble {
  --meta: var(--bubble-bot-meta);
  border-color: var(--bubble-bot-edge);
  background: var(--bubble-bot-bg);
  color: var(--bubble-bot-ink);
  box-shadow: 0 3px 0 0 var(--bubble-bot-shadow);
}

.msg.theirs:not(.grouped) .bubble {
  border-top-left-radius: 4px;
}

.msg.mine:not(.grouped) .bubble {
  border-top-right-radius: 4px;
}

.msg-body {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-body.rich {
  display: block;
}

.msg-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  color: var(--meta);
  font-size: 0.6875rem;
  white-space: nowrap;
  transform: translateY(2px);
}

.tick {
  display: inline-grid;
  width: 16px;
  height: 16px;
}

.tick svg {
  width: 16px;
  height: 16px;
}

.tick.read {
  color: var(--amber-400);
}

.msg.pending .bubble {
  opacity: 0.72;
}

.msg.failed .bubble {
  border-style: dashed;
}

.retry {
  margin-top: var(--space-1);
  padding: 2px 4px;
  border: 0;
  background: none;
  color: var(--accent);
  font-family: var(--font-label);
  font-size: 0.625rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.code-block,
.inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: color-mix(in srgb, currentColor 10%, transparent);
}

.code-block {
  margin: 6px 0;
  padding: 8px 10px;
  overflow-x: auto;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  white-space: pre;
}

.inline-code {
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.92em;
}

/* ---- görüldü sayacı: el yazısı ---- */
.seen-line {
  margin: 6px 8px 0;
  color: var(--text-muted);
  font-family: var(--font-hand);
  font-size: 1.1875rem;
  font-weight: 600;
  line-height: 1.2;
}

.seen-line.mine {
  align-self: flex-end;
}

.seen-line.theirs {
  align-self: center;
  margin-top: var(--space-4);
  padding: 4px 14px 2px;
  font-size: 1.1875rem;
  animation: pop var(--dur-slow) var(--ease-jam);
}

/* ==========================================================================
   Görseller
   ========================================================================== */

.bubble.with-image {
  display: block;
  padding: 4px;
}

.msg-image {
  position: relative;
  display: block;
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-inset);
  cursor: zoom-in;
}

.msg-image img {
  display: block;
  max-width: 100%;
  height: auto;
}

.msg-image img.local {
  max-width: min(260px, 100%);
  max-height: 320px;
}

.caption {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  column-gap: 10px;
  max-width: 300px;
  padding: 5px 7px 2px 8px;
}

.msg-meta.on-image {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--on-image-bg);
  color: var(--on-image-ink);
  transform: none;
}

.upload-progress {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 8px;
  border: 2px solid var(--cream-100);
  border-radius: var(--r-pill);
  background: var(--on-image-bg);
  overflow: hidden;
}

.upload-progress > span {
  display: block;
  height: 100%;
  background: var(--amber-400);
  transition: width 150ms linear;
}

.attachments {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-3) 0;
  overflow-x: auto;
  background: var(--bg-surface);
  border-top: 3px solid var(--bg-page-deep);
}

.attachments:not([hidden]) + .composer {
  border-top: 0;
}

.attachment {
  position: relative;
  flex: none;
  width: 72px;
  height: 72px;
  border: 2px solid var(--ring);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-inset);
}

.attachment img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--on-image-bg);
  color: var(--on-image-ink);
}

.attachment button svg {
  width: 13px;
  height: 13px;
}

.drop-overlay {
  position: absolute;
  inset: var(--space-3);
  z-index: 5;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  border: 3px dashed var(--accent-2);
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg-surface) 90%, transparent);
  color: var(--text-strong);
  font-family: var(--font-hand);
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
}

.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--overlay-deep);
  cursor: zoom-out;
}

.viewer[open] {
  display: grid;
  place-items: center;
}

.viewer::backdrop {
  background: transparent;
}

.viewer img {
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 96px);
  border: 3px solid var(--cream-100);
  border-radius: var(--r-sm);
  object-fit: contain;
}

.viewer-close {
  position: absolute;
  top: max(var(--space-3), env(safe-area-inset-top));
  right: var(--space-3);
}

/* ==========================================================================
   Yazma alanı
   ========================================================================== */

.composer {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3);
  padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
  background: var(--bg-surface);
  border-top: 3px solid var(--bg-page-deep);
}

.composer textarea {
  flex: 1;
  max-height: 160px;
  padding: 10px 18px;
  border-radius: 22px;
  resize: none;
  line-height: 1.4;
}

.attach-btn,
.summon-btn {
  width: 44px;
  height: 44px;
}

.summon-btn,
.bot-toggle {
  font-size: 1.125rem;
}

.send-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 3px solid var(--ring);
  border-radius: 50%;
  background: var(--accent-solid);
  color: var(--cream-100);
  box-shadow: var(--shadow-jar);
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam),
    background-color var(--dur-fast) linear;
}

.send-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-jar-lift);
  background: var(--tomato-500);
}

.send-btn:active {
  transform: translateY(4px);
  box-shadow: var(--shadow-jar-press);
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

.bot-toggle.off {
  filter: grayscale(1);
  opacity: 0.7;
}

.bot-toggle.off::after {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  top: 50%;
  border-top: 3px solid var(--accent);
  transform: rotate(-35deg);
}

/* ---- komut menüsü ---- */
.command-menu {
  list-style: none;
  max-height: 260px;
  margin: 0;
  padding: var(--space-2);
  overflow-y: auto;
  background: var(--bg-surface-alt);
  border-top: 3px solid var(--bg-page-deep);
}

.command {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: 8px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
}

.command[aria-selected='true'],
.command:hover {
  background: var(--bg-inset);
}

.command code {
  flex: none;
  color: var(--text-accent);
  font-family: var(--font-body);
  font-weight: 700;
}

.command span {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ==========================================================================
   Komutlu mesajlar
   ========================================================================== */

.kind-shout .msg-body {
  font-family: var(--font-label);
  font-size: 1.25rem;
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.kind-whisper .msg-body {
  font-size: var(--fs-xs);
  font-style: italic;
  opacity: 0.75;
}

.game {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 140px;
  padding: 2px 4px;
  text-align: center;
}

.game-label {
  font-family: var(--font-label);
  font-size: 0.625rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  opacity: 0.75;
}

.dice-faces {
  display: flex;
  gap: 4px;
  font-size: 44px;
  line-height: 1.05;
}

.die,
.coin-face,
.wheel {
  display: inline-block;
}

.coin-face,
.wheel {
  font-size: 40px;
  line-height: 1.1;
}

.game-result {
  font-family: var(--font-label);
  font-size: 1.0625rem;
  letter-spacing: 0.03em;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0) rotate(0);
  }
  15% {
    transform: translateX(-6px) rotate(-2deg);
  }
  30% {
    transform: translateX(6px) rotate(2deg);
  }
  45% {
    transform: translateX(-5px) rotate(-1deg);
  }
  60% {
    transform: translateX(5px) rotate(1deg);
  }
  75% {
    transform: translateX(-2px);
  }
}

@keyframes roll {
  0% {
    transform: rotate(0) scale(0.6);
    opacity: 0.4;
  }
  70% {
    transform: rotate(600deg) scale(1.15);
    opacity: 1;
  }
  100% {
    transform: rotate(720deg) scale(1);
  }
}

@keyframes flip {
  0% {
    transform: rotateY(0) translateY(0);
  }
  50% {
    transform: rotateY(900deg) translateY(-18px);
  }
  100% {
    transform: rotateY(1800deg) translateY(0);
  }
}

@keyframes spin {
  from {
    transform: rotate(0);
  }
  to {
    transform: rotate(1080deg);
  }
}

@keyframes boom {
  0% {
    transform: scale(1);
    filter: none;
    opacity: 1;
  }
  30% {
    transform: scale(1.12) rotate(-2deg);
  }
  100% {
    transform: scale(1.5) rotate(4deg);
    filter: blur(10px);
    opacity: 0;
  }
}

.fresh.kind-shout {
  animation: shake 0.6s ease-in-out 2;
}

.fresh .die {
  animation: roll 0.9s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.fresh .coin-face {
  animation: flip 1s ease-out;
}

.fresh .wheel {
  animation: spin 1.2s cubic-bezier(0.1, 0.6, 0.2, 1);
}

/* ---- kendini imha eden mesaj: domates tehlike şeridi ---- */
.msg .bubble.burn-sealed {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 3px solid var(--ring);
  background: repeating-linear-gradient(
    -45deg,
    var(--stripe-a),
    var(--stripe-a) 12px,
    var(--stripe-b) 12px,
    var(--stripe-b) 24px
  );
  color: var(--cream-100);
  box-shadow: var(--shadow-jar);
  text-align: left;
  font: inherit;
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam);
}

.msg .bubble.burn-sealed:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-jar-lift);
}

.burn-sealed:hover .burn-icon {
  animation: shake 0.5s ease-in-out;
}

.burn-icon {
  font-size: 26px;
}

.burn-text {
  display: grid;
}

.burn-text strong {
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  font-weight: 400;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.burn-text small {
  opacity: 0.85;
}

.burn-destroyed .msg-body {
  font-family: var(--font-hand);
  font-size: 1.25rem;
  font-weight: 600;
  opacity: 0.8;
}

.burn-timer {
  display: inline-block;
  margin: 0 100% 4px 0;
  padding: 1px 10px;
  border: 2px solid var(--wood-900);
  border-radius: var(--r-pill);
  background: var(--amber-400);
  color: var(--wood-900);
  font-family: var(--font-label);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

.burn-tag {
  display: block;
  flex-basis: 100%;
  margin-bottom: 2px;
  font-family: var(--font-label);
  font-size: 0.625rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  opacity: 0.85;
}

.bubble.with-image .burn-timer,
.bubble.with-image .burn-tag {
  margin: 2px 4px 6px;
}

.exploding {
  animation: boom 0.7s ease-in forwards;
}

/* ---- yarışma şıkları: küçük kavanoz etiketleri ---- */
.quiz-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(44px, 1fr));
  gap: var(--space-2);
  flex-basis: 100%;
  margin: var(--space-2) 0 var(--space-1);
}

.quiz-option {
  min-height: 42px;
  border: 3px solid var(--wood-900);
  border-radius: var(--r-pill);
  background: var(--cream-100);
  color: var(--wood-900);
  box-shadow: 0 3px 0 0 var(--wood-900);
  font-family: var(--font-label);
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam);
}

.quiz-option:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 0 var(--wood-900);
}

.quiz-option:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 0 0 0 var(--wood-900);
}

.quiz-option:disabled {
  filter: grayscale(0.6);
  opacity: 0.55;
}

/* ---- gizli cevap (/sor): kâğıt not ---- */
.private-note {
  position: relative;
  display: grid;
  gap: var(--space-2);
  width: 100%;
  max-width: 560px;
  margin: var(--space-5) auto var(--space-1);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border: 3px solid var(--note-edge);
  border-radius: var(--r-sm);
  background: var(--note-bg);
  color: var(--note-ink);
  box-shadow: 0 4px 0 0 var(--note-shadow);
  rotate: -0.6deg;
  animation: pop var(--dur-slow) var(--ease-jam);
}

.private-note::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  translate: -50% 0;
  width: 58px;
  height: 20px;
  background: var(--note-tape);
  opacity: 0.85;
  rotate: 2deg;
}

.private-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-label);
  font-size: 0.625rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.private-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--note-edge);
  border-radius: 50%;
  background: transparent;
  color: var(--note-ink);
}

.private-close svg {
  width: 14px;
  height: 14px;
}

.private-question,
.private-foot {
  font-size: var(--fs-xs);
  opacity: 0.7;
}

.private-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.private-body.pending {
  font-family: var(--font-hand);
  font-size: 1.25rem;
  font-weight: 600;
}

.private-body.error {
  color: var(--tomato-700);
  font-weight: 600;
}

.suggestions {
  display: grid;
  gap: var(--space-2);
}

.suggestion {
  display: grid;
  gap: 2px;
  padding: 8px 12px;
  border: 2px solid var(--note-edge);
  border-radius: var(--r-md);
  background: var(--cream-200);
  color: var(--note-ink);
  box-shadow: 0 3px 0 0 var(--note-edge);
  text-align: left;
  transition:
    transform var(--dur-base) var(--ease-jam),
    box-shadow var(--dur-base) var(--ease-jam);
}

.suggestion:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 0 var(--note-edge);
}

.suggestion strong {
  color: var(--tomato-700);
  font-family: var(--font-label);
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

/* ==========================================================================
   Bildirimler
   ========================================================================== */

.banner {
  position: fixed;
  top: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 6px 18px;
  border: 3px solid var(--wood-900);
  border-radius: var(--r-pill);
  background: var(--amber-400);
  color: var(--wood-900);
  box-shadow: 0 3px 0 0 var(--wood-900);
  font-family: var(--font-label);
  font-size: 0.6875rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.toast {
  position: fixed;
  bottom: 96px;
  left: 50%;
  translate: -50% 0;
  z-index: 30;
  max-width: min(36ch, calc(100vw - var(--space-6)));
  padding: var(--space-4) var(--space-5) var(--space-3);
  animation: pop var(--dur-slow) var(--ease-jam);
}

/* ==========================================================================
   Pencereler
   ========================================================================== */

.dialog {
  width: min(470px, calc(100% - 32px));
  max-height: min(660px, calc(100dvh - 32px));
  padding: 0;
  border: 3px solid var(--ring);
  border-radius: var(--r-lg);
  background: var(--bg-surface);
  color: var(--text-body);
  box-shadow: var(--shadow-card);
}

.dialog::backdrop {
  background: var(--overlay);
}

.dialog form,
.dialog-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: inherit;
  padding: var(--space-4) var(--space-5) var(--space-5);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.dialog-header h2 {
  font-size: 1.0625rem;
}

.dialog-note {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

.dialog-footer .ghost {
  --shadow-hard: var(--bg-page-deep);
  border-color: var(--border-strong);
  color: var(--text-body);
}

/* ---- yeni sohbet ---- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 12px;
  border: 2px solid var(--ring);
  border-radius: var(--r-pill);
  background: var(--accent-solid);
  color: var(--cream-100);
  font-size: var(--fs-sm);
  font-weight: 700;
}

.chip span[aria-hidden] {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
}

.user-results {
  list-style: none;
  min-height: 120px;
  margin: 0 -6px;
  padding: 0;
  overflow-y: auto;
}

.user-results .note,
.invite-list .note {
  margin: var(--space-4) auto;
  padding: var(--space-3) var(--space-4) var(--space-2);
  max-width: 28ch;
  font-size: 1.25rem;
  rotate: -1deg;
  box-shadow: 0 3px 0 0 var(--note-shadow);
}

.user-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  text-align: left;
}

.user-option:hover {
  background: var(--bg-surface-alt);
}

.user-option .who {
  flex: 1;
  min-width: 0;
  display: grid;
}

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

.user-option small {
  color: var(--text-muted);
}

.check {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-strong);
  border-radius: 50%;
  color: transparent;
}

.check svg {
  width: 14px;
  height: 14px;
}

.user-option[aria-pressed='true'] .check {
  border-color: var(--ring);
  background: var(--accent-solid);
  color: var(--cream-100);
}

.group-title {
  display: grid;
  gap: var(--space-2);
  font-family: var(--font-label);
  font-size: 0.6875rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--text-muted);
}

.group-title input {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  letter-spacing: 0;
  text-transform: none;
}

/* ---- davetiyeler ---- */
.invite-list {
  list-style: none;
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.invite {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 2px solid var(--border-soft);
  border-radius: var(--r-md);
  background: var(--bg-surface-alt);
}

.invite.used {
  opacity: 0.7;
}

.invite-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.invite-code {
  color: var(--text-strong);
  font-family: var(--font-label);
  font-size: 1.0625rem;
  letter-spacing: 0.12em;
}

.invite-status {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.invite-link {
  padding: 6px 12px;
  font-size: var(--fs-sm);
}

.invite-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ---- profil ---- */
.profile-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.profile-card strong {
  font-size: 1.125rem;
}

.profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.check-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-solid);
}

.avatar-comment {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border: 2px solid var(--bubble-bot-edge);
  border-radius: var(--r-md);
  background: var(--bubble-bot-bg);
  color: var(--bubble-bot-ink);
  box-shadow: 0 3px 0 0 var(--bubble-bot-shadow);
  white-space: pre-wrap;
}

.avatar-comment-head {
  font-family: var(--font-label);
  font-size: 0.625rem;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
}

.offscreen {
  position: fixed;
  left: -9999px;
  opacity: 0;
}

/* ==========================================================================
   Mobil: tek panel
   ========================================================================== */

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

  .sidebar {
    border-right: 0;
  }

  .chat {
    display: none;
  }

  .app.show-chat .sidebar {
    display: none;
  }

  .app.show-chat .chat {
    display: flex;
  }

  .back-btn {
    display: inline-grid;
  }

  .messages {
    padding: var(--space-1) var(--space-3) var(--space-3);
  }

  .bubble {
    max-width: 86%;
  }

  .sidebar-header {
    gap: 6px;
  }

  .sidebar-header .icon-btn {
    width: 38px;
    height: 38px;
  }

  .composer {
    gap: 6px;
    padding-inline: var(--space-2);
  }

  .attach-btn,
  .summon-btn {
    width: 40px;
    height: 40px;
  }

  /* iOS'ta odaklanınca yakınlaştırmayı önler */
  input,
  textarea {
    font-size: 16px;
  }

  .auth-card {
    padding: var(--space-4);
  }
}

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