*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f8;
  --bg2: #ffffff;
  --bg3: #e8eaf2;
  --border: #d0d4e8;
  --text: #1e2140;
  --text2: #6b7299;
  --accent: #6366f1;
  --accent-hover: #4f51d4;
  --danger: #ef4444;
  --success: #22c55e;
  --sidebar-w: 220px;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(99,102,241,.08);
  --font-size: 14px;
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: var(--font-size); }

.hidden { display: none !important; }
.screen { height: 100vh; }
.error-msg { color: var(--danger); margin-top: 8px; font-size: 13px; }

/* ── Login ── */
#login-screen { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 0%, #dde0f5 0%, var(--bg) 70%); }
.login-box { width: 360px; background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 40px 36px; box-shadow: var(--shadow); }
.login-logo { font-size: 48px; text-align: center; margin-bottom: 12px; }
.login-box h1 { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 28px; }
.login-box h1 span { color: var(--accent); }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=search], select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text); padding: 9px 12px; font-size: var(--font-size); outline: none; width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
input[type=color] { padding: 3px 6px; height: 38px; cursor: pointer; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 7px; font-size: var(--font-size); font-weight: 500; cursor: pointer; transition: background .15s, opacity .15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 5px 7px; font-size: 15px; background: transparent; border: none; color: var(--text2); cursor: pointer; border-radius: 6px; line-height: 1; }
.btn-icon:hover { background: var(--bg3); color: var(--text); }
.btn-inline-link { background: none; border: none; color: var(--accent); font-size: 12px; cursor: pointer; padding: 0; font-weight: 500; }
.btn-inline-link:hover { text-decoration: underline; }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 52px; background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.sidebar-toggle { font-size: 18px; flex-shrink: 0; }
.logo { font-size: 15px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.logo strong { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }

/* ── Search ── */
.search-wrap { position: relative; flex: 1; max-width: 440px; }
#search-input { background: var(--bg3); border-radius: 20px; padding: 7px 14px; }
.search-dropdown { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200; max-height: 320px; overflow-y: auto; }
.search-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; text-decoration: none; color: var(--text); transition: background .1s; }
.search-item:hover { background: var(--bg3); }
.search-item img { width: 16px; height: 16px; flex-shrink: 0; }
.search-item-title { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-url { font-size: 11px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-item-cat { font-size: 11px; padding: 2px 7px; border-radius: 20px; color: #fff; flex-shrink: 0; margin-left: auto; }
.search-empty { padding: 16px; text-align: center; color: var(--text2); }

/* ── User menu ── */
.user-menu-wrap { position: relative; }
.user-btn { gap: 8px; }
#user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 12px; }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 200px; z-index: 200; overflow: hidden; }
.dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-item { display: block; width: 100%; text-align: left; padding: 10px 16px; background: none; border: none; color: var(--text); font-size: 13px; cursor: pointer; transition: background .1s; }
.dropdown-item:hover { background: var(--bg3); }
.dropdown-item.danger { color: var(--danger); }
a.dropdown-item { text-decoration: none; }
.dropdown-settings { padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dropdown-label { font-size: 12px; color: var(--text2); white-space: nowrap; }
.font-size-control { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text2); }
.font-size-control .btn-icon { font-size: 12px; padding: 3px 6px; }

/* ── App body ── */
.app-body { display: flex; height: calc(100vh - 52px); overflow: hidden; }

/* ── Sidebar ── */
#sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; transition: width .2s, opacity .2s; }
#sidebar.collapsed { width: 0; opacity: 0; overflow: hidden; }
.sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.sidebar-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); }
#collection-list { flex: 1; padding: 4px 8px 16px; }
.collection-item { display: flex; align-items: center; gap: 8px; padding: 8px 8px; border-radius: 7px; cursor: pointer; color: var(--text); transition: background .1s; font-size: var(--font-size); }
.collection-item:hover { background: var(--bg3); }
.collection-item.active { background: #ede9fe; color: var(--accent); font-weight: 600; }
.collection-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-actions { display: flex; gap: 2px; opacity: 0; }
.collection-item:hover .collection-actions { opacity: 1; }
.collection-item.active .collection-actions { opacity: 1; }
.collection-actions .btn-icon { font-size: 12px; padding: 2px 5px; }

/* ── Board ── */
#board-wrap { flex: 1; overflow-x: auto; overflow-y: auto; }
#board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 20px; align-content: flex-start; }
#board.empty::after { content: 'Noch keine Kategorien. Klicke auf „＋ Kategorie" um loszulegen.'; color: var(--text2); font-size: 15px; white-space: nowrap; }
#no-collection { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text2); font-size: 15px; }

/* ── Category column ── */
.category-col { min-width: 0; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.category-col.drag-over { border-color: var(--accent); }
.category-col.col-drag-over { border: 2px dashed var(--accent); background: #ede9fe; }
.cat-header { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-radius: 11px 11px 0 0; cursor: grab; }
.cat-header:active { cursor: grabbing; }
.cat-title { font-weight: 600; font-size: var(--font-size); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-badge { font-size: 11px; border-radius: 20px; padding: 1px 8px; }
.cat-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.cat-icon { color: var(--icon-color) !important; }
.cat-icon:hover { background: var(--icon-hover-bg) !important; color: inherit !important; }
.category-col:hover .cat-actions { opacity: 1; }
.cat-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; max-height: 600px; }
.cat-add-btn { margin: 8px; }

/* ── Bookmark ── */
.bookmark-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; background: var(--bg3); cursor: grab; transition: background .1s; }
.bookmark-item:hover { background: #dde0f5; }
.bookmark-item.dragging { opacity: .4; }
.bookmark-item img.favicon { width: 16px; height: 16px; flex-shrink: 0; border-radius: 3px; }
.bookmark-item a { flex: 1; color: var(--text); text-decoration: none; font-size: var(--font-size); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bookmark-item a:hover { color: var(--accent); }
.bm-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; flex-shrink: 0; }
.bookmark-item:hover .bm-actions { opacity: 1; }

/* ── Inline new category ── */
.new-cat-inline { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.new-cat-inline input[type=text] { flex: 1; }
.new-cat-inline input[type=color] { width: 38px; flex-shrink: 0; }

/* ── Modal ── */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 500; backdrop-filter: blur(2px); }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: 440px; box-shadow: var(--shadow); }
.modal-wide { width: 600px; max-height: 80vh; overflow-y: auto; }
.modal h2 { font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.modal h3 { font-size: 14px; font-weight: 600; margin: 20px 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-close-btn { margin-top: 20px; }

/* ── User list ── */
.user-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-row-name { font-weight: 600; flex: 1; }
.user-row-email { color: var(--text2); font-size: 12px; flex: 1; }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.role-badge.admin { background: #ede9fe; color: var(--accent); }
.role-badge.user  { background: var(--bg3); color: var(--text2); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c0c4dc; border-radius: 3px; }

/* ── Move category picker ── */
.move-picker { position: absolute; z-index: 600; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 180px; overflow: hidden; }
.move-picker-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); padding: 8px 14px 4px; }
.move-picker-item { display: block; width: 100%; text-align: left; padding: 9px 14px; background: none; border: none; color: var(--text); font-size: 13px; cursor: pointer; transition: background .1s; }
.move-picker-item:hover { background: var(--bg3); color: var(--accent); }
.move-picker-empty { padding: 12px 14px; font-size: 13px; color: var(--text2); }

/* ── Toast ── */
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg2); border-radius: 8px; padding: 10px 20px; font-size: 13px; box-shadow: var(--shadow); z-index: 1000; transition: opacity .3s; }
#toast.hidden { opacity: 0; pointer-events: none; }
