:root {
  --bg: #ffffff;
  --text: #111111;
  --muted: #6b6b6b;
  --line: #e8e8e8;
  --line-strong: #d4d4d4;
  --soft: #f5f5f5;
  --danger: #c62828;
  --radius: 12px;
  --top: 60px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button { font: inherit; color: inherit; }
a { color: inherit; }

svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.boot { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }

/* ---------- Form elemanları ---------- */

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 12px 14px; resize: none; line-height: 1.45; }
.input:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(0, 0, 0, .08); }
.input::placeholder { color: #9a9a9a; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; font-weight: 600; }

.checkbox { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; }
.checkbox input { width: 18px; height: 18px; accent-color: #111; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: #111; border-color: #111; color: #fff; }
.btn-primary:hover { background: #333; border-color: #333; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a61f1f; border-color: #a61f1f; }
.btn-ghost-danger { border-color: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: #fdf1f1; }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn-square { width: 46px; padding: 0; flex: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn.danger:hover { background: #fdf1f1; color: var(--danger); }

.form-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdf1f1;
  color: var(--danger);
  font-size: 14px;
  white-space: pre-line;
}

.logo-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #111;
  color: #fff;
}
.logo-mark svg { width: 30px; height: 30px; stroke-width: 2.6; }
.logo-mark.small { width: 34px; height: 34px; border-radius: 9px; }
.logo-mark.small svg { width: 20px; height: 20px; }

.progress { display: block; height: 4px; border-radius: 4px; background: #ececec; overflow: hidden; }
.progress > span { display: block; width: 0; height: 100%; border-radius: inherit; background: #111; transition: width .25s ease; }

.empty { margin: 32px 0; text-align: center; color: var(--muted); }

/* ---------- Giriş ---------- */

.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin: 20px 0 6px; font-size: 26px; }
.auth-card > p { margin: 0 0 24px; }
.auth-card .btn-block { margin-top: 6px; }

/* ---------- Uygulama çerçevesi ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--top);
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 17px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}
.account-btn:hover { background: var(--soft); }
.account-name { font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  flex: none;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.lists-pane { padding: 20px; }
.items-pane { padding: 24px 32px 64px; min-width: 0; }

.pane-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.pane-head h2 { font-size: 20px; }

.add-row { display: flex; gap: 8px; }

/* ---------- Listeler ---------- */

.lists { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list-link {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  cursor: pointer;
}
.list-link:hover { background: var(--soft); }
.list-link.active { background: var(--soft); border-color: var(--line-strong); }
.list-link-main { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.list-link-name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.list-link-count { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.list-link.complete .list-link-count { color: var(--text); font-weight: 600; }

/* ---------- Liste detayı ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 50vh;
  color: var(--muted);
  text-align: center;
}
.empty-state svg { width: 40px; height: 40px; stroke-width: 1.6; }

.list-head { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 18px; }
.list-title-wrap { flex: 1; min-width: 0; padding-top: 4px; }
.list-title-wrap h2 { font-size: 26px; overflow-wrap: anywhere; }
.progress-line { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.progress-line .progress { flex: 1; max-width: 260px; }
.back-btn { display: none; margin-left: -8px; }

.sticky-add { margin-bottom: 14px; }

.items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.item { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); transition: background .12s; }
@media (hover: hover) { .item:hover { background: #fafafa; } }

.check {
  display: grid;
  place-items: center;
  width: 54px;
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.check svg {
  width: 26px;
  height: 26px;
  padding: 3px;
  border: 2px solid #111;
  border-radius: 8px;
  stroke: transparent;
  stroke-width: 3;
  transition: background .15s, stroke .15s;
}
@media (hover: hover) { .check:hover svg { stroke: #c4c4c4; } }
.item.done .check svg { background: #111; stroke: #fff; }

.item-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 15px 14px 15px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.item-text { font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.item.done .item-text { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: #111; }
.item-ek { font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ---------- Diyaloglar ---------- */

dialog.dialog {
  width: min(440px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .22);
  overflow: hidden;
}
dialog.dialog::backdrop { background: rgba(0, 0, 0, .38); }
dialog.dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }

.dialog-body { padding: 22px 20px 20px; max-height: calc(100dvh - 48px); overflow-y: auto; }
.dialog-body h3 { font-size: 19px; margin-bottom: 8px; }
.dialog-body > p { margin: 0 0 18px; white-space: pre-line; }
.dialog-body > .input { margin: 10px 0 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

dialog.dialog-sheet { width: min(640px, calc(100vw - 32px)); }
.sheet { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 20px; }
.sheet-head h3 { flex: 1; font-size: 17px; }
.sheet-grip { display: none; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; overscroll-behavior: contain; }
.sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); padding-bottom: max(12px, env(safe-area-inset-bottom)); }

.item-edit { font-size: 17px; font-weight: 600; min-height: 52px; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.item-meta { margin: 12px 0 16px; display: flex; flex-direction: column; gap: 2px; }
.status-btn.is-done { background: #111; border-color: #111; color: #fff; }
.status-btn.is-done:hover { background: #333; }

.section-title { display: flex; align-items: baseline; gap: 8px; margin: 26px 0 10px; font-size: 15px; }

.files { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 8px 10px 12px; border-top: 1px solid var(--line); }
.file:first-child { border-top: 0; }
.file-ext {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  overflow: hidden;
}
.file-info { flex: 1; min-width: 0; }
.file-name { display: block; font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-name:hover { text-decoration: underline; }
.file-sub { font-size: 12.5px; color: var(--muted); }
.files-empty { padding: 16px; margin: 0; text-align: center; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); }

.dropzone {
  margin-top: 12px;
  padding: 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  transition: background .15s, border-color .15s;
}
.dropzone.drag { border-color: #111; background: var(--soft); }
.drop-hint { margin: 8px 0 0; }
@media (hover: none) { .drop-hint .drag-text { display: none; } }
.upload-progress { margin-top: 12px; text-align: left; }
.upload-progress .progress { height: 6px; margin-bottom: 6px; }
.upload-row { display: flex; align-items: center; gap: 8px; }
.upload-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.storage { display: flex; gap: 10px; margin-bottom: 12px; }
.storage-box { flex: 1; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.storage-box strong { display: block; font-size: 18px; }
.backup-hint { margin: 8px 0 0; }

.notify-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 6px 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--soft);
}
.notify-banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14px; line-height: 1.35; }
.notify-banner-text span { color: var(--muted); font-size: 13px; }
.notify-status { margin: 16px 0 6px; }
.notify-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.notify-error { margin: 14px 0 0; }
.notify-diag { margin-top: 18px; font-size: 13px; }
.notify-diag summary { cursor: pointer; color: var(--muted); }
.notify-diag pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  font: 12px/1.5 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.account-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.account-head .avatar { width: 44px; height: 44px; font-size: 18px; }
.menu { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.menu-item { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 16px; border: 0; border-top: 1px solid var(--line); background: #fff; text-align: left; font-weight: 600; cursor: pointer; }
.menu-item:first-child { border-top: 0; }
.menu-item:hover { background: var(--soft); }
.menu-item.danger { color: var(--danger); }

.users { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-row .avatar { width: 32px; height: 32px; font-size: 13px; }
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; padding: 1px 8px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--text); }
.user-form { display: grid; gap: 10px; margin-top: 10px; }

/* ---------- Bildirimler ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(420px, calc(100vw - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 11px 16px;
  border-radius: 10px;
  background: #111;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  white-space: pre-line;
  animation: toast-in .2s ease-out;
  transition: opacity .3s, transform .3s;
}
.toast.error { background: var(--danger); }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Masaüstü: sabit yükseklikte iki panel ---------- */

@media (min-width: 860px) {
  .app { display: flex; flex-direction: column; height: 100dvh; }
  .layout { flex: 1; min-height: 0; }
  .lists-pane { overflow-y: auto; border-right: 1px solid var(--line); }
  .items-pane { overflow-y: auto; }
  .sticky-add { position: sticky; top: -24px; z-index: 2; margin: 0 -8px 14px; padding: 8px; background: #fff; }
}

/* ---------- Telefon / tablet ---------- */

@media (max-width: 859px) {
  :root { --top: 56px; }
  .topbar { padding: 0 12px 0 16px; padding-top: env(safe-area-inset-top); height: calc(var(--top) + env(safe-area-inset-top)); }
  .layout { grid-template-columns: 1fr; }
  .lists-pane { padding: 16px; }
  .items-pane { display: none; padding: 10px 16px 48px; }
  body.show-list .lists-pane { display: none; }
  body.show-list .items-pane { display: block; }
  .back-btn { display: inline-grid; }
  .list-title-wrap h2 { font-size: 21px; }
  .list-link { border-color: var(--line); padding: 14px; }
  .sticky-add { position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); z-index: 5; margin: 0 -16px 10px; padding: 8px 16px 10px; background: #fff; }
  .check { width: 50px; }
}

@media (max-width: 599px) {
  .account-name { display: none; }
  .account-btn { padding: 0 4px; border: 0; }
  dialog.dialog-sheet {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }
  dialog.dialog-sheet[open] { animation: sheet-up .22s ease-out; }
  .sheet { max-height: 92dvh; }
  .sheet-grip { display: block; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: #d9d9d9; }
  .sheet-head { position: relative; padding: 18px 8px 8px 16px; }
  .sheet-body { padding: 4px 16px 18px; }
  .sheet-foot { padding-left: 16px; padding-right: 16px; }
  .file-dl-text { display: none; }
  .file .btn-sm { width: 40px; padding: 0; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
