:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --accent: #34c759;
  --accent2: #0a84ff;
  --danger: #ff3b30;
  --line: #e5e5ea;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --card: #1c1c1e; --text: #ffffff;
    --muted: #8e8e93; --line: #38383a;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
body.blurred .screen { filter: blur(22px); transition: filter .15s; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ---- app bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--line);
}
.appbar h1 { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -.5px; }
.appbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---- market ---- */
#market { padding-bottom: 150px; }
#market-body, .setup-body { padding: 10px 12px; }

/* kategori kutuları (home) */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.cat-tile {
  position: relative; background: var(--card); border: none;
  border-radius: 16px; padding: 18px 14px; text-align: left;
  cursor: pointer; font-family: inherit; color: var(--text);
  display: flex; flex-direction: column; gap: 4px;
  transition: transform .08s; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.cat-tile:active { transform: scale(.97); }
.cat-tile-emoji { font-size: 32px; }
.cat-tile-name { font-size: 15px; font-weight: 700; }
.cat-tile-meta { font-size: 12px; color: var(--muted); }
.cat-tile-badge {
  position: absolute; top: 12px; right: 12px; min-width: 22px; height: 22px;
  padding: 0 6px; background: var(--accent); color: #fff; border-radius: 11px;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* listelerim girişi */
.lists-entry {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: var(--card); border: none; border-radius: 16px;
  padding: 16px 14px; margin-bottom: 14px; cursor: pointer;
  font-family: inherit; color: var(--text); text-align: left;
}
.lists-entry:active { transform: scale(.98); }
.lists-entry-ico { font-size: 24px; }
.lists-entry-mid { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.lists-entry-name { font-size: 16px; font-weight: 700; }
.lists-entry-sub { font-size: 12px; color: var(--muted); }
.lists-entry-arrow { color: var(--muted); font-size: 22px; }

/* liste kartları */
.new-list-btn {
  width: 100%; background: var(--card); border: none; border-radius: 14px;
  padding: 14px; margin-bottom: 12px; font-size: 15px; font-weight: 600;
  color: var(--accent); cursor: pointer; font-family: inherit;
}
.list-cards { display: flex; flex-direction: column; gap: 10px; }
.list-card {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: var(--card); border: none; border-radius: 14px;
  padding: 14px; cursor: pointer; font-family: inherit; color: var(--text); text-align: left;
}
.list-card-mid { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.list-card-name { font-size: 16px; font-weight: 600; }
.list-card-meta { font-size: 12px; color: var(--muted); }

.list-head { padding: 4px 4px 14px; }
.list-head-name { font-size: 24px; font-weight: 800; }
.list-head-date { font-size: 13px; color: var(--muted); margin-top: 4px; }
.list-items { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 12px; padding: 8px 12px;
}
.list-item-ico { width: 40px; height: 40px; flex-shrink: 0; }
.list-item-ico svg { width: 100%; height: 100%; display: block; }
.list-item-mid { flex: 1; }
.list-item-name { font-size: 15px; font-weight: 600; }
.list-item-cat { font-size: 12px; color: var(--muted); }
.list-item-rm {
  background: none; border: none; color: var(--muted);
  font-size: 16px; padding: 8px; cursor: pointer;
}
.del-list-btn {
  width: 100%; margin-top: 20px; background: none; border: none;
  color: var(--danger); font-size: 15px; font-weight: 600;
  padding: 14px; cursor: pointer; font-family: inherit;
}

/* alt panel (listeye ekle) */
.sheet-ov {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(16px + var(--safe-bottom));
  max-height: 80vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.sheet-title { font-size: 14px; color: var(--muted); text-align: center; padding-bottom: 6px; }
.sheet-row {
  width: 100%; text-align: left; background: var(--card); border: none;
  border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 600;
  color: var(--text); cursor: pointer; font-family: inherit;
}
.sheet-new { color: var(--accent); }
.sheet-cancel {
  width: 100%; background: var(--card); border: none; border-radius: 12px;
  padding: 14px; margin-top: 6px; font-size: 16px; font-weight: 600;
  color: var(--muted); cursor: pointer; font-family: inherit;
}

/* kategori içi gezinme başlığı */
.nav-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.back-btn {
  background: var(--card); border: none; border-radius: 10px; padding: 8px 14px;
  font-size: 15px; font-weight: 600; color: var(--accent2); cursor: pointer; font-family: inherit;
}
.nav-cat-title { font-size: 18px; font-weight: 800; }

/* ürün ızgarası */
.prod-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.prod-card {
  position: relative; background: var(--card); border: none;
  border-radius: var(--radius); padding: 10px 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; transition: transform .08s, box-shadow .15s;
  color: var(--text); font-family: inherit;
}
.prod-card:active { transform: scale(.95); }
.prod-ico { width: 60px; height: 60px; }
.prod-ico svg { width: 100%; height: 100%; display: block; }
.prod-name { font-size: 12px; text-align: center; color: var(--text); line-height: 1.2; }
.prod-card.selected { box-shadow: inset 0 0 0 2.5px var(--accent); }
.prod-card.selected::after {
  content: "✓"; position: absolute; top: 6px; right: 6px;
  width: 20px; height: 20px; background: var(--accent); color: #fff;
  border-radius: 50%; font-size: 13px; display: flex;
  align-items: center; justify-content: center; font-weight: 700;
}

/* ---- sepet barı ---- */
#cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--line);
  transform: translateY(120%); transition: transform .25s;
  display: flex; gap: 10px; align-items: center;
}
#cart-bar.show { transform: translateY(0); }
.cart-info { flex: 1; font-size: 15px; font-weight: 600; }
#cart-count { color: var(--accent); }
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  border-radius: 12px; padding: 12px 20px; font-size: 16px;
  font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-primary:disabled { opacity: .4; }
.btn-ghost {
  background: transparent; color: var(--muted); border: none;
  font-size: 15px; cursor: pointer; font-family: inherit; padding: 8px;
}

/* ---- kurulum ---- */
#setup { padding-bottom: 90px; }
.setup-head { padding: calc(var(--safe-top) + 24px) 16px 6px; }
.setup-head h2 { font-size: 22px; font-weight: 800; margin: 0 0 6px; }
.setup-desc { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.4; }
.setup-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 95%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: .5px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.setup-counter { flex: 1; color: var(--muted); font-size: 14px; }
.setup-footer .btn-primary { min-width: 120px; }

/* ---- kasa ---- */
#vault { padding-bottom: 120px; }
.vault-top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: .5px solid var(--line);
}
.vault-title { font-size: 20px; font-weight: 800; }
.icon-btn {
  background: var(--card); border: none; width: 40px; height: 40px;
  border-radius: 50%; font-size: 18px; cursor: pointer;
}
.vault-tabs { display: flex; gap: 6px; padding: 12px 16px 4px; }
.tab {
  flex: 1; padding: 8px; border: none; background: var(--card);
  border-radius: 10px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; font-family: inherit;
}
.tab.active { background: var(--accent2); color: #fff; }

.media-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px;
  padding: 8px 6px;
}
@media (min-width: 500px) { .media-grid { grid-template-columns: repeat(4, 1fr); } }
.media-cell {
  position: relative; aspect-ratio: 1; background: var(--card);
  border-radius: 4px; overflow: hidden; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.media-cell img { width: 100%; height: 100%; object-fit: cover; }
.media-cell.is-note { padding: 8px; }
.note-preview { font-size: 11px; color: var(--text); overflow: hidden; }
.media-cell.picked { outline: 3px solid var(--accent2); outline-offset: -3px; }
.pick-dot { display: none; }
.media-cell.picked .pick-dot {
  display: block; position: absolute; top: 6px; right: 6px;
  width: 20px; height: 20px; background: var(--accent2); border-radius: 50%;
  border: 2px solid #fff;
}
.badge-type {
  position: absolute; bottom: 6px; left: 6px; color: #fff;
  font-size: 16px; text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.file-ico { font-size: 34px; }
.file-name { position: absolute; bottom: 4px; left: 4px; right: 4px;
  font-size: 9px; color: var(--muted); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 15px; }

/* ---- fab ---- */
.fab {
  position: fixed; right: 18px; bottom: calc(24px + var(--safe-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 30px; font-weight: 300;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 25;
}
.fab-note {
  bottom: calc(92px + var(--safe-bottom)); background: var(--accent2);
  font-size: 22px; width: 50px; height: 50px; right: 22px;
}

/* ---- seçim barı ---- */
.sel-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: color-mix(in srgb, var(--card) 95%, transparent);
  backdrop-filter: blur(20px); border-top: .5px solid var(--line);
  transform: translateY(130%); transition: transform .2s;
}
.sel-bar.show { transform: translateY(0); }
.sel-count { font-size: 13px; color: var(--muted); display: block; margin-bottom: 6px; }
.sel-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sel-act {
  flex: 1; min-width: 70px; padding: 10px 6px; border: none;
  background: var(--bg); border-radius: 10px; font-size: 13px;
  font-weight: 600; cursor: pointer; color: var(--text); font-family: inherit;
}

/* ---- viewer ---- */
#viewer {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.95);
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 10px) 10px calc(var(--safe-bottom) + 10px);
}
#viewer.show { display: flex; }
.viewer-media { max-width: 100%; max-height: 80vh; border-radius: 8px; }
.viewer-close {
  position: absolute; top: calc(var(--safe-top) + 14px); right: 16px;
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.2); color: #fff; font-size: 18px; cursor: pointer;
}
.viewer-dl {
  margin-top: 18px; color: #fff; background: var(--accent2);
  padding: 12px 22px; border-radius: 12px; text-decoration: none;
  font-weight: 700; font-size: 15px;
}
.note-full { background: var(--card); color: var(--text); border-radius: 14px; padding: 20px;
  max-width: 100%; max-height: 74vh; overflow: auto; transform-origin: center; }
.note-text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: 16px; line-height: 1.5; }

/* yakınlaştırma alanı */
.zoom-wrap { width: 100%; max-height: 80vh; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.zoom-wrap img, .zoom-wrap video { transform-origin: center; transition: transform .05s; will-change: transform; }
.viewer-pdf { width: 100%; height: 78vh; border: none; border-radius: 8px; background: #fff; }

/* not editörü */
.note-editor { width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--card); border-radius: 14px; overflow: hidden; }
.note-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: .5px solid var(--line); }
.note-ta {
  flex: 1; width: 100%; border: none; outline: none; resize: none;
  padding: 16px; font-size: 16px; line-height: 1.5; font-family: inherit;
  background: var(--card); color: var(--text);
  white-space: pre-wrap; overflow-wrap: anywhere; word-wrap: break-word;
}
.file-box { color: #fff; text-align: center; }
.file-ico-lg { font-size: 70px; margin-bottom: 10px; }

/* ---- storage ---- */
.storage-info { text-align: center; color: var(--muted); font-size: 12px; padding: 16px; }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px;
  border-radius: 20px; font-size: 14px; z-index: 60; opacity: 0;
  transition: opacity .2s, transform .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
