:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --radius-card: 16px;
  --radius-sm: 10px;
}

/* Theme 1: Bento Dark (Default) */
html[data-theme="bento-dark"] {
  --bg: #0b0f17;
  --bg-grad: radial-gradient(circle at 15% 10%, rgba(56, 189, 248, 0.08), transparent 40%),
             radial-gradient(circle at 85% 20%, rgba(168, 85, 247, 0.08), transparent 40%);
  --card: #131926;
  --card-hover: #192233;
  --card-border: rgba(255, 255, 255, 0.08);
  --text: #e8edf5;
  --text-muted: #8b98ad;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --green: #22c55e;
  --red: #ef4444;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --blur: none;
}

/* Theme 2: Glassmorphism */
html[data-theme="glass"] {
  --bg: #0f2027;
  --bg-grad: linear-gradient(135deg, #0f2027 0%, #203a43 45%, #2c5364 100%);
  --card: rgba(255, 255, 255, 0.11);
  --card-hover: rgba(255, 255, 255, 0.17);
  --card-border: rgba(255, 255, 255, 0.22);
  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --accent: #7dd3fc;
  --accent-soft: rgba(125, 211, 252, 0.2);
  --green: #4ade80;
  --red: #f87171;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  --blur: blur(18px);
}

/* Theme 3: Pro Terminal */
html[data-theme="terminal"] {
  --bg: #07090c;
  --bg-grad: none;
  --card: #0d1117;
  --card-hover: #141b24;
  --card-border: #212a36;
  --text: #d8e1eb;
  --text-muted: #768390;
  --accent: #f59e0b;
  --accent-soft: rgba(245, 158, 11, 0.15);
  --green: #10b981;
  --red: #f43f5e;
  --shadow: none;
  --blur: none;
  --radius-card: 8px;
  --radius-sm: 6px;
}

/* Theme 4: Clean Light */
html[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-grad: radial-gradient(circle at 20% 0%, rgba(59, 130, 246, 0.08), transparent 45%);
  --card: #ffffff;
  --card-hover: #f8fafc;
  --card-border: rgba(15, 23, 42, 0.09);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --green: #16a34a;
  --red: #dc2626;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --blur: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}

.bg-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-grad);
  pointer-events: none;
  z-index: -1;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--card-border);
  background: var(--card);
  backdrop-filter: var(--blur);
  position: sticky;
  top: 0;
  z-index: 30;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.market-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  cursor: pointer;
}

.market-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--card-border);
  font-size: 12px;
  font-family: var(--font-mono);
}

.market-chip .m-label { color: var(--text-muted); font-family: var(--font-sans); font-weight: 500; }
.market-chip .m-up { color: var(--green); }
.market-chip .m-down { color: var(--red); }
.market-loading { font-size: 12px; color: var(--text-muted); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-pill, .select-pill, .btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--card-border);
  background: rgba(128, 128, 128, 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-pill:hover, .select-pill:hover, .btn-icon:hover {
  background: var(--card-hover);
  border-color: var(--accent);
}

.btn-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.select-pill option {
  background: #131926;
  color: #e8edf5;
}

kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
}

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  flex-direction: column;
  z-index: 50;
}
.dropdown-menu.open { display: flex; }
.dropdown-menu button {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.dropdown-menu button:hover { background: var(--accent-soft); }

/* Search Bar */
.search-section {
  max-width: 680px;
  margin: 20px auto 16px;
  padding: 0 20px;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--card);
  backdrop-filter: var(--blur);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 4px 8px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s;
}

.search-bar:focus-within {
  border-color: var(--accent);
}

.search-engine {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px;
  cursor: pointer;
  outline: none;
}

.search-engine option { background: #131926; color: #e8edf5; }

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 8px;
  outline: none;
}

.search-submit {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  padding: 6px 10px;
  border-radius: 8px;
}
.search-submit:hover { background: var(--accent-soft); }

/* 4-Column Dashboard Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 4px 24px 40px;
  max-width: 1720px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 1280px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid { grid-template-columns: 1fr; padding: 4px 12px 32px; } }

.column {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* Widget Card */
.widget {
  background: var(--card);
  backdrop-filter: var(--blur);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--card-border);
}

.widget-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.widget-count {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.widget-body {
  padding: 10px 12px 12px;
}

.widget-add-btn {
  display: none;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
body.edit-mode .widget-add-btn { display: inline-flex; }

/* Link List */
.link-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  transition: background 0.12s;
  min-width: 0;
}

.link-row:hover {
  background: var(--card-hover);
}

.link-row img.favicon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  object-fit: contain;
}

.link-row span.link-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.link-actions {
  display: none;
  gap: 4px;
  flex-shrink: 0;
}
body.edit-mode .link-actions { display: inline-flex; }

.mini-btn {
  background: rgba(128, 128, 128, 0.14);
  border: none;
  color: var(--text-muted);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
}
.mini-btn:hover { color: var(--text); background: var(--accent-soft); }
.mini-btn.del:hover { color: var(--red); }

/* Tiles Layout (Favoriten) */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tile-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  background: rgba(128, 128, 128, 0.06);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.tile-item:hover {
  background: var(--card-hover);
  border-color: var(--card-border);
  transform: translateY(-1px);
}

.tile-item img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: contain;
}

.tile-item span {
  font-size: 11.5px;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* RSS Widget */
.rss-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.rss-tab {
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.rss-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.rss-featured {
  display: flex;
  gap: 10px;
  padding: 8px;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  background: rgba(128, 128, 128, 0.06);
  text-decoration: none;
  color: var(--text);
}
.rss-featured:hover { background: var(--card-hover); }
.rss-featured img {
  width: 78px;
  height: 58px;
  object-fit: cover;
  border-radius: 7px;
  flex-shrink: 0;
}
.rss-featured-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}
.rss-featured-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.rss-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 6px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--text);
}
.rss-item:hover { background: var(--card-hover); }
.rss-item-title {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rss-item-time {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Weather Widget */
.weather-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 12px;
}
.weather-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.weather-icon { font-size: 32px; line-height: 1; }
.weather-temp { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.weather-desc { font-size: 12.5px; font-weight: 500; }
.weather-meta { font-size: 11.5px; color: var(--text-muted); text-align: right; }

.weather-forecast {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--card-border);
}
.wf-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
}
.wf-day-name { color: var(--text-muted); font-weight: 500; }
.wf-day-icon { font-size: 18px; }
.wf-day-temps { font-family: var(--font-mono); font-size: 11px; }
.wf-day-rain { font-size: 10.5px; color: var(--accent); }

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 100;
}
.hidden { display: none !important; }

.cmd-box {
  width: min(580px, 92vw);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.cmd-box input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--card-border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 14px 16px;
  outline: none;
}
.cmd-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}
.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
.cmd-item.selected, .cmd-item:hover { background: var(--accent-soft); }
.cmd-item-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cmd-item-left img { width: 16px; height: 16px; border-radius: 3px; }
.cmd-item-cat { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.cmd-footer {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--card-border);
}

.modal-card {
  width: min(420px, 92vw);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal-card h3 { margin: 0 0 14px; font-size: 16px; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.modal-card input {
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: rgba(128, 128, 128, 0.08);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn-secondary, .btn-primary {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
}
.btn-secondary { background: transparent; color: var(--text); }
.btn-primary { background: var(--accent); color: #081018; border-color: transparent; font-weight: 600; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 200;
}
