:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1d1c1a;
  --muted: #6d6a64;
  --line: #e2dfd8;
  --accent: #c2410c;
  --accent-soft: #fbe9df;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fdf3d8;
  --ok: #1f7a4d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --surface: #1f1e1c;
    --surface-2: #292825;
    --text: #ece9e4;
    --muted: #9e9a92;
    --line: #34322e;
    --accent: #fb7b3c;
    --accent-soft: #3a2418;
    --danger: #ff6b5e;
    --danger-soft: #3a1c19;
    --warn: #f0b847;
    --warn-soft: #362b12;
    --ok: #4cc38a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .6rem; font-weight: 600; }
.card h2 { font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--text); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--surface-2); border-radius: 4px; padding: .1em .35em; }
pre { padding: .7rem; overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .45rem; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand svg { width: 18px; height: 18px; fill: var(--accent); }
.brand:hover { text-decoration: none; }
.search { flex: 1 1 260px; max-width: 560px; }
.search input { width: 100%; }
.top nav { display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; margin-left: auto; }
.top nav a, .linkbtn {
  color: var(--muted); padding: .35rem .6rem; border-radius: 6px; font-size: .92rem;
  background: none; border: 0; cursor: pointer; font: inherit; font-size: .92rem;
}
.top nav a:hover, .linkbtn:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.top nav a.on { color: var(--text); background: var(--surface-2); font-weight: 600; }
.inline { display: inline; margin: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }
.narrow { max-width: 720px; margin: 0 auto; }
.narrow > h1 { margin-top: .5rem; }

/* Formulare */
input[type=text], input[type=search], input[type=password], input[type=url], textarea, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; width: 100%;
}
.top input[type=search] { background: var(--surface-2); border-color: transparent; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
select { width: auto; }
textarea { resize: vertical; }
.form label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .9rem; }
.form label input, .form label textarea { margin-top: .3rem; font-weight: 400; }
.form label .muted { font-weight: 400; }
label.chk { display: flex; gap: .5rem; align-items: center; font-weight: 400; cursor: pointer; }
label.chk input { width: auto; margin: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem; justify-content: center;
  font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer;
  padding: .48rem .9rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger:not(.ghost) { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.ghost.danger:hover { color: var(--danger); background: var(--danger-soft); }
.btn.small { padding: .25rem .55rem; font-size: .82rem; font-weight: 500; }
.btn.wide { width: 100%; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
details.card summary { cursor: pointer; font-weight: 600; }

.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: 1rem; background: #e6f4ec; color: var(--ok); border: 1px solid transparent; }
.flash.err { background: var(--danger-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) { .flash { background: #15301f; } }
.notice { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: var(--warn-soft); }
.notice.danger { background: var(--danger-soft); display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.notice p { margin: 0; flex: 1 1 320px; }

/* Layout Liste */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 1.75rem; align-items: start; }
.side { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; padding-right: .25rem; }
.side section { margin-bottom: 1.5rem; }
.filters, .tagcloud { list-style: none; margin: 0; padding: 0; }
.filters a, .tagcloud a {
  display: flex; justify-content: space-between; gap: .5rem; padding: .28rem .55rem; border-radius: 6px;
  color: var(--text); font-size: .92rem;
}
.filters a:hover, .tagcloud a:hover { background: var(--surface-2); text-decoration: none; }
.filters a.on, .tagcloud a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.filters a.danger { color: var(--danger); }
.count { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; font-weight: 400; }
.tagfilter { margin-bottom: .5rem; padding: .35rem .6rem; font-size: .88rem; }

.listhead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.listhead h1 { margin: 0; }

.bulkbar {
  position: sticky; top: 64px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: .55rem .7rem; margin-bottom: .75rem; box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.bulkbar input[type=text] { width: 190px; padding: .35rem .6rem; }
.bulkbar .btn { padding: .35rem .7rem; font-size: .85rem; }

.bm-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.star { background: none; border: 0; padding: 0 .1rem; font-size: 1.15rem; line-height: 1.2; cursor: pointer; color: var(--line); transition: color .15s, transform .15s; }
.star:hover { color: #e8a317; transform: scale(1.15); }
.star.on { color: #e8a317; }
.bm { display: grid; grid-template-columns: auto auto auto 1fr auto; gap: .75rem; align-items: start; padding: .85rem 1rem; border-top: 1px solid var(--line); }
.bm:first-child { border-top: 0; }
.bm:hover { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.bm.is-marked { background: var(--danger-soft); }
.bm .sel { margin-top: .3rem; accent-color: var(--accent); }
.fav { width: 20px; height: 20px; border-radius: 4px; margin-top: .15rem; object-fit: contain; }
.fav.letter {
  display: inline-grid; place-items: center; font-size: .72rem; font-weight: 700; color: #fff;
  background: hsl(var(--h) 45% 48%);
}
.bm-body { min-width: 0; }
.bm-title { font-weight: 600; color: var(--text); display: block; overflow-wrap: anywhere; }
.bm-title:visited { color: color-mix(in srgb, var(--text) 75%, var(--accent)); }
.bm-meta { font-size: .82rem; color: var(--muted); display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; margin-top: .1rem; }
.bm-desc { margin: .35rem 0 0; font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; }
.tag { font-size: .78rem; padding: .08rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--text); }
.tag:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.bm-actions { display: flex; gap: .15rem; opacity: .35; transition: opacity .15s; flex-wrap: wrap; justify-content: flex-end; }
.bm:hover .bm-actions, .bm:focus-within .bm-actions, .bm.is-marked .bm-actions { opacity: 1; }
.badge { font-size: .74rem; padding: .05rem .45rem; border-radius: 4px; font-weight: 600; }
.badge.dead { background: var(--danger); color: #fff; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.muted { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.pill { display: inline-block; font-size: .72rem; padding: 0 .4rem; border-radius: 999px; font-weight: 700; }
.pill.danger { background: var(--danger); color: #fff; }

.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; gap: .25rem; justify-content: center; margin: 1.25rem 0; flex-wrap: wrap; }
.pager a { padding: .35rem .7rem; border-radius: 6px; color: var(--text); }
.pager a:hover { background: var(--surface-2); text-decoration: none; }
.pager a.on { background: var(--accent); color: #fff; }

/* Login */
.login { min-height: 80vh; display: grid; place-items: center; }
.login .card { width: 100%; max-width: 360px; padding: 2rem; text-align: left; }
.login h1 { text-align: center; margin-bottom: 1rem; }
.login-mark { display: grid; place-items: center; margin-bottom: .5rem; }
.login-mark svg { width: 36px; height: 36px; fill: var(--accent); }
.login label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .9rem; }
.login label input { margin-top: .3rem; }

/* Linkprüfung */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: .5rem; margin: 1rem 0 .5rem; }
.stats > * { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; color: var(--text); }
.stats b { display: block; font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stats span { font-size: .8rem; color: var(--muted); }
.stats a.danger { border-color: var(--danger); }
.stats a.danger b { color: var(--danger); }
.stats a:hover { text-decoration: none; background: var(--danger-soft); }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 1rem; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.status { margin: .6rem 0 0; }
.checklog { list-style: none; padding: 0; margin: .5rem 0 0; max-height: 320px; overflow-y: auto; font-size: .85rem; }
.checklog li { padding: .3rem 0; border-top: 1px solid var(--line); display: flex; gap: .5rem; }
.checklog li b { color: var(--danger); white-space: nowrap; }
.checklog li span { overflow-wrap: anywhere; }

/* Import */
.drop { display: grid !important; place-items: center; gap: .4rem; padding: 1.5rem; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; text-align: center; font-weight: 400 !important; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { width: auto; border: 0; padding: 0; background: none; }
.report { width: 100%; border-collapse: collapse; font-size: .9rem; }
.report th, .report td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
.report th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.report td.err { color: var(--danger); }

/* Tags */
.taglist { list-style: none; padding: .4rem .8rem; }
.taglist li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.taglist li:first-child { border-top: 0; }
.taglist .tag { font-size: .88rem; }
.taglist .rename { margin-left: auto; display: flex; gap: .3rem; align-items: center; }
.taglist .rename input { width: 170px; padding: .25rem .5rem; font-size: .88rem; }
.suggest { display: flex; flex-wrap: wrap; gap: .3rem; margin: -.5rem 0 1rem; }
.suggest button { font: inherit; font-size: .8rem; padding: .1rem .55rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; }
.suggest button:hover { border-color: var(--accent); color: var(--accent); }

/* Startseite */
.home { max-width: 1080px; margin: 0 auto; }
.home section { margin-bottom: 2rem; }
.home-hero { text-align: center; padding: 1.5rem 0 .5rem; }
.home-hero h1 { font-size: 1.7rem; margin-bottom: 1rem; }
.home-search { max-width: 620px; margin: 0 auto 1rem; }
.home-search input { font-size: 1.05rem; padding: .8rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow); }
.home-tags { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; max-width: 720px; margin: 0 auto; }
.danger-link { color: var(--danger); font-weight: 600; }
.home-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.home-head h2 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .45rem;
  padding: 1rem .7rem .85rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  color: var(--text); box-shadow: var(--shadow); transition: transform .12s, border-color .12s, box-shadow .12s;
  cursor: pointer; min-width: 0; user-select: none;
}
.tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); }
.tile.dragging { opacity: .4; transform: scale(.96); }
.tile-icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); overflow: hidden; flex: none; }
.tile-icon img { width: 28px; height: 28px; object-fit: contain; }
.tile-icon.letter, .mini-icon.letter { background: hsl(var(--h) 45% 48%); color: #fff; font-weight: 700; }
.tile-icon.letter { font-size: 1.15rem; }
.tile-title { font-weight: 600; font-size: .9rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.tile-host { font-size: .74rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.minilist { list-style: none; margin: 0; padding: .3rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.minilist a { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; border-radius: 7px; color: var(--text); }
.minilist a:hover { background: var(--surface-2); text-decoration: none; }
.mini-icon { width: 22px; height: 22px; border-radius: 5px; display: grid; place-items: center; overflow: hidden; flex: none; font-size: .7rem; }
.mini-icon img { width: 18px; height: 18px; object-fit: contain; }
.mini-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.checklog li.ok b { color: var(--ok); }

@media (max-width: 860px) {
  .layout { display: flex; flex-direction: column; gap: 1rem; }
  .side { display: contents; }
  .side-filters { order: 1; margin: 0 !important; }
  .side-filters h2 { display: none; }
  .filters { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .2rem; }
  .filters a { white-space: nowrap; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; }
  .content { order: 2; min-width: 0; }
  .side-tags { order: 3; }
  .top nav a, .linkbtn { white-space: nowrap; }
  .bulkbar { top: 0; }
  .tagcloud { display: flex; flex-wrap: wrap; gap: .2rem; max-height: 180px; overflow-y: auto; }
  .tagcloud a { background: var(--surface-2); }
  .top { padding: .6rem 1rem; }
  .top nav { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .wrap { padding: 1rem; }
  .bm { grid-template-columns: auto auto auto 1fr; }
  .bm-actions { grid-column: 4; justify-content: flex-start; opacity: 1; }
  .taglist .rename { margin-left: 0; width: 100%; }
  .taglist .rename input { flex: 1; }
  .home-cols { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: .5rem; }
  .tile { padding: .8rem .45rem .7rem; }
  .home-hero h1 { font-size: 1.4rem; }
}

@media (hover: none) { .drag-hint { display: none; } }

/* Papierkorb */
.wide-ish { max-width: 960px; }
.pill { background: var(--surface-2); color: var(--muted); }
.bm.trashed .bm-title { color: var(--muted); }
.bm.trashed .bm-actions { opacity: 1; }
.trash-search { margin-bottom: 1rem; max-width: 420px; }
.flash a { font-weight: 600; margin-left: .4rem; }
