/* Windows'taki kutuphanenin (ui/style.css) iPad hali: dokunmatik, guvenli alanlar, Safari 17 uyumlu */
:root {
  --bg: #12151b;
  --bg-2: #171b22;
  --panel: #1d222b;
  --panel-2: #242a35;
  --line: #2c3340;
  --text: #e8ebf0;
  --muted: #8a93a3;
  --accent: #e07a55;
  --accent-2: #f0a07a;
  --good: #5cc98a;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
img { -webkit-user-drag: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
/* 16px'ten kucuk yazili kutulara dokununca iOS sayfayi yakinlastirir */
input { font: inherit; font-size: 16px; color: var(--text); -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.shell { display: grid; grid-template-columns: 250px 1fr; height: 100%; }

/* ---------- Kenar cubugu ---------- */
.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: calc(18px + var(--safe-top)) 14px calc(14px + var(--safe-bottom)) calc(14px + var(--safe-left));
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand img { width: 32px; height: 32px; }

.search { position: relative; margin-bottom: 14px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 17px; height: 17px; pointer-events: none; }
.search input {
  width: 100%; padding: 10px 12px 10px 38px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-decoration { -webkit-appearance: none; }
.search input:focus { border-color: var(--accent); }

nav { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); padding: 18px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px;
  padding: 10px 12px; border-radius: 10px; text-align: left; color: #c3c9d4;
}
.nav-item:active { background: var(--panel); }
.nav-item.on { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item .count { margin-left: auto; font-size: 13px; color: var(--muted); }
.nav-item svg { width: 17px; height: 17px; }

.side-foot { padding: 12px 8px 0; border-top: 1px solid var(--line); }
.status { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------- Ana alan ---------- */
.main {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: calc(26px + var(--safe-top)) calc(30px + var(--safe-right)) calc(40px + var(--safe-bottom)) 30px;
  min-width: 0;
}
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 20px; margin-bottom: 22px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: 28px; font-weight: 700; }
.top p { margin: 2px 0 0; }
.top-actions { display: flex; gap: 12px; align-items: center; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; margin: 0 0 12px; }

.primary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; font-weight: 600;
}
.primary { background: var(--accent); color: #fff; }
.ghost { background: var(--panel); border: 1px solid var(--line); color: #c3c9d4; font-weight: 500; }
.primary:active, .ghost:active { filter: brightness(.9); transform: scale(.98); }

.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { min-height: 38px; padding: 7px 14px; border-radius: 7px; color: var(--muted); font-size: 14px; }
.seg button.on { background: var(--panel-2); color: var(--text); }

/* ---------- Kuruluma davet (Safari'de, ana ekrana eklenmemisken) ---------- */
.hint {
  display: flex; align-items: center; gap: 12px; margin-bottom: 22px; padding: 12px 10px 12px 14px;
  background: rgba(224, 122, 85, .12); border: 1px solid rgba(224, 122, 85, .4); border-radius: 12px; color: #f3d5c8;
}
.hint .share { width: 24px; height: 24px; color: var(--accent-2); }
.hint div { flex: 1; }
.hint-close { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); flex: none; }

/* ---------- Son acilanlar ---------- */
.recent-wrap { margin-bottom: 30px; }
.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.recent .cover { aspect-ratio: 16 / 7; }

/* ---------- Kartlar ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 18px; }
.card {
  position: relative; border-radius: var(--radius); background: var(--panel);
  overflow: hidden; cursor: pointer; text-align: left;
  border: 1px solid var(--line);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  display: flex; flex-direction: column;
  -webkit-touch-callout: none;
}
.card:active { transform: scale(.97); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cover { position: relative; aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; }
.cover .bg-img { position: absolute; inset: -20px; background-size: cover; background-position: center; filter: blur(22px) saturate(1.4) brightness(.65); }
.cover .icon { position: relative; width: 44%; max-width: 110px; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0,0,0,.45)); }
.recent .cover .icon { width: 26%; max-width: 90px; }
.cover .letter { position: relative; font-size: 54px; font-weight: 800; color: rgba(255,255,255,.95); text-shadow: 0 6px 20px rgba(0,0,0,.3); }
.play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(10,12,16,.45); opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.play span {
  display: inline-flex; align-items: center; gap: 8px; background: var(--accent); color: #fff;
  font-weight: 700; padding: 9px 18px; border-radius: 999px; box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
.play svg { fill: currentColor; stroke: none; width: 14px; height: 14px; }

.info { padding: 11px 13px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 30px; }
.meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 30px; }
.desc { font-size: 12.5px; color: #a9b1bf; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.badge, .kind {
  position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 700;
  background: rgba(10,12,16,.7); padding: 3px 8px; border-radius: 999px; display: flex; align-items: center; gap: 6px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); }
.kind { padding: 5px; color: #c3c9d4; }
.kind svg { width: 14px; height: 14px; }
.badge + .kind { display: none; }

.star, .more {
  position: absolute; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: rgba(10,12,16,.55); color: #fff; transition: opacity .15s ease;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.star { top: 7px; right: 7px; opacity: 0; pointer-events: none; }
.star svg, .more svg { width: 17px; height: 17px; }
.star.on { opacity: 1; pointer-events: auto; color: #ffcf5a; }
.star.on svg { fill: currentColor; }
.more { bottom: 6px; right: 5px; background: transparent; color: var(--muted); -webkit-backdrop-filter: none; backdrop-filter: none; }
.more:active { color: var(--text); background: var(--panel-2); }

/* Fare / trackpad varsa Windows'taki gibi ustune gelince goster */
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { background: var(--panel); color: var(--text); }
  .primary:hover { background: #ea8a66; }
  .ghost:hover { border-color: #3d4656; color: var(--text); }
  .card:hover { transform: translateY(-3px); border-color: #3d4656; box-shadow: 0 14px 30px rgba(0,0,0,.45); }
  .card:hover .play { opacity: 1; }
  .card:hover .star { opacity: 1; pointer-events: auto; }
  .more:hover { color: var(--text); background: var(--panel-2); }
}

/* ---------- Bos durum ---------- */
.empty { border: 1px dashed var(--line); border-radius: 16px; padding: 60px 30px; text-align: center; color: var(--muted); }
.empty img { width: 64px; opacity: .9; margin-bottom: 14px; }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 19px; }
.empty p { margin: 0 auto 20px; max-width: 440px; }

/* ---------- Menu ---------- */
.menu {
  position: fixed; z-index: 30; min-width: 210px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 5px; box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.menu button { display: flex; width: 100%; gap: 12px; align-items: center; min-height: 44px; padding: 10px 12px; border-radius: 8px; text-align: left; }
.menu button:active { background: var(--line); }
.menu button.danger { color: #ff8b80; }
.menu svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) { .menu button:hover { background: var(--line); } }

/* ---------- Form (klavye acilinca kapanmasin diye ustte durur) ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 40; background: rgba(5,7,10,.65);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  display: flex; justify-content: center; align-items: flex-start;
  padding: calc(8vh + var(--safe-top)) 20px 20px;
}
.modal {
  width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 30px 70px rgba(0,0,0,.6);
}
.modal h3 { margin: 0 0 4px; font-size: 20px; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.modal input {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; outline: none; width: 100%;
  -webkit-appearance: none; appearance: none;
}
.modal input:focus { border-color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.err { color: #ff8b80; margin: 0; font-size: 13px; }

/* ---------- Acik uygulama ---------- */
.runner { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; }
.runner-bar {
  flex: none; display: flex; align-items: center; gap: 8px;
  height: calc(46px + var(--safe-top));
  padding: var(--safe-top) calc(6px + var(--safe-right)) 0 calc(6px + var(--safe-left));
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.runner-bar button { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 6px 12px; border-radius: 9px; color: var(--accent-2); font-weight: 600; }
.runner-bar button:active { background: var(--panel); }
.runner-title { flex: 1; text-align: center; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.runner-body { position: relative; flex: 1; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; }
.runner-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--bg); }

.toast {
  position: fixed; bottom: calc(24px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); z-index: 70;
  background: var(--panel-2); border: 1px solid var(--line); padding: 11px 18px; border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5); max-width: calc(100% - 32px); text-align: center;
}

/* ---------- Dar ekran: Split View / Slide Over ---------- */
@media (max-width: 739px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side {
    border-right: 0; border-bottom: 1px solid var(--line);
    display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 12px;
    padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  }
  .brand { padding: 0; font-size: 17px; }
  .brand img { width: 28px; height: 28px; }
  .search { margin: 0; }
  nav { grid-column: 1 / -1; display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
  nav::-webkit-scrollbar { display: none; }
  .nav-label, .side-foot { display: none; }
  .nav-item { width: auto; flex: none; min-height: 38px; padding: 7px 14px; border-radius: 999px; background: var(--panel); white-space: nowrap; }
  .nav-item.on { background: var(--accent); color: #fff; box-shadow: none; }
  .nav-item.on .count { color: rgba(255,255,255,.8); }
  .main { padding: 18px calc(16px + var(--safe-right)) calc(30px + var(--safe-bottom)) calc(16px + var(--safe-left)); }
  .top h1 { font-size: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
}
@media (max-width: 520px) {
  #btnAdd span { display: none; }
  #btnAdd { padding: 10px 12px; }
  .seg button { padding: 7px 10px; }
}
