:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #16161a;
  --muted: #6b6b76;
  --line: #e4e4ea;
  --accent: #d6336c;
  --accent-2: #f76707;
  --ok: #2b8a3e;
  --warn: #e8590c;
  --err: #c92a2a;
  --chip: #f0f0f4;
  --radius: 14px;
  --grad: linear-gradient(135deg, #7048e8 0%, #d6336c 55%, #f76707 100%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e11;
    --card: #18181d;
    --text: #f1f1f4;
    --muted: #9a9aa6;
    --line: #2a2a32;
    --chip: #24242b;
    --ok: #51cf66;
    --err: #ff6b6b;
    --warn: #ff922b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.error-text { color: var(--err); font-size: 14px; min-height: 1em; }
a { color: var(--accent); }

/* Üst bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--grad); position: relative; margin: 0 auto; }
.logo-mark::after { content: ""; position: absolute; inset: 30%; border: 3px solid #fff; border-radius: 50%; }
.logo-mark.small { width: 24px; height: 24px; border-radius: 7px; margin: 0; }
.logo-mark.small::after { border-width: 2px; }
.tabs { display: flex; gap: 4px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 8px 12px 10px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 15px;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a.active { color: var(--text); border-color: var(--accent); }

main { max-width: 680px; margin: 0 auto; padding: 16px 16px 120px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.page-head { margin-bottom: 12px; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 8px; }

/* Butonlar */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--chip); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 15px;
  cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--grad); color: #fff; border: 0; }
.btn.danger { color: var(--err); }
.btn.block { width: 100%; }
.btn.big { padding: 15px; font-size: 17px; border-radius: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 4px; }

input[type=password], input[type=text], input[type=search], input[type=datetime-local], textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin: 6px 0;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: transparent; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent); margin-top: 12px; }

/* Çipler */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--chip); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
#scheduleAt { margin-top: 12px; }

/* Medya */
.media-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 12px; }
.media-list:empty { display: none; }
.media-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--chip); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .idx { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.media-item .tag { position: absolute; bottom: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 1px 6px; }
.media-item .ctrl { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; }
.media-item .ctrl button {
  width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff;
  font-size: 14px; line-height: 1; cursor: pointer; padding: 0;
}
.media-item.loading { display: grid; place-items: center; color: var(--muted); font-size: 13px; }

/* Hesap seçimi */
.accounts-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.acc {
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--bg); cursor: pointer; font: inherit; color: var(--text); text-align: left;
}
.acc.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--grad); flex: none; }
.acc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
.per-acc label { display: block; font-weight: 600; font-size: 14px; margin-top: 10px; }

.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.submit-bar .btn { max-width: 648px; margin: 0 auto; display: flex; }

/* Liste */
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .avatar { width: 42px; height: 42px; }

.post { padding: 14px; }
.post-top { display: flex; gap: 12px; }
.thumbs { display: flex; gap: 4px; flex: none; }
.thumbs img, .thumbs video { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--chip); }
.post-cap { font-size: 14px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-wrap; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--chip); }
.badge.done { color: var(--ok); }
.badge.failed { color: var(--err); }
.badge.partial { color: var(--warn); }
.badge.scheduled, .badge.processing { color: #4c6ef5; }
.targets { margin: 10px 0 0; padding: 0; list-style: none; font-size: 14px; }
.targets li { padding: 4px 0; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.targets .err { color: var(--err); font-size: 13px; width: 100%; padding-left: 22px; }
.post-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.post-actions .btn { padding: 7px 12px; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.banner { background: color-mix(in srgb, var(--warn) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.ok-text { color: var(--ok); font-weight: 600; }
code { background: var(--chip); padding: 1px 5px; border-radius: 5px; font-size: 13px; word-break: break-all; }

/* Giriş */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-box {
  background: var(--card); width: 100%; max-width: 680px; height: 88vh; border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .modal { align-items: center; } .modal-box { border-radius: 18px; height: 80vh; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; align-content: start; padding: 4px 0; }
.drive-item { position: relative; border-radius: 10px; overflow: hidden; background: var(--chip); aspect-ratio: 1; cursor: pointer; border: 2px solid transparent; }
.drive-item.sel { border-color: var(--accent); }
.drive-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drive-item .name { position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.7)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drive-item.folder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 8px; text-align: center; }
.drive-item.folder .name { position: static; background: none; color: var(--text); white-space: normal; font-size: 12px; font-weight: 600; }
.drive-item .check { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; display: none; place-items: center; }
.drive-item.sel .check { display: grid; }
.folder-icon { width: 42px; height: 32px; background: #fab005; border-radius: 4px 4px 6px 6px; position: relative; }
.folder-icon::before { content: ""; position: absolute; top: -6px; left: 0; width: 18px; height: 8px; background: #fab005; border-radius: 3px 3px 0 0; }
.modal-foot { padding-top: 10px; }
.link-more { margin: 6px auto; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  z-index: 100; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.toast.err { background: var(--err); color: #fff; }
