:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --text: #111827;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #e5e7eb;
  --accent: #111827;
  --danger: #b91c1c;
  --success: #166534;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; }
.container { width: min(1120px, calc(100% - 32px)); margin: 32px auto; }
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; }
.brand { font-weight: 800; text-decoration: none; }
.topbar nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar nav a { text-decoration: none; color: var(--muted); font-weight: 600; }
.topbar nav a:hover { color: var(--text); }
.userpill { background: #eef2ff; color: #3730a3; padding: 6px 10px; border-radius: 999px; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 24px; box-shadow: 0 16px 40px rgba(17,24,39,.07); margin-bottom: 20px; }
.auth { max-width: 460px; margin: 56px auto; }
h1, h2 { margin-top: 0; letter-spacing: -.03em; }
label { display: grid; gap: 7px; font-weight: 700; margin: 14px 0; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; font: inherit; background: #fff; }
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: var(--accent); color: #fff; border-radius: 14px; padding: 11px 15px; font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; }
button.secondary, .button.secondary { background: #e5e7eb; color: #111827; }
button.danger, .button.danger { background: var(--danger); color: #fff; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 20px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.list { display: grid; gap: 10px; }
.row { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 14px; display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; }
.flash { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-weight: 700; }
.flash.success { background: #dcfce7; color: var(--success); }
.flash.error { background: #fee2e2; color: var(--danger); }
.tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 20px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 12px; vertical-align: middle; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }
.tokenbox code { display: block; word-break: break-all; background: #111827; color: #fff; padding: 14px; border-radius: 14px; }
.hero { min-height: 65vh; display: grid; place-content: center; text-align: center; }
.hero h1 { font-size: clamp(42px, 7vw, 84px); margin: 0 0 10px; }
.public .container { width: 100%; margin: 0; }
.linktree { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: linear-gradient(135deg, #111827, #374151); background-size: cover; background-position: center; }
.linkcard { width: min(520px, 100%); background: rgba(255,255,255,.9); backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,.4); border-radius: 30px; padding: 30px; box-shadow: 0 22px 60px rgba(0,0,0,.25); text-align: center; }
.linkcard h1 { font-size: 40px; margin-bottom: 8px; }
.bio { color: var(--muted); white-space: pre-wrap; }
.links { display: grid; gap: 12px; margin: 24px 0; }
.linkbtn { text-align: left; display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); padding: 14px; border-radius: 18px; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease; }
.linkbtn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(17,24,39,.12); }
.linkbtn img { width: 48px; height: 48px; object-fit: cover; border-radius: 14px; flex: 0 0 auto; }
.linkbtn strong, .linkbtn small { display: block; }
.linkbtn small { color: var(--muted); margin-top: 2px; }
footer { color: var(--muted); font-size: 13px; }
@media (max-width: 740px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .row { grid-template-columns: 1fr; }
  .toolbar { align-items: flex-start; flex-direction: column; }
}

/* Link-Reihenfolge: Drag-and-drop + Sortierbuttons */
.muted { color: var(--muted); margin: 4px 0 0; }
.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}
.sortable-row { transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease; }
.sortable-row.dragging { opacity: .55; box-shadow: 0 18px 36px rgba(17,24,39,.14); }
.link-order-controls {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-right: 2px;
}
.drag-handle { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 12px; background: #f9fafb; color: var(--muted); font-weight: 900; cursor: grab; user-select: none; }
.drag-handle:active { cursor: grabbing; }
.link-move-form { display: inline-flex; align-items: center; gap: 5px; margin: 0; }
.iconbtn { width: 34px; height: 34px; padding: 0; border-radius: 11px; background: #e5e7eb; color: #111827; font-weight: 900; }
.chevron-btn { position: relative; }
.chevron-btn::before {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  display: block;
}
.chevron-up::before { transform: rotate(225deg); margin-top: 5px; }
.chevron-down::before { transform: rotate(45deg); margin-bottom: 5px; }
.iconbtn:disabled { opacity: .35; cursor: not-allowed; }
.link-main {
  flex: 1 1 auto;
  min-width: 0;
}
.link-main small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.link-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.link-edit-button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.order-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 44px));
  background: #111827;
  color: #fff;
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 18px 45px rgba(17,24,39,.28);
  font-weight: 800;
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.order-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.order-toast[data-type="ok"] { background: #166534; }
.order-toast[data-type="error"] { background: #b91c1c; }
.sortable-links[data-saving="1"] .sortable-row { opacity: .92; }
@media (max-width: 740px) {
  .link-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
  }
  .link-order-controls { grid-row: 1 / span 2; align-self: start; }
  .link-main { align-self: center; }
  .link-status { grid-column: 2; }
  .link-edit-button { grid-column: 2; justify-self: start; }
}

/* Analytics */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin: 18px 0 22px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(17,24,39,.06);
}
.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1;
  letter-spacing: -.04em;
}
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(320px, 1.2fr);
  gap: 16px;
  align-items: start;
}
.metric-list {
  display: grid;
  gap: 10px;
}
.metric-list > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.metric-list > div:last-child { border-bottom: 0; }
.metric-list span { color: var(--muted); font-weight: 700; }
.metric-list strong { font-size: 24px; }
.top-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.top-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #f9fafb;
}
.top-list small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}
.top-list span {
  flex: 0 0 auto;
  font-weight: 900;
}
@media (max-width: 860px) {
  .analytics-grid { grid-template-columns: 1fr; }
}

/* Seite bearbeiten: Live-Vorschau */
.page-edit-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 26px;
}
.page-edit-form-card {
  margin-bottom: 0;
}
.live-preview-card {
  position: static;
  margin-bottom: 0;
}
.live-preview-card .preview-device {
  width: min(560px, 100%);
  margin: 0 auto;
}
.live-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.live-preview-head h2 {
  margin-bottom: 4px;
}
.preview-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  background: #eef2ff;
  color: #3730a3;
}
.preview-badge[data-state="draft"] {
  background: #fef3c7;
  color: #92400e;
}
.preview-device {
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 12px;
  background: #0f172a;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.preview-linktree {
  min-height: 520px;
  display: grid;
  place-items: center;
  padding: 24px 14px;
  border-radius: 20px;
  background: linear-gradient(135deg, var(--preview-theme-color, #111827), #374151);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.preview-linkcard {
  width: min(100%, 340px);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.45);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 18px 44px rgba(0,0,0,.24);
  text-align: center;
  color: #111827;
}
.preview-linkcard h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 36px);
  line-height: 1.05;
  color: #111827;
  word-break: break-word;
}
.preview-bio {
  margin: 0;
  color: #6b7280;
  white-space: pre-wrap;
  word-break: break-word;
}
.preview-links {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}
.preview-linkbtn {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #111827;
  border-radius: 16px;
  padding: 12px;
  text-decoration: none;
  cursor: default;
}
.preview-linkbtn img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  flex: 0 0 auto;
}
.preview-linkbtn strong,
.preview-linkbtn small {
  display: block;
}
.preview-linkbtn small {
  color: #6b7280;
  margin-top: 2px;
}
.preview-empty {
  margin: 0;
  color: #6b7280;
  font-weight: 700;
}
.preview-linkcard footer {
  color: #6b7280;
  font-size: 12px;
  word-break: break-word;
}
.preview-note {
  font-size: 13px;
  margin-top: 12px;
}
@media (max-width: 980px) {
  .page-edit-layout {
    grid-template-columns: 1fr;
  }
  .live-preview-card {
    position: static;
  }
  .preview-linktree {
    min-height: 420px;
  }
}

/* Management Dark-/Lightmode */
.theme-toggle {
  border: 1px solid var(--line);
  background: #f9fafb;
  color: var(--text);
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
  box-shadow: none;
}
.theme-toggle:hover {
  border-color: var(--muted);
}
.theme-toggle [data-theme-icon] {
  width: 16px;
  display: inline-flex;
  justify-content: center;
}

html[data-mgmt-theme="dark"] body.management {
  color-scheme: dark;
  --bg: #0b1120;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --card: #111827;
  --line: #263244;
  --accent: #e5e7eb;
  --danger: #f87171;
  --success: #4ade80;
}
html[data-mgmt-theme="dark"] body.management .topbar {
  background: rgba(15, 23, 42, .92);
  border-bottom-color: var(--line);
}
html[data-mgmt-theme="dark"] body.management .brand,
html[data-mgmt-theme="dark"] body.management h1,
html[data-mgmt-theme="dark"] body.management h2,
html[data-mgmt-theme="dark"] body.management h3 {
  color: var(--text);
}
html[data-mgmt-theme="dark"] body.management .topbar nav a {
  color: var(--muted);
}
html[data-mgmt-theme="dark"] body.management .topbar nav a:hover {
  color: var(--text);
}
html[data-mgmt-theme="dark"] body.management input,
html[data-mgmt-theme="dark"] body.management textarea,
html[data-mgmt-theme="dark"] body.management select {
  background: #0f172a;
  color: var(--text);
  border-color: var(--line);
}
html[data-mgmt-theme="dark"] body.management input::placeholder,
html[data-mgmt-theme="dark"] body.management textarea::placeholder {
  color: #64748b;
}
html[data-mgmt-theme="dark"] body.management .card,
html[data-mgmt-theme="dark"] body.management .row,
html[data-mgmt-theme="dark"] body.management .tablewrap,
html[data-mgmt-theme="dark"] body.management .stat-card {
  background: #111827;
  border-color: var(--line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .24);
}
html[data-mgmt-theme="dark"] body.management table {
  color: var(--text);
}
html[data-mgmt-theme="dark"] body.management th,
html[data-mgmt-theme="dark"] body.management td {
  border-bottom-color: var(--line);
}
html[data-mgmt-theme="dark"] body.management button,
html[data-mgmt-theme="dark"] body.management .button {
  background: #e5e7eb;
  color: #0f172a;
}
html[data-mgmt-theme="dark"] body.management button.secondary,
html[data-mgmt-theme="dark"] body.management .button.secondary,
html[data-mgmt-theme="dark"] body.management .iconbtn,
html[data-mgmt-theme="dark"] body.management .drag-handle,
html[data-mgmt-theme="dark"] body.management .theme-toggle {
  background: #1f2937;
  color: var(--text);
  border-color: var(--line);
}
html[data-mgmt-theme="dark"] body.management button.danger,
html[data-mgmt-theme="dark"] body.management .button.danger {
  background: #7f1d1d;
  color: #fee2e2;
}
html[data-mgmt-theme="dark"] body.management .userpill {
  background: #1e1b4b;
  color: #c7d2fe;
}
html[data-mgmt-theme="dark"] body.management .flash.success {
  background: #052e16;
  color: #bbf7d0;
}
html[data-mgmt-theme="dark"] body.management .flash.error {
  background: #450a0a;
  color: #fecaca;
}
html[data-mgmt-theme="dark"] body.management .tokenbox code {
  background: #020617;
  color: #e5e7eb;
  border: 1px solid var(--line);
}
html[data-mgmt-theme="dark"] body.management .top-list li,
html[data-mgmt-theme="dark"] body.management .drag-handle {
  background: #0f172a;
  border-color: var(--line);
}
html[data-mgmt-theme="dark"] body.management .link-main small,
html[data-mgmt-theme="dark"] body.management .muted,
html[data-mgmt-theme="dark"] body.management .bio,
html[data-mgmt-theme="dark"] body.management footer,
html[data-mgmt-theme="dark"] body.management .metric-list span,
html[data-mgmt-theme="dark"] body.management .top-list small,
html[data-mgmt-theme="dark"] body.management th,
html[data-mgmt-theme="dark"] body.management .link-status,
html[data-mgmt-theme="dark"] body.management .metric-list > div {
  border-bottom-color: var(--line);
}
html[data-mgmt-theme="dark"] body.management .theme-toggle:hover {
  border-color: #64748b;
}
html[data-mgmt-theme="dark"] body.management code {
  background: #020617;
  color: #e5e7eb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1px 5px;
}

html[data-mgmt-theme="dark"] body.management .order-toast {
  box-shadow: 0 18px 45px rgba(0,0,0,.42);
}

/* Öffentliche Seite: Bild nur im Kasten-Bereich statt als kompletter Hintergrund */
.public .linktree {
  background-size: auto;
  background-position: initial;
}
.linkcard h1 {
  color: #111827;
}
.linkcard-hero {
  min-height: 132px;
  display: grid;
  place-items: center;
  margin: 12px -12px 6px;
  padding: 28px 20px 34px;
  border-radius: 24px;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.linkcard-hero.no-image {
  min-height: auto;
  margin: 8px 0 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
}
.linkcard-hero .bio,
.bio {
  color: var(--bio-color, #6b7280);
  white-space: pre-wrap;
  margin: 0;
  text-shadow: 0 1px 18px rgba(255,255,255,.28);
}
.links {
  margin-top: 18px;
}

/* Live-Vorschau: gleiche Struktur wie die echte öffentliche Seite */
.preview-linktree {
  background-size: auto;
  background-position: initial;
}
.preview-linkcard h1 {
  color: #111827;
}
.preview-linkcard-hero {
  min-height: 108px;
  display: grid;
  place-items: center;
  margin: 10px -8px 4px;
  padding: 22px 14px 28px;
  border-radius: 20px;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.preview-linkcard-hero.no-image {
  min-height: auto;
  margin: 8px 0 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
}
.preview-bio {
  color: var(--preview-bio-color, #6b7280);
  text-shadow: 0 1px 16px rgba(255,255,255,.26);
}

/* Upload + Zuschnitt */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.image-upload-field {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.image-upload-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.file-button {
  cursor: pointer;
}
.cropper {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #f9fafb;
  padding: 14px;
}
.cropper-stage {
  position: relative;
  width: min(520px, 100%);
  aspect-ratio: 16 / 9;
  margin: 0 auto 12px;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: repeating-conic-gradient(#e5e7eb 0% 25%, #f3f4f6 0% 50%) 50% / 22px 22px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
[data-crop-aspect="1:1"] .cropper-stage {
  width: min(360px, 100%);
  aspect-ratio: 1 / 1;
}
.cropper-stage:active {
  cursor: grabbing;
}
.cropper-stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  transform-origin: center;
  will-change: transform;
  pointer-events: none;
}
.cropper-zoom {
  width: min(520px, 100%);
  margin: 0 auto;
}
.cropper-zoom input[type="range"] {
  padding: 0;
}
input[type="color"] {
  min-height: 46px;
  padding: 5px;
  cursor: pointer;
}

html[data-mgmt-theme="dark"] body.management .cropper {
  background: #0f172a;
  border-color: var(--line);
}
html[data-mgmt-theme="dark"] body.management .cropper-stage {
  border-color: var(--line);
  background: repeating-conic-gradient(#1f2937 0% 25%, #111827 0% 50%) 50% / 22px 22px;
}

/* Feinschliff Bildbereich + Live-Vorschau */
.linkcard,
.preview-linkcard {
  position: relative;
  overflow: hidden;
}

.linkcard h1,
.preview-linkcard h1,
html[data-mgmt-theme="dark"] body.management .preview-linkcard h1 {
  position: relative;
  z-index: 2;
  color: #111827 !important;
}

.linkcard-hero:not(.no-image) {
  position: relative;
  z-index: 1;
  min-height: 186px;
  margin: -64px -18px 14px;
  padding: 86px 22px 30px;
  border-radius: 20px 20px 24px 24px;
  background-size: cover;
  background-position: center;
  background-clip: padding-box;
}

.preview-linkcard-hero:not(.no-image) {
  position: relative;
  z-index: 1;
  min-height: 158px;
  margin: -54px -12px 12px;
  padding: 72px 16px 26px;
  border-radius: 16px 16px 20px 20px;
  background-size: cover;
  background-position: center;
  background-clip: padding-box;
}

.linkcard-hero:not(.no-image) .bio,
.preview-linkcard-hero:not(.no-image) .preview-bio {
  display: inline-block;
  max-width: min(92%, 520px);
  padding: 8px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.34);
  border: 1px solid rgba(255,255,255,.36);
  box-shadow: 0 10px 28px rgba(17,24,39,.12);
  backdrop-filter: blur(7px) saturate(1.08);
  -webkit-backdrop-filter: blur(7px) saturate(1.08);
  line-height: 1.42;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(255,255,255,.48);
}

.preview-linkcard-hero:not(.no-image) .preview-bio {
  max-width: min(94%, 420px);
  padding: 7px 10px;
  border-radius: 14px;
  font-weight: 600;
}

.linkcard:not(.no-title-outline) h1,
.preview-linkcard:not(.no-title-outline) h1,
html[data-mgmt-theme="dark"] body.management .preview-linkcard:not(.no-title-outline) h1 {
  text-shadow:
    -1px -1px 0 rgba(255,255,255,.86),
     1px -1px 0 rgba(255,255,255,.86),
    -1px  1px 0 rgba(255,255,255,.86),
     1px  1px 0 rgba(255,255,255,.86),
     0 1px 10px rgba(255,255,255,.24);
}

.current-upload-hint {
  margin-top: -6px;
}

.cropper-stage {
  contain: layout paint;
}

/* Link-Icons aus public/assets/icons/ */
.icon-picker {
  margin: 14px 0;
}

.icon-picker-label {
  font-weight: 700;
  margin-bottom: 7px;
}

.icon-picker details {
  position: relative;
}

.icon-picker summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 10px 12px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-picker summary::-webkit-details-marker {
  display: none;
}

.icon-picker summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-left: 12px;
  transition: transform .15s ease;
}

.icon-picker details[open] summary::after {
  transform: rotate(225deg);
}

.icon-picker-current {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-picker-image-slot {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.icon-picker-current img,
.icon-choice img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 9px;
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(17,24,39,.08);
  padding: 4px;
}

.icon-picker-empty-dot {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-block;
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(107,114,128,.75) 46% 54%, transparent 54% 100%),
    #f3f4f6;
  border: 1px dashed #cbd5e1;
}

.icon-picker-menu {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 42px rgba(17,24,39,.16);
  padding: 8px;
  max-height: 280px;
  overflow: auto;
}

.icon-choice {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
}

.icon-choice:hover {
  background: #f3f4f6;
}

.icon-choice input {
  width: auto;
  margin: 0;
}

.icon-choice:has(input:checked) {
  background: #eef2ff;
  color: #3730a3;
}

.linkbtn img,
.preview-linkbtn img {
  object-fit: contain;
  padding: 4px;
  background: rgba(255,255,255,.82);
}

html[data-mgmt-theme="dark"] body.management .icon-picker summary,
html[data-mgmt-theme="dark"] body.management .icon-picker-menu {
  background: #111827;
  border-color: #334155;
}

html[data-mgmt-theme="dark"] body.management .icon-choice:hover {
  background: #1f2937;
}

html[data-mgmt-theme="dark"] body.management .icon-choice:has(input:checked) {
  background: #172554;
  color: #dbeafe;
}

html[data-mgmt-theme="dark"] body.management .icon-picker-empty-dot {
  background:
    linear-gradient(135deg, transparent 0 46%, rgba(203,213,225,.75) 46% 54%, transparent 54% 100%),
    #1f2937;
  border-color: #475569;
}

@media (max-width: 740px) {
  .icon-picker-menu {
    position: static;
    margin-top: 8px;
  }
}
