:root {
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFAFB;
  --field: #FBFBFC;
  --text: #14161B;
  --text-2: #3A3F4A;
  --muted: #5B6270;
  --placeholder: #7A8190;
  --border: #E1E4E9;
  --border-strong: #D5D9E0;
  --hairline: #EEF0F3;
  --chip: #EEF0F3;
  --seg-bg: #EEF0F3;
  --seg-selected: #FFFFFF;
  --accent: #2747D9;
  --accent-hover: #1F3BBD;
  --on-accent: #FFFFFF;
  --ink: #14161B;
  --on-ink: #FFFFFF;
  --code-bg: #14161B;
  --code-text: #E6E8EC;
  --link: #2747D9;
  --link-hover: #1A33A8;
  --warn-bg: #FFF6E5;
  --warn-border: #F0D49B;
  --warn-text: #6B4A00;
  --danger: #C2281D;
  --danger-bg: #FDF0EF;
  --danger-border: #F1C4C0;
  --danger-text: #8E1C14;
  --shadow-selected: 0 1px 3px rgb(20 22 27 / 0.12);
  --shadow-card: 0 1px 2px rgb(20 22 27 / 0.04);

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F1115;
    --surface: #171A20;
    --surface-2: #1B1F26;
    --field: #0F1115;
    --text: #ECEEF2;
    --text-2: #C9CDD5;
    --muted: #A3A9B5;
    --placeholder: #8A919E;
    --border: #262A33;
    --border-strong: #333844;
    --hairline: #22262E;
    --chip: #262A33;
    --seg-bg: #0F1115;
    --seg-selected: #262A33;
    --accent: #8FA4FF;
    --accent-hover: #A9B9FF;
    --on-accent: #0B0E1A;
    --ink: #ECEEF2;
    --on-ink: #0F1115;
    --code-bg: #0B0D11;
    --code-text: #E6E8EC;
    --link: #8FA4FF;
    --link-hover: #B7C4FF;
    --warn-bg: #2E2410;
    --warn-border: #5A4615;
    --warn-text: #F2D08A;
    --danger: #FF8A80;
    --danger-bg: #2E1513;
    --danger-border: #5C2420;
    --danger-text: #FFB4AB;
    --shadow-selected: none;
    --shadow-card: none;
    color-scheme: dark;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.normal { font-weight: 400; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

main { display: flex; flex-direction: column; gap: 28px; }

.icon { display: inline-flex; flex: none; }

/* ---------- Başlık ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand h1 { margin: 0; font-size: 30px; line-height: 1.15; }
.lead { margin: 4px 0 0; color: var(--muted); }

.brand-mark {
  width: 48px;
  height: 48px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: var(--on-ink);
}

.platform-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.platform-chips li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Kart ve form ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}

.form-card { padding: 28px; display: flex; flex-direction: column; gap: 24px; }

.form-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.mode-hint { margin: 0; font-size: 14px; max-width: 460px; }

.segmented {
  display: inline-flex;
  gap: 4px;
  margin: 0;
  padding: 4px;
  border: 0;
  border-radius: 12px;
  background: var(--seg-bg);
}
.segmented label { position: relative; cursor: pointer; }
.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.segmented label > span,
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: 500 14px var(--font-body);
  cursor: pointer;
}
.segmented input:checked + span,
.segmented button[aria-pressed="true"] {
  background: var(--seg-selected);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-selected);
}
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented-sm { padding: 3px; gap: 2px; border-radius: 10px; }
.segmented-sm button { min-height: 38px; padding: 0 14px; border-radius: 8px; font-size: 13px; }

.panel { display: flex; flex-direction: column; gap: 20px; }

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }

.input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--field);
  color: var(--text);
  font-size: 14px;
}
textarea.input { padding: 14px; line-height: 1.7; resize: vertical; }
.input::placeholder { color: var(--placeholder); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input[aria-invalid="true"] { border: 1.5px solid var(--danger); }

.count-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

.stepper {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--field);
}
.stepper-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.stepper-btn:disabled { color: var(--placeholder); cursor: not-allowed; }
.stepper-value {
  width: 48px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.stepper-value::-webkit-inner-spin-button,
.stepper-value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.detect { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 24px; font-size: 13px; }
.detect strong { font-weight: 600; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--chip);
}
.chip-warn { background: var(--warn-bg); color: var(--warn-text); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--hairline);
}
.form-actions p { margin: 0; }

/* ---------- Düğmeler ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  font: 600 14px var(--font-body);
  cursor: pointer;
}
.btn-primary { min-height: 48px; padding: 0 22px; font-size: 15px; background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.75; cursor: progress; }
.btn-ink { background: var(--ink); color: var(--on-ink); }

.spinner { display: none; animation: spin 0.9s linear infinite; }
.is-loading .spinner { display: block; }
.is-loading .btn-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Uyarılar ---------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 14px;
}
.alert svg { flex: none; margin-top: 2px; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); white-space: pre-line; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.alert ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.alert strong { font-weight: 600; }

/* ---------- Boş / yükleniyor ---------- */
.state-card { padding: 32px; }
.empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  border-style: dashed;
  border-color: var(--border-strong);
  box-shadow: none;
}
.empty-card h2 { margin: 0; font-size: 18px; }
.empty-card p { margin: 0; max-width: 360px; font-size: 14px; }
.empty-card strong { color: var(--text); font-weight: 600; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--chip);
  color: var(--muted);
}

.loading-card { display: flex; flex-direction: column; gap: 18px; }
.loading-card p { margin: 0; }
.skeleton { display: grid; gap: 10px; }
.skeleton span { height: 14px; border-radius: 7px; background: var(--chip); animation: pulse 1.4s ease-in-out infinite; }
.skeleton span:nth-child(1) { width: 92%; }
.skeleton span:nth-child(2) { width: 78%; }
.skeleton span:nth-child(3) { width: 86%; }
.skeleton span:nth-child(4) { width: 64%; }
@keyframes pulse { 50% { opacity: 0.45; } }
.elapsed { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  .spinner, .skeleton span { animation: none; }
}

/* ---------- Sonuç ---------- */
.result { display: flex; flex-direction: column; gap: 16px; }
.result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.result-head h2 { margin: 0; font-size: 22px; }
.result-head p { margin: 2px 0 0; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0;
}
.stat {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.stat dt { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat dd {
  margin: 4px 0 0;
  font: 600 28px/1.2 var(--font-display);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
table { width: 100%; min-width: 820px; border-collapse: collapse; font-size: 14px; }
th {
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}
td { padding: 14px 16px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-family: var(--font-mono); font-weight: 500; font-variant-numeric: tabular-nums; }
th.num { font-family: var(--font-body); font-weight: 600; }
.nowrap { white-space: nowrap; }
.date { color: var(--text-2); font: 13px var(--font-mono); white-space: nowrap; }

.platform-cell { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.platform-badge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--chip);
}

.video-cell { max-width: 340px; }
.video-title { display: block; font-weight: 500; color: var(--link); }
.video-host {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font: 12px var(--font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cards { display: none; margin: 0; padding: 0; list-style: none; }
.result-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.result-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.result-card-top .chip { font-weight: 500; }
.result-card .video-title { line-height: 1.35; font-weight: 600; color: var(--text); }
.result-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.result-card-metrics dt { color: var(--muted); font-size: 11px; }
.result-card-metrics dd { margin: 0; font: 500 15px var(--font-mono); }
.result-card-channel { font-size: 13px; }

.code {
  margin: 0;
  padding: 20px 22px;
  overflow-x: auto;
  border-radius: 16px;
  background: var(--code-bg);
  color: var(--code-text);
  font: 13px/1.7 var(--font-mono);
  white-space: pre;
}

.result > p { margin: 0; }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Telefon ---------- */
@media (max-width: 640px) {
  .page { padding: 28px 16px 40px; gap: 20px; }
  main { gap: 20px; }
  .brand h1 { font-size: 22px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 10px; }
  .lead { font-size: 13px; }
  .platform-chips { display: none; }
  .form-card { padding: 18px; gap: 16px; }
  .segmented:not(.segmented-sm) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .segmented:not(.segmented-sm) label > span { width: 100%; justify-content: center; }
  .btn-primary { width: 100%; }
  .form-actions { padding-top: 16px; }
  .form-actions p { text-align: center; width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 12px; }
  .stat dd { font-size: 20px; }
  .table-wrap { display: none; }
  .cards { display: grid; gap: 12px; }
  .state-card { padding: 24px; }
}
