/* dash — a self-hosted-style dashboard for a Solid pod.
 * Dark-first (like gethomepage) with a light-mode swap via
 * prefers-color-scheme; every colour is a token so both themes stay honest. */

/* Base = dark. --accent-soft derives from --accent, so setting a single
 * custom --accent (theme override, or the board's accent) recolours the whole
 * UI. Theme resolution: no [data-theme] follows the OS (auto); an explicit
 * [data-theme="dark"|"light"] on <html> overrides it. */
:root {
  --bg: #0b1020;
  --bg-2: #0e1428;
  --panel: rgba(255,255,255,0.035);
  --panel-2: rgba(255,255,255,0.06);
  --line: rgba(255,255,255,0.08);
  --line-2: rgba(255,255,255,0.14);
  --text: #eef1f8;
  --dim: rgba(238,241,248,0.62);
  --faint: rgba(238,241,248,0.38);
  --accent: #6ea8fe;
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --up: #34d399;
  --down: #f87171;
  --unknown: rgba(238,241,248,0.28);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.28);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
/* light tokens — one block, applied to auto-on-light and to explicit light */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f7; --bg-2: #e6eaf3;
    --panel: rgba(15,23,42,0.03); --panel-2: rgba(15,23,42,0.05);
    --line: rgba(15,23,42,0.08); --line-2: rgba(15,23,42,0.14);
    --text: #131a2b; --dim: rgba(19,26,43,0.62); --faint: rgba(19,26,43,0.42);
    --accent: #2563eb; --unknown: rgba(19,26,43,0.22);
    --shadow: 0 1px 2px rgba(15,23,42,.08), 0 8px 20px rgba(15,23,42,.08);
  }
}
:root[data-theme="light"] {
  --bg: #eef1f7; --bg-2: #e6eaf3;
  --panel: rgba(15,23,42,0.03); --panel-2: rgba(15,23,42,0.05);
  --line: rgba(15,23,42,0.08); --line-2: rgba(15,23,42,0.14);
  --text: #131a2b; --dim: rgba(19,26,43,0.62); --faint: rgba(19,26,43,0.42);
  --accent: #2563eb; --unknown: rgba(19,26,43,0.22);
  --shadow: 0 1px 2px rgba(15,23,42,.08), 0 8px 20px rgba(15,23,42,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  /* rich default mesh — vivid, layered orbs, not flat grey */
  background:
    radial-gradient(1100px 780px at 8% -12%, rgba(99,102,241,0.34), transparent 56%),
    radial-gradient(1000px 720px at 100% 2%, rgba(168,85,247,0.28), transparent 55%),
    radial-gradient(1200px 820px at 50% 122%, rgba(34,211,238,0.18), transparent 55%),
    radial-gradient(760px 560px at 88% 92%, rgba(236,72,153,0.16), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) body {
    background:
      radial-gradient(1000px 720px at 8% -12%, rgba(99,102,241,0.22), transparent 56%),
      radial-gradient(900px 660px at 100% 2%, rgba(168,85,247,0.18), transparent 55%),
      radial-gradient(1100px 780px at 50% 122%, rgba(14,165,233,0.14), transparent 55%),
      linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
  }
}

/* over a rich background (image or gradient preset) force a dark, legible
   palette regardless of theme — light text + frosted panels on the artwork */
body.dark-bg {
  --bg: #0a0c16;
  --text: #f2f4fb; --dim: rgba(242,244,251,0.72); --faint: rgba(242,244,251,0.5);
  --line: rgba(255,255,255,0.10); --line-2: rgba(255,255,255,0.18);
  --panel: rgba(255,255,255,0.05); --panel-2: rgba(255,255,255,0.09);
  --unknown: rgba(242,244,251,0.32);
  --shadow: 0 1px 2px rgba(0,0,0,0.45), 0 14px 34px rgba(0,0,0,0.4);
  background: var(--bg);
}
/* over a light/warm preset — force a dark-on-light palette (indie-web feel)
   regardless of the OS theme, so a light board stays light everywhere */
body.light-bg {
  --bg: #f4ecdf;
  --text: #241f17; --dim: rgba(36,31,23,0.66); --faint: rgba(36,31,23,0.44);
  --line: rgba(40,30,15,0.12); --line-2: rgba(40,30,15,0.20);
  --panel: rgba(40,30,15,0.035); --panel-2: rgba(40,30,15,0.06);
  --unknown: rgba(36,31,23,0.26);
  --shadow: 0 1px 2px rgba(40,30,15,0.08), 0 12px 30px rgba(40,30,15,0.10);
  background: var(--bg);
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: 46px; padding: 0 18px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: 0.02em; font-size: 15px; color: var(--accent); }
.topbar-r { display: flex; align-items: center; gap: 12px; }
.root { color: var(--dim); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.root:hover { color: var(--text); }
.tbtn {
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: 9px;
  padding: 5px 12px; cursor: pointer; transition: background .15s, border-color .15s;
}
.tbtn:hover { background: var(--accent-soft); border-color: var(--accent); }
.tbtn.on { background: var(--accent); border-color: transparent; color: #fff; }

/* ---------- layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 26px 20px 80px; }

/* header widgets */
.head { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: end; margin-bottom: 22px; }
.head-l { min-width: 0; }
.greet { font-size: 15px; color: var(--dim); font-weight: 500; }
.h-title { font-size: 30px; font-weight: 300; letter-spacing: -0.01em; margin-top: 2px; }
.head-r { text-align: right; }
.clock { font-size: 40px; font-weight: 200; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.cdate { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.wx { font-size: 13px; color: var(--dim); margin-top: 6px; display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.wx .wt { font-weight: 600; color: var(--text); }

/* search */
.searchbar { margin: 0 0 26px; display: flex; }
.searchbar form { position: relative; flex: 1; }
.searchbar .si {
  width: 100%; font: inherit; font-size: 14px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 12px 14px 12px 42px; outline: none; transition: border-color .15s, background .15s, box-shadow .15s;
}
.searchbar .si::placeholder { color: var(--faint); }
.searchbar .si:focus { border-color: var(--accent); background: var(--panel-2); box-shadow: 0 0 0 4px var(--accent-soft); }
.searchbar .mag { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); opacity: .45; font-size: 14px; pointer-events: none; }
.searchbar .prov { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font: inherit; font-size: 11.5px; color: var(--dim); background: transparent; border: 0; cursor: pointer; }

/* ---------- groups of services ---------- */
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; align-items: start; }
.group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 6px; }
.group-h { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 10px; }
.group-h h2 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.group-h .ga { display: flex; gap: 4px; }
.svc-list { display: grid; gap: 6px; }
.group.cols-2 .svc-list { grid-template-columns: 1fr 1fr; }
.group.cols-3 .svc-list { grid-template-columns: repeat(3, minmax(0,1fr)); }
.group.cols-4 .svc-list { grid-template-columns: repeat(4, minmax(0,1fr)); }
/* denser columns → compact tiles (icon + name), gethomepage-style */
.group.cols-3 .svc, .group.cols-4 .svc { padding: 8px; gap: 8px; }
.group.cols-3 .svc-ico, .group.cols-4 .svc-ico { width: 30px; height: 30px; }
.group.cols-3 .svc-sub, .group.cols-4 .svc-sub { display: none; }
@media (max-width: 640px) { .group.cols-3 .svc-list, .group.cols-4 .svc-list { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .group.cols-2 .svc-list { grid-template-columns: 1fr; } }

/* custom background layer (image with blur, or a solid colour) + theme scrim */
#dash-bg { position: fixed; inset: -16px; z-index: -1; background-size: cover; background-position: center; background-repeat: no-repeat; }
#dash-bg::after { content: ''; position: absolute; inset: 0; background: var(--bg); opacity: var(--scrim, 0); }
body.custom-bg { background: var(--bg); }
/* on a photo the panels want a touch more opacity to stay legible */
body.custom-bg .group, body.custom-bg .bm { backdrop-filter: blur(6px); }

.svc {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid transparent;
  text-decoration: none; color: var(--text);
  transition: border-color .15s, transform .1s, background .15s;
  position: relative; min-width: 0;
}
.svc:hover { border-color: var(--accent); transform: translateY(-1px); }
.svc-ico {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; font-size: 18px; color: #fff; font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
}
.svc-ico img { width: 22px; height: 22px; object-fit: contain; display: block; }
/* logo chip — real service logos (packs / URLs / favicons) read best on white */
.svc-ico.logo { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.15), inset 0 0 0 1px rgba(0,0,0,.05); }
.svc-ico.logo img { width: 24px; height: 24px; }
.svc-body { min-width: 0; flex: 1; }
.svc-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-sub { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svc-status {
  flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%;
  background: var(--unknown); transition: background .3s, box-shadow .3s;
}
.svc-status.up { background: var(--up); box-shadow: 0 0 8px color-mix(in srgb, var(--up) 60%, transparent); }
.svc-status.down { background: var(--down); }
.svc-status.checking { animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* ---------- bookmarks ---------- */
.bm-wrap { margin-top: 24px; }
.bm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.bm-group h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 2px 8px; }
.bm-list { display: flex; flex-wrap: wrap; gap: 6px; }
.bm {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 6px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  text-decoration: none; color: var(--dim); font-size: 12.5px; font-weight: 500;
  transition: color .15s, border-color .15s, background .15s;
}
.bm:hover { color: var(--text); border-color: var(--line-2); background: var(--accent-soft); }
.bm-abbr {
  width: 20px; height: 20px; border-radius: 6px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 9.5px; font-weight: 800; color: #fff; letter-spacing: -0.02em;
}

/* ---------- edit affordances ---------- */
.editing .svc, .editing .bm { padding-right: 30px; }
.ic-btn {
  font: inherit; background: transparent; border: 0; cursor: pointer;
  color: var(--faint); border-radius: 7px; padding: 3px 6px; line-height: 1;
}
.ic-btn:hover { color: var(--text); background: var(--panel-2); }
.svc .del, .bm .del {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  display: none; color: var(--down); font-size: 15px; line-height: 1;
  background: transparent; border: 0; cursor: pointer; padding: 4px;
}
.editing .svc .del, .editing .bm .del { display: block; }
.add-svc {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; margin-top: 4px; border-radius: 10px; cursor: pointer;
  border: 1px dashed var(--line-2); color: var(--dim); font-size: 12.5px; font-weight: 600;
  background: transparent;
}
.add-svc:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.add-group {
  display: block; margin: 18px auto 0; padding: 9px 18px; border-radius: 11px;
  border: 1px dashed var(--line-2); background: transparent; color: var(--dim);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.add-group:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- states ---------- */
.center { text-align: center; color: var(--dim); }
.hero {
  max-width: 560px; margin: 6vh auto 0; text-align: center; padding: 0 20px;
}
.hero .logo { font-size: 50px; margin-bottom: 10px; }
.hero h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.hero p { color: var(--dim); font-size: 14.5px; line-height: 1.6; margin: 12px auto 0; max-width: 46ch; }
.hero .cta { margin-top: 22px; display: inline-flex; gap: 10px; }
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  padding: 10px 18px; border-radius: 11px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn:hover { filter: brightness(1.06); }
.demo-note {
  text-align: center; font-size: 12.5px; color: var(--faint);
  margin: 0 0 22px; padding: 8px 14px; border: 1px dashed var(--line);
  border-radius: 10px; max-width: 640px; margin-left: auto; margin-right: auto;
}
.err {
  max-width: 560px; margin: 8vh auto 0; text-align: center;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 26px 24px; color: var(--dim);
}
.err strong { color: var(--text); display: block; font-size: 15px; margin-bottom: 8px; }
.loading { text-align: center; color: var(--faint); padding: 12vh 0; font-size: 13.5px; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(3px); padding: 20px;
}
.modal {
  width: min(440px, 100%); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow);
  padding: 20px; max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--dim); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 9px 11px; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 12px; }
.field.row { display: flex; gap: 10px; align-items: center; }
.field.row label { margin: 0; }
.field.inline { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.modal-actions .left { display: flex; gap: 8px; }

/* ---------- appearance controls ---------- */
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--dim);
  background: transparent; border: 0; border-radius: 7px; padding: 6px 14px; cursor: pointer;
}
.seg button.on { background: var(--accent); color: #fff; }
.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; outline: 1px solid var(--line-2); outline-offset: 1px;
  position: relative; padding: 0;
}
.swatch.on { border-color: var(--text); }
.swatch.def { background: var(--panel-2); display: grid; place-items: center; font-size: 12px; color: var(--dim); outline: 1px dashed var(--line-2); }
.bg-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.bg-preset {
  width: 48px; height: 30px; border-radius: 8px; cursor: pointer; padding: 0;
  border: 2px solid transparent; outline: 1px solid var(--line-2); outline-offset: 1px;
  background-size: cover; background-position: center;
}
.bg-preset.on { border-color: var(--text); }
.bg-preset.none { display: grid; place-items: center; font-size: 13px; color: var(--dim); background: var(--panel-2); outline-style: dashed; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(12px);
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 11px; padding: 10px 16px; font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: min(460px, calc(100vw - 32px)); z-index: 70;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--down); }

@media (max-width: 560px) {
  .head { grid-template-columns: 1fr; }
  .head-r { text-align: left; }
  .wx { justify-content: flex-start; }
  .clock { font-size: 34px; }
  .h-title { font-size: 24px; }
}
