:root {
  --accent: #04B430;
  --bg: #f6f8f6;
  --panel: #ffffff;
  --fg: #161a16;
  --muted: #5c6b5f;
  --border: rgba(18, 60, 32, 0.12);
  --hover: rgba(4, 180, 48, 0.08);
  --radius: 12px;
}
html[data-theme="dark"] {
  --bg: #0d120f;
  --panel: #161e19;
  --fg: #edf5ee;
  --muted: #9fb5a4;
  --border: rgba(90, 200, 120, 0.16);
  --hover: rgba(0, 230, 46, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Minimal Opera-Air style scrollbars (slim) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(128, 140, 132, 0.32);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(128, 140, 132, 0.52); }
body {
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
}
button { font-family: inherit; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  padding: 28px 14px;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; }
.side-brand img { height: 30px; width: auto; }
.side-brand .side-name { font-size: 15px; font-weight: 700; }
.side-search {
  width: 100%; min-width: 0; padding: 9px 12px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: transparent; color: var(--fg); font-size: 13px; outline: none;
}
.side-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--fg);
  border: 0; background: transparent; width: 100%; text-align: left;
}
.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--fg); color: var(--bg); font-weight: 600; }
.side-item .ico { width: 18px; text-align: center; display: inline-flex; align-items: center; justify-content: center; }
.side-item .ico svg { display: block; opacity: 0.85; }
.li-ico { display: inline-flex; align-items: center; color: var(--muted); }
.li-ico svg { display: block; }

/* ---------- Main ---------- */
.main { flex: 1; padding: 36px 44px 60px; max-width: 860px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.page-head h1 { font-size: 22px; }
.page-head .head-sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.section { display: none; }
.section.active { display: block; }
.section h2 { font-size: 17px; margin: 26px 0 6px; }
.section .sec-desc { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }

/* ---------- Cards / rows ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px;
}
.row + .row { border-top: 1px solid var(--border); }
.row .r-label { font-size: 14px; font-weight: 600; }
.row .r-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row .r-ctrl { flex-shrink: 0; }

/* ---------- Controls ---------- */
.toggle {
  position: relative; width: 40px; height: 22px; border-radius: 11px;
  background: #d5ddd7; border: 0; cursor: pointer; transition: background 0.15s;
  flex-shrink: 0;
}
html[data-theme="dark"] .toggle { background: #2c3a31; }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: left 0.15s; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle.on { background: var(--accent, #04B430); }
.toggle.on::after { left: 21px; }

.btn {
  padding: 9px 18px; border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: var(--fg); font-size: 13px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: #d64545; border-color: rgba(214,69,69,0.4); }
.btn.danger:hover { border-color: #d64545; color: #d64545; }
.btn.sm { padding: 6px 12px; font-size: 12px; }

input[type="text"], input[type="password"], select {
  padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: var(--fg); font-size: 13px; outline: none;
  min-width: 240px;
}
/* The sidebar search must never exceed the sidebar's own width — the generic
   min-width above (240px) otherwise overflows the 230px sidebar. */
input[type="text"].side-search { min-width: 0; width: 100%; }

/* Radio pills */
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--fg); font-size: 13px; cursor: pointer;
}
.pill:hover { border-color: var(--accent); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* Wallpapers */
.wall-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.wall-search-row { display: flex; gap: 8px; align-items: center; }
.wall-search-row input {
  flex: 1; min-width: 0; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: var(--fg); font-size: 13px; outline: none;
}
#wallSuggest { margin-top: 10px; }
.wall-tile {
  aspect-ratio: 16/10; border-radius: 10px; cursor: pointer; border: 2px solid transparent;
  background-size: cover; background-position: center;
}
.wall-tile.active { border-color: var(--accent); }
/* "No background" tile — dashed, centered ✕ */
.wall-tile.wall-none-tile {
  border-style: dashed; border-color: var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 20px; background: transparent;
}
.wall-tile.wall-none-tile:hover { border-color: var(--accent); color: var(--accent); }
.wall-tile.wall-none-tile.active { border-style: solid; border-color: var(--accent); color: var(--accent); }

/* Lists (bookmarks/history) */
.item-list { max-height: 380px; overflow-y: auto; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px;
}
.list-item + .list-item { border-top: 1px solid var(--border); }
.list-item .li-title { font-size: 13.5px; font-weight: 600; }
.list-item .li-sub { font-size: 11.5px; color: var(--muted); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-actions { margin-left: auto; display: flex; gap: 6px; }

/* Custom engines list */
.engine-list { display: flex; flex-direction: column; }
.ce-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
}
.ce-row + .ce-row { border-top: 1px solid var(--border); }
.ce-row .li-title { font-size: 13.5px; font-weight: 600; }
.ce-row .li-sub { font-size: 11.5px; color: var(--muted); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ce-row .li-actions { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }

/* Custom dialog overlays */
.dlg-overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 9, 0.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 200;
}
.dlg-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; width: 380px; max-width: 92vw;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
}
.dlg-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.dlg-msg { font-size: 13px; color: var(--muted); line-height: 1.5; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dlg-input {
  width: 100%; min-width: 0; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: var(--fg); font-size: 13px; outline: none;
}

/* Utility */
.hidden { display: none !important; }

/* Empty / hint */
.empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 11px 22px; border-radius: 999px;
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 0.25s; z-index: 50;
}
.toast.show { opacity: 1; }

@media (max-width: 760px) {
  .sidebar { width: 68px; padding: 20px 8px; }
  .side-brand .side-name, .side-item span:not(.ico), .side-search { display: none; }
  .side-item { justify-content: center; padding: 12px 6px; }
  .main { padding: 26px 20px 50px; }
  .wall-grid { grid-template-columns: repeat(3, 1fr); }
}