/* Forum sayfasi, dikey telefon (360-430 px). Sade surum: Claude Design tasarimi gelince Frontend yeniden
   giydirir. Renkler oyunun koyu kahve/altin havasinda; yazi sistem fontu (CSP disaridan font almaz).
   Satir ici stil yok (CSP); boyut degisimi yalniz JS'ten element.style ile. */

:root {
  --bg: #120d09;
  --surface: #1c1510;
  --surface-2: #261c14;
  --border: #3b2c1f;
  --text: #efe5d3;
  --muted: #a8977f;
  --gold: #d4a64a;
  --gold-strong: #f0c76a;
  --on-gold: #1a1108;
  --danger: #d9634f;
  --warn: #caa040;
  --focus: #f0c76a;
  --radius: 12px;
  --tap: 44px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}

body.sheet-open { overflow: hidden; }

a { color: var(--gold-strong); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; user-select: all; -webkit-user-select: all; }
.small { font-size: 14px; }

/* --- Ust cubuk --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(52px + var(--safe-top));
  padding: var(--safe-top) calc(6px + var(--safe-right)) 0 calc(6px + var(--safe-left));
  background: rgba(18, 13, 9, 0.96);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  flex: 1; min-width: 0; padding: 0 6px;
  font-size: 18px; font-weight: 650; color: var(--gold-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title:focus { outline: none; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
/* Oturumsuz ekranda yalniz kapat dugmesi kalir. */
body.gated .gate-hide { display: none; }

.icon-btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text);
  cursor: pointer; text-decoration: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn[hidden] { display: none; }
.icon { width: 22px; height: 22px; }
.bell-count {
  position: absolute; top: 5px; right: 3px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.bell-count[hidden] { display: none; }

/* --- Ekran govdesi --- */
.view {
  display: flex; flex-direction: column; gap: 12px;
  max-width: 640px; margin: 0 auto;
  padding: 12px calc(12px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(12px + var(--safe-left));
}
.view:focus { outline: none; }
.view-topic { padding-bottom: 0; }

.state { padding: 24px 8px; text-align: center; color: var(--muted); }
.state.error { color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 12px; }

.card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.card-title { font-size: 16px; color: var(--gold); }
.card h3 { font-size: 15px; color: var(--gold); }
.gate { margin-top: 24px; text-align: center; align-items: center; gap: 14px; }
.gate h2 { font-size: 20px; color: var(--gold-strong); }
.intro { display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; }
.intro h2 { font-size: 22px; color: var(--gold-strong); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.form { gap: 8px; }

.section-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.section-head.end { justify-content: flex-end; }
.section-head:empty { display: none; }
.section-text { flex: 1; font-size: 14px; }
.more { display: flex; justify-content: center; }
.more:empty { display: none; }

/* --- Dugmeler --- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:active { filter: brightness(1.15); }
.button:disabled { opacity: 0.55; cursor: default; }
.button.primary { background: var(--gold); border-color: var(--gold); color: var(--on-gold); }
.button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.button.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.button.wide { width: 100%; }
.button.active { border-color: var(--gold); color: var(--gold-strong); }
.button.load-more { width: 100%; }
.button .icon { width: 18px; height: 18px; }
.button-row { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.link { color: var(--gold-strong); }

/* --- Listeler --- */
.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list:empty { display: none; }
.list.compact { border: 0; background: transparent; }
.list > .state { border: 0; }
.row {
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; width: 100%; padding: 12px 14px;
  border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text);
  font: inherit; text-align: left; text-decoration: none;
}
.row:last-child { border-bottom: 0; }
a.row:active, button.row:active { background: var(--surface-2); }
.row.muted { color: var(--muted); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 600; }
.row-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; color: var(--muted); font-size: 14px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chevron { color: var(--muted); font-size: 22px; }
.sep { color: var(--border); }
.topic-row .row-title { font-size: 16px; }
.list.compact .row { padding: 10px 0; }

.notif-row { align-items: flex-start; cursor: pointer; }
.notif-row .dot { flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: transparent; }
.notif-row.unread .dot { background: var(--gold); }
.notif-row:not(.unread) .row-title { font-weight: 500; color: var(--muted); }
.link-row { padding: 10px 0; min-height: var(--tap); border: 0; }

/* --- Isaretler, yazar, rozet --- */
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.chip-staff { border-color: var(--gold); color: var(--gold-strong); }
.chip-pin { border-color: #7a6a3a; color: #e8d39a; }
.chip-lock { color: var(--muted); }
.chip-warn { border-color: var(--warn); color: var(--warn); }

.author { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.author .nickname { font-weight: 650; color: var(--text); }
.author.compact .nickname { font-weight: 500; color: var(--muted); }
.badge-line { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.empire-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); }
.empire-red { background: #d0453a; }
.empire-yellow { background: #e0b928; }
.empire-blue { background: #3d82d6; }
.post-head .author { flex-direction: column; align-items: flex-start; gap: 1px; }
.post-head .author .nickname + .chip { margin-top: 2px; }

/* --- Konu --- */
.topic-head { display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 4px; }
.topic-title { font-size: 20px; color: var(--gold-strong); }
.topic-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }

.posts { display: flex; flex-direction: column; gap: 10px; }
.post {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.post.official { border-color: #6b5326; }
.post.mine { background: #211910; }
.post-placeholder { padding: 10px 14px; gap: 6px; background: transparent; border-style: dashed; font-size: 14px; }
.post-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.post-side { display: flex; align-items: center; gap: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }
.post-menu { width: 40px; height: 40px; margin: -8px -10px -8px 0; }
.post-body { white-space: pre-wrap; word-break: break-word; }
.post-foot { display: flex; gap: 8px; color: var(--muted); font-size: 12px; }
.post-placeholder .post-foot { justify-content: flex-end; }

.banner { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: 14px; }
.banner .button { align-self: flex-start; }
.banner-warn { border-color: #6d5a26; }
.banner-danger { border-color: var(--danger); }
.banner-muted { color: var(--muted); }

/* Cevap kutusu ekranin altina yapisir; klavye acilinca WebView gorunur alani kucultur, kutu ustunde kalir. */
.reply-area {
  position: sticky; bottom: 0; z-index: 5;
  margin: 0 calc(-12px - var(--safe-right)) 0 calc(-12px - var(--safe-left));
  padding: 8px calc(12px + var(--safe-right)) calc(8px + var(--safe-bottom)) calc(12px + var(--safe-left));
  background: rgba(18, 13, 9, 0.97); border-top: 1px solid var(--border);
}
.reply-area:empty { display: none; }
.reply-bar { display: flex; flex-direction: column; gap: 4px; }
.reply-bar.disabled .banner { background: transparent; }
.reply-row { display: flex; align-items: flex-end; gap: 8px; }
.reply-input { flex: 1; min-height: var(--tap); max-height: 200px; resize: none; }
.reply-foot { display: flex; justify-content: flex-end; }
.send { width: var(--tap); padding: 0; flex: none; }
.counter { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); font-weight: 700; }

.edit-form { display: flex; flex-direction: column; gap: 8px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* --- Formlar --- */
.label { font-size: 14px; font-weight: 600; color: var(--muted); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; }
.input {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #0d0906; color: var(--text);
  font: inherit; font-size: 16px; /* 16 px alti iOS'ta odakta yakinlastirir */
}
.input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 2px rgba(212, 166, 74, 0.35); }
.input:disabled { opacity: 0.6; }
textarea.input { resize: vertical; line-height: 1.4; }
select.input { appearance: none; -webkit-appearance: none; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }
.inline-form { display: flex; flex-direction: column; gap: 6px; }
.form-error { color: var(--danger); font-size: 14px; font-weight: 600; }
.form-error[hidden] { display: none; }

.choices { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; border: 0; }
.choices legend { margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.choice, .check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.choice input, .check input { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--gold); }
.choice-text { display: flex; align-items: center; gap: 6px; }
.check { padding-top: 4px; font-weight: 600; }

/* Anahtar: gercek checkbox gorunmez ama odaklanir ve ekran okuyucu "switch" olarak okur. */
.switch-row { display: flex; flex-direction: column; gap: 4px; }
.switch { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; cursor: pointer; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui { flex: none; position: relative; width: 48px; height: 28px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); transition: background 0.15s; }
.switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 0.15s; }
.switch input:checked + .switch-ui { background: var(--gold); border-color: var(--gold); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); background: var(--on-gold); }
.switch input:focus-visible + .switch-ui { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-ui { opacity: 0.6; }

/* --- Kurallar --- */
.rules { display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.rules-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.rules h3 { margin-top: 4px; }
.rules-box { max-height: 40vh; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #0d0906; }

/* --- Alt pencere (menu, onay, sikayet) --- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.sheet {
  width: 100%; max-width: 640px; max-height: 85vh; overflow-y: auto;
  padding: 6px calc(14px + var(--safe-right)) calc(14px + var(--safe-bottom)) calc(14px + var(--safe-left));
  border-radius: 16px 16px 0 0; border: 1px solid var(--border); border-bottom: 0; background: var(--surface);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-title { font-size: 17px; color: var(--gold-strong); padding-left: 2px; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }
.sheet-text { color: var(--text); }
.sheet-form { display: flex; flex-direction: column; gap: 8px; }
.menu-list { display: flex; flex-direction: column; }
.menu-item {
  min-height: 52px; padding: 0 6px; border: 0; border-bottom: 1px solid var(--border); background: transparent;
  color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item.danger { color: var(--danger); }

/* --- Bilgi satiri --- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); z-index: 60;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: #2c2117; color: var(--text); font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.toast[hidden] { display: none; }
