/* Satranç Portalı — Design Tokens
   Premium koyu (siyah + altın) / Açık (krem + walnut) çift tema. */

:root, .theme-dark {
  /* Surface */
  --bg:           #0d0d10;
  --bg-elev:      #14141a;
  --surface:      #1a1a21;
  --surface-2:    #21212a;
  --surface-3:    #2a2a34;
  --border:       #2a2a35;
  --border-soft:  #1f1f27;
  --border-strong:#3a3a48;

  /* Text */
  --text:         #ece7dc;
  --text-dim:     #a39c8e;
  --text-muted:   #6e685e;
  --text-faint:   #4a463e;

  /* Brand — gold */
  --gold:         #c9a961;
  --gold-bright:  #e6c478;
  --gold-dim:     #8a7a4a;
  --gold-soft:    rgba(201,169,97,.12);
  --gold-line:    rgba(201,169,97,.28);

  /* Semantic */
  --success:      #7ba572;
  --success-soft: rgba(123,165,114,.16);
  --error:        #c75c50;
  --error-soft:   rgba(199,92,80,.16);
  --warning:      #e0ad55;
  --warning-soft: rgba(224,173,85,.16);
  --info:         #7da0c4;
  --info-soft:    rgba(125,160,196,.16);

  /* Chess board */
  --sq-light:     #e9d5b0;
  --sq-dark:      #966a3f;
  --sq-light-hi:  #d8c47a;
  --sq-dark-hi:   #a87a44;
  --sq-coord:     rgba(43,28,16,.6);
  --sq-coord-on:  rgba(255,245,220,.6);

  /* Overlays */
  --shadow-sm:    0 1px 2px rgba(0,0,0,.4);
  --shadow:       0 4px 16px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg:    0 24px 60px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
  --shadow-gold:  0 0 0 1px var(--gold-line), 0 6px 24px rgba(201,169,97,.18);
}

.theme-light {
  --bg:           #f5efe2;
  --bg-elev:      #fbf6ea;
  --surface:      #ffffff;
  --surface-2:    #f1e9d6;
  --surface-3:    #e8dcc1;
  --border:       #d9cdb1;
  --border-soft:  #e7dcc4;
  --border-strong:#b89e6e;

  --text:         #2a2317;
  --text-dim:     #6a5f48;
  --text-muted:   #94886c;
  --text-faint:   #b8ab8b;

  --gold:         #a3863e;
  --gold-bright:  #c9a961;
  --gold-dim:     #7a6531;
  --gold-soft:    rgba(163,134,62,.10);
  --gold-line:    rgba(163,134,62,.32);

  --success:      #5a8456;
  --success-soft: rgba(90,132,86,.14);
  --error:        #a8463b;
  --error-soft:   rgba(168,70,59,.14);
  --warning:      #b8862f;
  --warning-soft: rgba(184,134,47,.14);
  --info:         #4a6f96;
  --info-soft:    rgba(74,111,150,.14);

  --shadow-sm:    0 1px 2px rgba(74,57,30,.10);
  --shadow:       0 6px 20px rgba(74,57,30,.10), 0 1px 2px rgba(74,57,30,.06);
  --shadow-lg:    0 24px 60px rgba(74,57,30,.22), 0 2px 8px rgba(74,57,30,.10);
  --shadow-gold:  0 0 0 1px var(--gold-line), 0 6px 24px rgba(163,134,62,.20);
}

/* Typography */
:root {
  --f-display: "Playfair Display", "Cormorant Garamond", Georgia, serif;
  --f-ui:      "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --f-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 22px;
}

/* Resets — scoped to the canvas world (kept narrow) */
.sx { font-family: var(--f-ui); color: var(--text); }
.sx, .sx *, .sx *::before, .sx *::after { box-sizing: border-box; }
.sx button { font-family: inherit; cursor: pointer; }
.sx input, .sx textarea { font-family: inherit; }
.sx h1, .sx h2, .sx h3, .sx h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.sx p { margin: 0; }

.sx .display { font-family: var(--f-display); font-weight: 500; letter-spacing: -.015em; }
.sx .mono    { font-family: var(--f-mono); }

/* The "frame" — full artboard surface */
.sx-frame {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-ui);
  font-size: 14px;
  overflow: hidden;
  position: relative;
}

/* Subtle paper grain in light mode, dust in dark */
.sx-frame::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 20% 30%, var(--text-faint) 50%, transparent 50%),
    radial-gradient(1px 1px at 70% 80%, var(--text-faint) 50%, transparent 50%),
    radial-gradient(1px 1px at 40% 60%, var(--text-faint) 50%, transparent 50%);
  background-size: 360px 360px, 480px 480px, 240px 240px;
  opacity: .25;
  mix-blend-mode: overlay;
}

/* ── Atomic UI primitives ─────────────────────────────────────── */
.sx .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.sx .panel-elev {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

.sx .btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  letter-spacing: .005em;
  transition: background .12s, border-color .12s, color .12s, transform .08s;
}
.sx .btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.sx .btn:active { transform: translateY(1px); }
.sx .btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--gold-dim);
  color: #1a1408;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 1px 2px rgba(0,0,0,.3);
}
.sx .btn-gold:hover { filter: brightness(1.06); border-color: var(--gold); }
.sx .btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.sx .btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.sx .btn-danger {
  background: var(--error-soft); border-color: rgba(199,92,80,.35); color: var(--error);
}
.sx .btn-danger:hover { background: rgba(199,92,80,.22); }
.sx .btn-sm { padding: 6px 10px; font-size: 12px; }
.sx .btn-lg { padding: 12px 18px; font-size: 14px; }

.sx .icon-btn {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: transparent; color: var(--text-dim);
}
.sx .icon-btn:hover { background: var(--surface-2); color: var(--text); }

.sx .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px; font-weight: 500;
  color: var(--text-dim);
  letter-spacing: .01em;
}
.sx .chip-gold {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: var(--gold-bright);
}
.theme-light .sx .chip-gold { color: var(--gold-dim); }
.sx .chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.sx .kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  font-family: var(--f-mono);
  font-size: 10.5px;
  color: var(--text-dim);
}

.sx .input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .12s, background .12s;
}
.sx .input:focus { border-color: var(--gold-line); background: var(--surface); }
.sx textarea.input { resize: vertical; min-height: 60px; line-height: 1.5; }
.sx select.input {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 32px; cursor: pointer;
}

/* Form field + label */
.sx .field-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 6px;
}
.sx .field-label .muted { color: var(--text-muted); font-weight: 400; }
.sx .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sx .form-grid .col-full { grid-column: 1 / -1; }
@media (max-width: 640px) { .sx .form-grid { grid-template-columns: 1fr; } }
.sx .check-row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--r);
  border: 1px solid var(--border-soft); margin-bottom: 6px;
  font-size: 13px; cursor: pointer;
}
.sx .check-row:hover { background: var(--surface-2); }
.sx .check-row input { accent-color: var(--gold); width: 15px; height: 15px; }

/* Data table */
.sx .data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sx .data-table th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.sx .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
.sx .data-table tbody tr:last-child td { border-bottom: 0; }
.sx .data-table tbody tr:hover td { background: var(--surface-2); }
.sx .data-table .t-center { text-align: center; }
.sx .data-table .t-right { text-align: right; }
.sx .data-table .t-muted { color: var(--text-muted); }
.sx .data-table .empty-row td { text-align: center; color: var(--text-muted); padding: 32px 14px; }

/* Pagination bar */
.sx .pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border-soft);
}
.sx .pagination-bar .page-info { font-size: 12px; color: var(--text-dim); font-family: var(--f-mono); }
.sx .pagination-bar .btn.is-disabled { opacity: .4; pointer-events: none; }

/* Range / segment tabs */
.sx .range-tabs {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 999px; margin-bottom: 18px;
}
.sx .range-tab {
  padding: 6px 14px; font-size: 12.5px; font-weight: 500;
  color: var(--text-dim); text-decoration: none; border-radius: 999px;
  transition: background .12s, color .12s;
}
.sx .range-tab:hover { color: var(--text); }
.sx .range-tab.is-active {
  background: var(--gold-soft); color: var(--gold-bright);
  border: 1px solid var(--gold-line);
  padding: 5px 13px;
}
.theme-light .sx .range-tab.is-active { color: var(--gold-dim); }

/* Combobox (typeahead) */
.sx .sx-combobox { position: relative; }
.sx .sx-combobox-wrap { position: relative; }
.sx .sx-combobox-display {
  width: 100%; padding: 9px 12px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sx .sx-combobox-display:hover { border-color: var(--border-strong); }
.sx .sx-combobox-display.has-value { color: var(--text); }
.sx .sx-combobox-display [data-cb-clear] {
  background: transparent; border: 0; color: var(--text-muted);
  cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px;
}
.sx .sx-combobox-display [data-cb-clear]:hover { color: var(--error); }
.sx .sx-combobox-popup {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); box-shadow: var(--shadow);
  z-index: 50; padding: 8px;
}
.sx .sx-combobox-popup .input { margin-bottom: 6px; }
.sx .sx-combobox-results { max-height: 260px; overflow-y: auto; }
.sx .sx-combobox-hint { padding: 12px 8px; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.sx .sx-combobox-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 6px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text); font-family: inherit; font-size: 13px;
}
.sx .sx-combobox-item:hover { background: var(--surface-2); }
.sx .sx-combobox-item .sx-combobox-sub {
  display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 2px;
}

/* Confirm modal (sx) */
.sx .sx-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  opacity: 0; transition: opacity .15s;
}
.sx .sx-modal-overlay.open { display: flex; opacity: 1; }
.sx .sx-modal {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  transform: translateY(8px); transition: transform .15s;
}
.sx .sx-modal-overlay.open .sx-modal { transform: translateY(0); }
.sx .sx-modal h3 {
  font-family: var(--f-display); font-size: 18px;
  margin: 0 0 8px; color: var(--text);
}
.sx .sx-modal p { color: var(--text-dim); font-size: 13.5px; line-height: 1.55; margin: 0 0 18px; }
.sx .sx-modal .sx-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Platform link chips (Lichess, Chess.com) */
.sx .platform-link {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 14px; border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px; text-decoration: none;
  transition: background .12s, border-color .12s, transform .12s;
}
.sx .platform-link:hover { background: var(--surface-2); border-color: var(--border-strong); transform: translateY(-1px); }
.sx .platform-link > svg:last-child { color: var(--text-muted); }
.sx .platform-link--lichess { border-left: 3px solid #e8e8e8; }
.sx .platform-link--lichess > svg:first-child { color: #d6d6d6; }
.theme-light .sx .platform-link--lichess { border-left-color: #2c2c2c; }
.theme-light .sx .platform-link--lichess > svg:first-child { color: #2c2c2c; }
.sx .platform-link--chesscom { border-left: 3px solid #81b64c; }
.sx .platform-link--chesscom > svg:first-child { color: #81b64c; }

/* Liste içi kompakt platform ikonları */
.sx .platform-icons { display: inline-flex; gap: 6px; align-items: center; }
.sx .platform-icon {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 24px; padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  color: var(--text-dim); text-decoration: none;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.sx .platform-icon:hover { background: var(--bg-elev); border-color: var(--border-strong); color: var(--text); }
.sx .platform-icon--lichess { color: #cfcfcf; }
.theme-light .sx .platform-icon--lichess { color: #2c2c2c; }
.sx .platform-icon--chesscom { color: #81b64c; }

/* Desktop ≥1024px: pill + metin. Aşağıda: ikon-only kare */
@media (max-width: 1023px) {
  .sx .platform-icon { width: 26px; padding: 0; border-radius: 6px; }
  .sx .platform-icon-text { display: none; }
}

/* Status toggle pill (aktif/pasif) */
.sx .status-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-dim); font-size: 12px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, opacity .12s;
}
.sx .status-toggle .status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted);
}
.sx .status-toggle.is-on { color: var(--success); background: var(--success-soft); border-color: rgba(123,165,114,.32); }
.sx .status-toggle.is-on .status-dot { background: var(--success); }
.sx .status-toggle.is-off { color: var(--text-muted); }
.sx .status-toggle:hover { filter: brightness(1.05); }
.sx .status-toggle[disabled] { opacity: .5; cursor: wait; }

/* Roster search box */
.sx .roster-search {
  display: flex; align-items: center; gap: 9px;
  position: relative; max-width: 420px;
  color: var(--text-muted);
}
.sx .roster-search > svg { flex-shrink: 0; }
.sx .roster-search .input { flex: 1; }
.sx .roster-spinner {
  width: 15px; height: 15px; flex-shrink: 0;
  border: 2px solid var(--border-strong); border-top-color: var(--gold);
  border-radius: 50%; opacity: 0; transition: opacity .12s;
}
.sx .roster-spinner.on { opacity: 1; animation: roster-spin .6s linear infinite; }
@keyframes roster-spin { to { transform: rotate(360deg); } }

.sx .divider { height: 1px; background: var(--border); margin: 12px 0; }

/* Eyebrow text */
.sx .eyebrow {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted);
}

.sx .gold-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-line) 20%, var(--gold-line) 80%, transparent);
}

/* Scrollbars (scoped) */
.sx .scroll { overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.sx .scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.sx .scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Headerbar shared style */
.sx .topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

/* Tab-strip */
.sx .tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.sx .tab {
  padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500;
  color: var(--text-dim); background: transparent; border: 0;
}
.sx .tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.theme-light .sx .tab.active { box-shadow: 0 1px 2px rgba(74,57,30,.08); }
.sx .tab-gold.active { color: var(--gold-bright); background: var(--gold-soft); }
.theme-light .sx .tab-gold.active { color: var(--gold-dim); }

/* Avatar */
.sx .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #1a1408;
  border: 1px solid var(--gold-line);
  flex: 0 0 auto;
}

/* Progress */
.sx .progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; position: relative; border: 1px solid var(--border-soft); }
.sx .progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); border-radius: inherit; }

/* Logo */
.sx .logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--f-display);
  font-size: 19px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -.005em;
}
.sx .logo-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background:
    linear-gradient(135deg, #1a1207 0%, #2a1d0e 100%),
    var(--gold);
  border: 1px solid var(--gold-line);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--gold-bright); font-size: 18px; line-height: 1;
}
.theme-light .sx .logo-mark { background: linear-gradient(135deg, #2a1d0e 0%, #3a2615 100%); }

/* Generic helpers */
.sx .stack { display: flex; flex-direction: column; }
.sx .row   { display: flex; align-items: center; }
.sx .grow  { flex: 1 1 auto; min-width: 0; }
.sx .gap-1 { gap: 4px; }
.sx .gap-2 { gap: 8px; }
.sx .gap-3 { gap: 12px; }
.sx .gap-4 { gap: 16px; }
.sx .gap-6 { gap: 24px; }
.sx .gap-8 { gap: 32px; }

/* Card */
.sx .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  transition: border-color .12s, transform .15s, box-shadow .15s;
}
.sx .card-hover:hover { border-color: var(--gold-line); transform: translateY(-1px); box-shadow: var(--shadow); }

/* "Tournament plaque" — gold-bordered emphasis surface */
.sx .plaque {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--gold-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-gold);
}
