:root {
  --bg: #0b0f1a;
  --bg-2: #121829;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f2f4f8;
  --muted: #9aa3b8;
  --red: #e30a17;
  --red-2: #ff4d57;
  --gold: #f5b942;
  --teal: #2ec4b6;
  --violet: #8b7cf6;
  --card-bg: linear-gradient(160deg, #ffffff 0%, #f6f7fb 100%);
  --card-text: #1e2738;
  --radius: 26px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.22, .9, .3, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: currentColor; }

.bg-glow {
  position: fixed; inset: -20% -20% auto -20%; height: 70vh; z-index: -1;
  background:
    radial-gradient(40% 50% at 20% 30%, rgba(227, 10, 23, .35), transparent 70%),
    radial-gradient(35% 45% at 85% 20%, rgba(139, 124, 246, .22), transparent 70%),
    radial-gradient(40% 40% at 60% 80%, rgba(46, 196, 182, .12), transparent 70%);
  filter: blur(30px);
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translate3d(0, 4%, 0) scale(1.05); } }

/* Üst çubuk */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 8px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--red), #a5000c);
  box-shadow: 0 8px 24px rgba(227, 10, 23, .45), inset 0 1px 0 rgba(255,255,255,.25);
}
.brand-mark svg { fill: #fff; width: 26px; height: 26px; }
h1 { font-family: 'Poppins', sans-serif; font-size: 1.15rem; margin: 0; letter-spacing: -.01em; }
.subtitle { margin: 0; font-size: .75rem; color: var(--muted); }

.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  transition: background .2s, transform .15s, color .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn[aria-pressed="true"] { background: var(--gold); color: #1b1300; border-color: transparent; }

/* Kategori çipleri */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 18px 6px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start;
  padding: 8px 14px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  transition: all .25s var(--ease); white-space: nowrap;
}
.chip .n { opacity: .6; font-weight: 500; margin-left: 4px; }
.chip.active {
  background: linear-gradient(135deg, var(--red), var(--red-2)); color: #fff; border-color: transparent;
  box-shadow: 0 6px 18px rgba(227, 10, 23, .35);
}

/* İlerleme */
.progress-wrap { display: flex; align-items: center; gap: 12px; padding: 8px 18px 0; }
.progress { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-bar {
  height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width .4s var(--ease);
}
.counter { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }

/* Kart sahnesi */
.stage {
  position: relative; flex: 1; margin: 14px 18px 6px; min-height: 0;
  perspective: 1400px; touch-action: pan-y;
}
.card {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  background: var(--card-bg); color: var(--card-text);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.06);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: 50% 110%;
  transition: transform .45s var(--ease), opacity .45s var(--ease);
  user-select: none; -webkit-user-select: none;
  will-change: transform;
}
.card.behind { transform: translateY(14px) scale(.95); opacity: .55; pointer-events: none; }
.card.behind-2 { transform: translateY(26px) scale(.9); opacity: .25; pointer-events: none; }
.card.dragging { transition: none; }

.card-head {
  background: linear-gradient(135deg, var(--red) 0%, #b8000f 100%);
  color: #fff; padding: 16px 22px; font-family: 'Poppins', sans-serif;
  font-weight: 700; font-size: .82rem; letter-spacing: .03em; text-transform: uppercase;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.card-head .num { opacity: .8; font-weight: 600; font-variant-numeric: tabular-nums; }

.card-body { flex: 1; padding: 22px 22px 18px; display: flex; flex-direction: column; overflow-y: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tag {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 6px 12px; border-radius: 999px; background: #fde8ea; color: var(--red);
}
.tag.src-asistan { background: #ede9fe; color: #5b45d6; }
.tag.src-kullanici { background: #d9f6f2; color: #0f8a7e; }

.card-title {
  font-family: 'Poppins', sans-serif; font-weight: 800;
  font-size: clamp(1.9rem, 8.5vw, 2.8rem); line-height: 1.08; letter-spacing: -.02em;
  margin: 0 0 16px; word-break: break-word;
}
.card-desc { font-size: 1.08rem; line-height: 1.6; color: #34405a; margin: 0; transition: filter .35s, opacity .35s; }
.card.hidden-answer .card-desc { filter: blur(9px); opacity: .5; }
.reveal-hint {
  display: none; margin-top: 14px; font-size: .8rem; font-weight: 600; color: var(--red);
}
.card.hidden-answer .reveal-hint { display: block; }

.card-note {
  margin-top: auto; padding-top: 16px; font-size: .78rem; color: #6b7590;
  display: flex; gap: 8px; align-items: flex-start;
}
.card-note::before { content: '✎'; color: #8b7cf6; }

.card-foot {
  border-top: 1px solid #e7e9f0; padding: 12px 22px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: .75rem; color: #8a93a8;
}

/* Kaydırma etiketleri */
.swipe-label {
  position: absolute; top: 72px; padding: 6px 14px; border-radius: 10px;
  font-family: 'Poppins', sans-serif; font-weight: 800; font-size: .9rem; letter-spacing: .05em;
  opacity: 0; border: 3px solid; pointer-events: none; text-transform: uppercase;
}
.swipe-label.next { right: 18px; color: var(--teal); transform: rotate(10deg); }
.swipe-label.prev { left: 18px; color: var(--violet); transform: rotate(-10deg); }

.empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); border: 2px dashed var(--border); border-radius: var(--radius);
}

.hint { text-align: center; color: var(--muted); font-size: .78rem; margin: 2px 0 0; transition: opacity .6s; }
.hint.fade { opacity: 0; }

/* Kontroller */
.controls {
  display: flex; justify-content: center; align-items: center; gap: 12px;
  padding: 12px 18px calc(16px + var(--safe-b));
}
.ctrl {
  width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .15s var(--ease), background .2s;
}
.ctrl:hover { background: var(--surface-2); }
.ctrl:active { transform: scale(.9); }
.ctrl-primary {
  width: 62px; height: 62px; border-radius: 22px; border: 0;
  background: linear-gradient(135deg, var(--red), var(--red-2));
  box-shadow: 0 10px 28px rgba(227, 10, 23, .5);
}
.ctrl-primary svg { width: 28px; height: 28px; }

/* Alt panel */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(5, 8, 15, .6); backdrop-filter: blur(4px);
  z-index: 20; animation: fade .25s;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-height: 92dvh; overflow-y: auto;
  background: linear-gradient(180deg, #1a2136, #121829);
  border-top: 1px solid var(--border);
  border-radius: 28px 28px 0 0; padding: 10px 20px calc(20px + var(--safe-b));
  transform: translateY(105%); transition: transform .4s var(--ease);
  max-width: 640px; margin: 0 auto;
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 44px; height: 5px; border-radius: 9px; background: var(--surface-2); margin: 4px auto 14px; }
.sheet h2 { font-family: 'Poppins', sans-serif; margin: 0 0 14px; font-size: 1.25rem; }
form label { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 13px 14px;
  font: 500 16px 'Inter', sans-serif; color: var(--text);
  background: rgba(255,255,255,.05); border: 1px solid var(--border); border-radius: 14px;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
select option { background: #121829; }
input:focus, textarea:focus, select:focus { border-color: var(--red-2); box-shadow: 0 0 0 3px rgba(255, 77, 87, .2); }
textarea { resize: vertical; min-height: 96px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-msg { min-height: 1.2em; font-size: .82rem; color: var(--red-2); margin: 2px 0 10px; }
.sheet-actions { display: flex; gap: 10px; }
.btn { flex: 1; padding: 14px; border-radius: 14px; font-weight: 700; transition: transform .15s, opacity .2s; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--surface); border: 1px solid var(--border); }
.btn.primary { background: linear-gradient(135deg, var(--red), var(--red-2)); color: #fff; box-shadow: 0 8px 22px rgba(227,10,23,.4); }
.btn:disabled { opacity: .6; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #fff; color: #111; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: .88rem;
  box-shadow: 0 12px 30px rgba(0,0,0,.4); transition: all .35s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Masaüstü */
@media (min-width: 720px) {
  body { align-items: center; }
  .topbar, .chips, .progress-wrap, .controls { width: 100%; max-width: 560px; }
  .stage { width: calc(100% - 36px); max-width: 524px; max-height: 620px; }
}
@media (max-height: 640px) {
  .card-title { font-size: 1.8rem; }
  .card-desc { font-size: 1rem; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
