:root {
  --bg: #F7F3EC; --surface: #FFFDF9; --sunk: #EFE9DF; --line: #E2D9CB;
  --fg: #1C1D2B; --muted: #696677;
  --accent: #2B2F6B; --accent-ink: #FFFFFF; --accent-soft: #E4E4F3;
  --warn: #A1361F;
  --display: "Fraunces", Georgia, serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgb(40 30 10 / .05), 0 6px 18px rgb(40 30 10 / .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14151F; --surface: #1D1E2B; --sunk: #262838; --line: #34364A;
    --fg: #ECEAF2; --muted: #A3A1B3;
    --accent: #A9AEF2; --accent-ink: #14151F; --accent-soft: #2C2F4D;
    --warn: #F0907A; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14151F; --surface: #1D1E2B; --sunk: #262838; --line: #34364A;
  --fg: #ECEAF2; --muted: #A3A1B3;
  --accent: #A9AEF2; --accent-ink: #14151F; --accent-soft: #2C2F4D;
  --warn: #F0907A; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; text-wrap: balance; font-weight: 700; }
h1 { font-size: clamp(2rem, 7vw, 2.8rem); letter-spacing: -.02em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; margin-bottom: 8px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.wrap {
  max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px calc(32px + env(safe-area-inset-bottom, 0px));
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.brand img { border-radius: 8px; }
.eyebrow { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.section-title { font-family: var(--body); font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 12px; }

.btn {
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; min-height: 44px;
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 38px; padding: 7px 14px; font-size: .9rem; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn:focus-visible, .chip:focus-visible, .tile:focus-visible, input:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }

.chip {
  display: flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  padding: 4px 12px 4px 4px; min-height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--fg);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: .9rem;
}

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-weight: 600; font-size: .9rem; }
input {
  font: inherit; font-size: 1rem; padding: 10px 12px; min-height: 44px; border-radius: 12px; min-width: 0;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
}
.msg { margin-top: 10px; font-size: .92rem; color: var(--warn); min-height: 0; }
.msg:empty { display: none; }
.msg.ok { color: var(--muted); }

.apps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.tile {
  display: flex; gap: 14px; align-items: flex-start; height: 100%; padding: 16px; border-radius: 18px; text-decoration: none; color: var(--fg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); transition: transform .15s ease, border-color .15s ease;
}
a.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .mark {
  width: 48px; height: 48px; border-radius: 14px; flex: none; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 1.4rem; color: #fff;
}
.tile .name { font-weight: 600; font-size: 1.02rem; }
.tile .blurb { color: var(--muted); font-size: .9rem; line-height: 1.35; margin-top: 2px; }
.tile .host { color: var(--muted); font-size: .78rem; margin-top: 6px; overflow-wrap: anywhere; }
.tile.soon { box-shadow: none; background: transparent; border-style: dashed; }
.tile.soon .mark { opacity: .45; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); margin-top: 6px; }
.foot { text-align: center; }

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--fg); box-shadow: 0 20px 60px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(10 10 25 / .45); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sheet-body { padding: 4px 16px 18px; }
.sheet-body section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.sheet-body section:last-of-type { border-bottom: 0; }
.sheet-body .row:first-child { margin-top: 0; }
#rename input { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { color: var(--muted); font-size: .84rem; }
.link input { width: 100%; font-size: .88rem; }
.link-btn { font: inherit; font-size: .88rem; font-weight: 600; background: none; border: 0; color: var(--warn); cursor: pointer; padding: 8px; min-height: 40px; }

.apps-pick { border: 0; padding: 0; margin: 14px 0 0; }
.apps-pick legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; min-height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); font-size: .86rem; cursor: pointer; }
.check input { min-height: 0; margin: 0; accent-color: var(--accent); width: 16px; height: 16px; }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.list li.member { flex-wrap: wrap; }
.list li.member .checks { flex-basis: 100%; padding-left: 44px; }
.empty { color: var(--muted); font-size: .92rem; }
