/* region: search */
:root {
  color-scheme: light;
  --ground: #e9eef2;
  --surface: #f7f9fb;
  --ink: #1b2733;
  --muted: #5b6978;
  --rule: #c9d2db;
  --hue-0: #1f5fbf;
  --hue-1: #b04a0c;
  --hue-2: #2b7a34;
  --hue-3: #a3287a;
  --hue-4: #0e7479;
  --hue-5: #86660a;
  --field: 1.5rem;
  --inset-top: env(safe-area-inset-top, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #16202b;
    --surface: #1d2935;
    --ink: #e4eaf0;
    --muted: #93a1b0;
    --rule: #2f3d4b;
    --hue-0: #72a8ff;
    --hue-1: #f0995a;
    --hue-2: #72c47a;
    --hue-3: #e883c8;
    --hue-4: #52c6cb;
    --hue-5: #d8b64a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #16202b;
  --surface: #1d2935;
  --ink: #e4eaf0;
  --muted: #93a1b0;
  --rule: #2f3d4b;
  --hue-0: #72a8ff;
  --hue-1: #f0995a;
  --hue-2: #72c47a;
  --hue-3: #e883c8;
  --hue-4: #52c6cb;
  --hue-5: #d8b64a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 max(1rem, env(safe-area-inset-left, 0px)) calc(2rem + var(--inset-bottom));
}

.hue-0 { --hue: var(--hue-0); }
.hue-1 { --hue: var(--hue-1); }
.hue-2 { --hue: var(--hue-2); }
.hue-3 { --hue: var(--hue-3); }
.hue-4 { --hue: var(--hue-4); }
.hue-5 { --hue: var(--hue-5); }

button {
  font: inherit;
  color: var(--ink);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 0.375rem;
  padding: 0.375rem 0.875rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--muted);
}

button:disabled {
  color: var(--muted);
  cursor: default;
}

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

.quiet {
  color: var(--muted);
}

#tags {
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 0.375rem;
  padding: 0.5rem 0.625rem;
}

#tags:focus-visible {
  outline-offset: 0;
}

.error {
  margin: 0;
  font-size: 0.875rem;
  border-left: 3px solid var(--hue-1);
  padding-left: 0.625rem;
}

header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: calc(1.25rem + var(--inset-top)) 0 0.75rem;
  background: var(--ground);
  border-bottom: 2px solid var(--rule);
  margin-bottom: 0.5rem;
}

header:focus-within {
  border-bottom-color: var(--ink);
}

.field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.field input,
.paint {
  font: inherit;
  font-size: var(--field);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
  padding: 0.25rem 0;
  margin: 0;
  border: 0;
  width: 100%;
  white-space: pre;
}

.field input {
  position: relative;
  display: block;
  background: transparent;
  color: transparent;
  caret-color: var(--ink);
  outline: none;
}

.field input::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.field input::selection {
  color: transparent;
  background: color-mix(in srgb, var(--hue-0) 25%, transparent);
}

.paint {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: var(--ink);
  pointer-events: none;
}

.paint .hit {
  color: var(--hue);
}

#count {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#results {
  list-style: none;
  margin: 0;
  padding: 0;
}

#results li {
  cursor: pointer;
  padding: 0.625rem 0 0.625rem 0.875rem;
  border-left: 3px solid transparent;
  margin-left: -0.875rem;
}

#results li.selected {
  border-left-color: var(--ink);
}

.title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}

#results li:hover .title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.hit {
  text-decoration: underline;
  text-decoration-color: var(--hue);
  text-decoration-thickness: 3px;
  text-underline-offset: 0.22em;
  text-decoration-skip-ink: none;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.875rem;
  margin: 0.125rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.host {
  margin-left: auto;
  overflow-wrap: anywhere;
}

#none {
  padding-top: 1rem;
  color: var(--muted);
}

#none p {
  margin: 0 0 0.5rem;
}

#none ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

#none .word {
  color: var(--ink);
  font-weight: 600;
}

#more {
  margin: 1rem 0 0;
  font-size: 0.875rem;
}

#stranded {
  display: grid;
  gap: 0.25rem;
  margin: 0.75rem 0;
}

#stranded p {
  margin: 0;
}

#stranded a {
  color: var(--ink);
  font-weight: 600;
}

footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
}

footer #status {
  margin: 0 auto 0 0;
}

#edit nav {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: calc(1.25rem + var(--inset-top)) 0 0.75rem;
  background: var(--ground);
}

#saved {
  margin: 0 0 0 auto;
  font-size: 0.875rem;
  color: var(--muted);
}

#saved.error {
  color: var(--ink);
}

#missing {
  margin: 1rem 0;
}

#fields {
  display: grid;
  gap: 1.25rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.source {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.875rem;
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

#url {
  color: var(--muted);
  overflow-wrap: anywhere;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

#url[href]:hover {
  color: var(--ink);
}

#url:not([href]) {
  text-decoration: none;
}

#edit-form label {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.875rem;
}

#tags::placeholder {
  color: var(--muted);
}

#tags {
  display: block;
  width: 100%;
  line-height: 1.45;
  resize: none;
  overflow: hidden;
}

fieldset:disabled #tags {
  opacity: 0.6;
}


@media (max-width: 30rem) {
  :root {
    --field: 1.25rem;
  }

  .host {
    margin-left: 0;
    flex-basis: 100%;
  }

  footer #status {
    flex-basis: 100%;
  }
}

/* region: search-login */
#login {
  padding-top: calc(12vh + var(--inset-top));
}

#login h1 {
  font-size: var(--field);
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 2rem;
}

#login-form {
  display: grid;
  gap: 1.125rem;
  max-width: 26rem;
}

#login-form label {
  display: grid;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.875rem;
}

#login-form input {
  font: inherit;
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 0.375rem;
  padding: 0.5rem 0.625rem;
}

#login-form input:focus-visible {
  outline-offset: 0;
}

#login-form button {
  justify-self: start;
  background: var(--ink);
  color: var(--ground);
  border-color: var(--ink);
  font-weight: 600;
}

.hint {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

#login-error {
  margin: 0;
  font-size: 0.875rem;
}
