:root {
  color-scheme: dark;
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
  background: #0f172a;
  color: #e5e7eb;
  --card: #1e293b;
  --edge: #334155;
  --muted: #a4b1c4;
  --accent: #93c5fd;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
           max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
main { max-width: 44rem; margin-inline: auto; }
h1, h2, p { margin: 0; }
.masthead, .dialog-top { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
h1 { color: #f1f5f9; font-size: clamp(1.4rem, 6vw, 2rem); letter-spacing: -.055em; }
h2 { font-size: 1.25rem; }
button, select, textarea { font: inherit; }
button, select {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: .65rem;
}
button {
  padding: .6rem .9rem;
  background: var(--accent);
  color: #0f172a;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: .6; cursor: progress; }
.secondary { background: var(--card); color: #e5e7eb; border-color: #475569; }
form {
  margin: 1.1rem 0 1.35rem;
  display: grid;
  gap: .45rem .5rem;
  grid-template-columns: minmax(0, 1fr) auto;
}
form label, form small { grid-column: 1 / -1; }
label, small, #count, .metadata, .status, #history-status { color: var(--muted); font-size: .86rem; }
textarea, select {
  min-width: 0;
  background: var(--card);
  border: 1px solid #475569;
  border-radius: .65rem;
  color: #f1f5f9;
  padding: .66rem .75rem;
  font-size: 1rem;
}
textarea { width: 100%; min-height: 44px; resize: vertical; }
.filter-row { margin: 0 0 .75rem; display: flex; align-items: end; justify-content: space-between; gap: .6rem; }
.filter-row > div { min-width: 0; }
.filter-row label { display: block; margin-bottom: .25rem; }
.filter-row select { max-width: 100%; text-overflow: ellipsis; }
#count { white-space: nowrap; padding-bottom: .75rem; }
.status:not(:empty), #history-status:not(:empty) { margin: .55rem 0 .8rem; line-height: 1.55; }
#cards { display: grid; gap: .75rem; }
.card { background: var(--card); border: 1px solid var(--edge); border-radius: .8rem; padding: .95rem; min-width: 0; }
.card h2 { font-size: 1.12rem; line-height: 1.45; overflow-wrap: anywhere; }
.card h2 a { color: #f1f5f9; text-decoration: none; }
.metadata { margin: .43rem 0 .65rem; line-height: 1.5; overflow-wrap: anywhere; }
.preview { color: #e5e7eb; line-height: 1.65; overflow-wrap: anywhere; }
.preview p + p { margin-top: .4rem; }
.card footer { margin-top: .7rem; display: flex; justify-content: flex-end; }
.more { display: block; width: 100%; margin-top: .8rem; }
dialog {
  width: min(34rem, calc(100% - 2rem));
  max-height: 75vh;
  padding: 1rem;
  border-radius: .8rem;
  background: #0f172a;
  color: #e5e7eb;
  border: 1px solid #475569;
}
dialog::backdrop { background: #020617bb; }
#history-items { display: grid; gap: .5rem; margin: .7rem 0; }
.history-item { display: grid; text-align: left; gap: .25rem; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.login { max-width: 25rem; margin: 8vh auto 0; }
.login h1 { margin-bottom: 1.25rem; }
.login-form { grid-template-columns: minmax(0, 1fr); row-gap: .65rem; }
.login-form input {
  min-height: 44px;
  min-width: 0;
  padding: .65rem .75rem;
  background: var(--card);
  color: #f1f5f9;
  border: 1px solid #475569;
  border-radius: .65rem;
  font: inherit;
}
.login-form button { margin-top: .35rem; }
.login-error { color: #fca5a5; line-height: 1.55; }
