:root {
  --bg: #ffffff;
  --surface: #f6f5f2;
  --tile: #ecebe7;
  --line: #e5e3de;
  --text: #1f2421;
  --muted: #6f736f;
  --accent: #efeeec;
  --accent-text: #37352f;
  --accent-line: #dcdad6;
  --chip-on: #e6e5e2;
  --shadow: 0 10px 40px rgba(20, 30, 25, 0.18);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --surface: #222222;
    --tile: #2a2a2a;
    --line: #333333;
    --text: #ebebea;
    --muted: #9b9b98;
    --accent: #2f2f2f;
    --accent-text: #ebebea;
    --accent-line: #3d3d3d;
    --chip-on: #373737;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
button { font: inherit; color: inherit; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.app { max-width: 620px; margin: 0 auto; padding: 0 0 24px; }

/* Werkbalk */
.toolbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar-group[hidden] { display: none; }
.status-text { margin-left: auto; color: var(--muted); font-size: 12px; }
.btn { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border: 1px solid var(--line); background: var(--bg); border-radius: 8px; cursor: pointer; font-size: 13px; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface); }
.btn-dark { background: var(--accent); border-color: var(--accent-line); color: var(--accent-text); font-weight: 500; }
.btn-dark:hover { background: var(--chip-on); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 30px; padding: 0; justify-content: center; }
.dot { position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%; background: #c0573d; }
.drag-hint { color: var(--muted); font-size: 12px; margin-right: 4px; }
.is-spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Filters */
.filters { padding: 12px; border-bottom: 1px solid var(--line); background: var(--surface); display: grid; gap: 10px; }
.filter-row { display: flex; gap: 10px; align-items: flex-start; }
.filter-label { width: 64px; flex: none; color: var(--muted); font-size: 12px; padding-top: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 26px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 12px; }
.chip.is-on { background: var(--chip-on); border-color: var(--muted); color: var(--text); font-weight: 500; }
.link-btn { justify-self: start; background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 12px; }

.notice { margin: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; }
.notice.is-error { border-color: #e2b4a8; background: #fbf0ec; color: #7a2e1d; }
@media (prefers-color-scheme: dark) { .notice.is-error { background: #3a2420; border-color: #6b3a2f; color: #f2c4b8; } }

/* Profielkop */
.profile { display: grid; grid-template-columns: auto 1fr; gap: 6px 20px; padding: 18px 16px 12px; align-items: center; }
.avatar { width: 76px; height: 76px; border-radius: 50%; background: var(--tile) center/cover no-repeat; display: grid; place-items: center; font-size: 26px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); }
.handle { font-size: 17px; font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.stats { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text); font-weight: 600; }
.profile-text { grid-column: 1 / -1; font-size: 13px; }
.name { font-weight: 600; }
.bio { white-space: pre-line; }
.plink { color: #3b5b8a; text-decoration: none; font-weight: 500; }
@media (prefers-color-scheme: dark) { .plink { color: #a9c2e6; } }

/* Highlights */
.highlights { grid-column: 1 / -1; display: flex; gap: 14px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.highlights::-webkit-scrollbar { display: none; }
.hl { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.hl-ring { width: 62px; height: 62px; border-radius: 50%; padding: 3px; border: 1px solid var(--line); display: block; background: var(--bg); }
.hl-img { width: 100%; height: 100%; border-radius: 50%; display: block; background: var(--tile) center/cover no-repeat; }
.hl-title { font-size: 11.5px; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Tabs */
.tabs { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.tab { height: 42px; border: 0; background: none; cursor: pointer; color: var(--muted); border-top: 1px solid transparent; margin-top: -1px; }
.tab svg { width: 20px; height: 20px; stroke-width: 1.6; }
.tab.is-active { color: var(--text); border-top-color: var(--text); }

/* Raster */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.tile { position: relative; aspect-ratio: 4 / 5; border: 0; padding: 0; background: var(--tile); overflow: hidden; cursor: pointer; display: block; width: 100%; }
.grid.is-reels .tile { aspect-ratio: 9 / 16; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tile .ph { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 10px; text-align: center; color: var(--muted); font-size: 11px; }
.tile .ph strong { color: var(--text); font-weight: 500; font-size: 12px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.tile .badges { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.tile .badges svg { width: 15px; height: 15px; stroke: #fff; filter: drop-shadow(0 0 2px rgba(0,0,0,.6)); }
.tile .ph ~ .badges svg { stroke: var(--muted); filter: none; }
.tile .date { position: absolute; left: 6px; bottom: 6px; padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.5); color: #fff; font-size: 10.5px; opacity: 0; transition: opacity .15s; }
.tile:hover .date, .tile:focus-visible .date, .grid.is-dragging .date { opacity: 1; }
.tile .ph ~ .date { display: none; }
.tile:focus-visible { outline: 2px solid var(--muted); outline-offset: -2px; }
.grid.is-dragging .tile:not(.locked) { cursor: grab; }
.grid.is-dragging .tile:not(.locked)::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--muted); opacity: .35; }
.grid.is-dragging .tile.locked { opacity: .55; cursor: not-allowed; }
.sortable-ghost { opacity: .3; }
.sortable-chosen { transform: scale(.97); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.skeleton { aspect-ratio: 4 / 5; background: var(--tile); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* Detail */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.modal-card { position: relative; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 6px; right: 8px; z-index: 2; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.modal-media { position: relative; background: #000; aspect-ratio: 4 / 5; }
.modal-media.is-reel { aspect-ratio: 9 / 16; max-height: 70vh; margin: 0 auto; }
.modal-media img, .modal-media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.modal-media .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #aaa; font-size: 13px; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); color: #111; font-size: 20px; line-height: 1; cursor: pointer; }
.nav.prev { left: 8px; } .nav.next { right: 8px; }
.nav[hidden] { display: none; }
.dots { position: absolute; bottom: 8px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.5); }
.dots span.on { background: #fff; }
.modal-body { padding: 14px 16px 18px; }
.modal-body h2 { margin: 6px 0 8px; font-size: 16px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); }
.pill { padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.caption { white-space: pre-line; font-size: 13px; margin: 0 0 14px; max-height: 220px; overflow: auto; }
.caption:empty { display: none; }

.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; padding: 9px 14px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 13px; box-shadow: var(--shadow); }

@media (max-width: 420px) {
  .profile { gap: 6px 14px; }
  .avatar { width: 60px; height: 60px; font-size: 20px; }
  .drag-hint { display: none; }
}
