:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --hover: #ecece8;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --line: #deded9;
  --accent: #1f5fbf;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171716;
    --surface: #222220;
    --hover: #2e2e2b;
    --text: #efefeb;
    --muted: #a3a39c;
    --line: #363632;
    --accent: #8ab4f8;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 0;
}

.account-actions { display: flex; align-items: center; gap: 4px; }
.user-name { margin-right: 8px; font-size: 13px; color: var(--muted); }

.login {
  display: grid;
  gap: 10px;
  max-width: 340px;
  margin: 18vh auto 0;
  padding: 0 24px;
}
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0 0 10px; color: var(--muted); }
.login .form-error { color: #c5362c; }

.notice {
  max-width: 680px;
  margin: 0 auto 16px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.clock { color: var(--muted); }
#time { color: var(--text); font-weight: 600; margin-right: 10px; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 7vh 24px 48px;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { background: var(--hover); }
button.quiet { background: transparent; border-color: transparent; color: var(--muted); }
button.quiet:hover { background: var(--hover); color: var(--text); }
button[aria-pressed="true"] { color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.search {
  position: relative;
  max-width: 680px;
  margin: 0 auto 48px;
}

#query {
  width: 100%;
  padding: 15px 20px;
  font: inherit;
  font-size: 17px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
#query:focus { outline: none; border-color: var(--accent); }

.results {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.16);
}
.results li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
}
.results li.active { background: var(--hover); }
.results .label { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.results .kind { color: var(--muted); font-size: 13px; }

.groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 28px;
}

h2 {
  margin: 0 0 8px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.group-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.group-title h2 { margin: 0; }
.group-title input { width: 100%; }

.link-row { display: flex; align-items: center; }

a.link {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  color: inherit;
  text-decoration: none;
  border-radius: 9px;
}
a.link:hover { background: var(--hover); }
a.link span.name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 5px;
}
.icon.letter {
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--hover);
}

.remove {
  flex: none;
  padding: 2px 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.add-form { display: grid; gap: 6px; margin-top: 8px; padding: 0 10px; }
input.field {
  width: 100%;
  padding: 6px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.form-error { margin: 0; font-size: 13px; color: #c5362c; }

.edit-actions { display: flex; gap: 8px; margin-top: 28px; }

.auto { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.auto .links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px 28px;
}
