:root {
  color-scheme: dark;
  --ink: #eaf0fa;
  --muted: #b9c7da;
  --gold: #f4ce80;
  --blue: #a8cbff;
  --line: #344b69;
  --surface: #111e30;
  --background: #080f1c;
  --success: #b7f3d9;
  --error: #ffbea9;
  font: 16px/1.55 "Segoe UI", system-ui, sans-serif;
}

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

body {
  min-width: 0;
  margin: 0;
  background: var(--background);
  color: var(--ink);
}

a { color: var(--blue); text-underline-offset: 4px; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.shell {
  width: min(960px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  background: #0c1625;
  border-bottom: 1px solid var(--line);
}

.header-content, .header-actions, .brand, .actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-content {
  min-height: 73px;
  justify-content: space-between;
  padding-block: 10px;
}

.brand {
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  line-height: 1.25;
}

.brand-mark {
  display: grid;
  flex: 0 0 36px;
  height: 40px;
  place-items: center;
  color: #111e30;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 0, 100% 67%, 50% 100%, 0 67%);
  font-size: 21px;
}

.site-link { flex-shrink: 0; }
.header-actions { flex-wrap: wrap; justify-content: flex-end; }
main.shell { padding-block: clamp(26px, 6vw, 55px) 0; }

h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 5.5vw, 51px);
  line-height: 1.05;
  letter-spacing: -.045em;
}

.intro { margin: 0 0 30px; color: var(--muted); }

.filters {
  display: grid;
  grid-template-columns: minmax(180px, .85fr) minmax(0, 1.15fr);
  gap: 18px;
  padding: clamp(14px, 3.5vw, 22px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #14243a;
}

.filters label, .field label {
  display: block;
  font-size: .9375rem;
  font-weight: 650;
}

input, textarea, select {
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #526988;
  border-radius: 8px;
  background: #0b1626;
  color: var(--ink);
  font-weight: 400;
  scroll-margin-block-end: 160px;
}

input::placeholder { color: var(--muted); }
textarea { min-height: 5.5rem; resize: vertical; }

.filters select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--blue) 50%), linear-gradient(135deg, var(--blue) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.sections {
  display: grid;
  gap: 16px;
  margin-block: 18px;
}

.section {
  min-width: 0;
  padding: clamp(14px, 3.5vw, 23px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.section h2 {
  margin: 0 0 13px;
  color: var(--ink);
  font-size: clamp(19px, 3.5vw, 24px);
  line-height: 1.25;
}

.field + .field { margin-top: 15px; }
.login { width: min(100%, 440px); margin-top: 16px; }
.login label { font-weight: 650; }
.login .button { margin-top: 14px; }
.field[data-changed] :is(input, textarea) { border-color: var(--gold); }
.field :is(input, textarea)[aria-invalid="true"] { border-color: var(--error); }
.message { margin: 0; color: var(--muted); font-size: .93rem; }
.message:empty { display: none; }
.message[data-tone="success"] { color: var(--success); }
.message[data-tone="error"] { color: var(--error); }
#no-results { padding: 19px 0 0; }
#load-actions { margin-top: 13px; }

.field-note {
  margin: 6px 0 0;
  color: var(--error);
  font-size: .875rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.editor-footer {
  position: sticky;
  z-index: 1;
  bottom: 0;
  padding: 9px 0 12px;
  background: var(--background);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px clamp(12px, 3.5vw, 20px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #14243a;
}

.change-counter { margin: 0; font-weight: 650; }
.actions { flex-wrap: wrap; }
.footer-actions { justify-content: flex-end; flex-shrink: 0; gap: 8px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.button-primary { background: var(--gold); color: #101b29; }
.button-primary:not(:disabled):hover { background: #ffe0a2; }
.button-secondary { border-color: #526988; background: #111e30; color: var(--ink); }
.button-secondary:not(:disabled):hover { border-color: var(--blue); }
.button:disabled { opacity: .58; cursor: default; }

.link-button {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--blue);
  font-size: .9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

@media (max-width: 670px) {
  .footer-content { align-items: flex-start; flex-direction: column; }
  .footer-actions { width: 100%; }
  .footer-actions .button { flex: 1; }
}

@media (max-width: 460px) {
  .shell { width: calc(100% - 28px); }
  .filters { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .header-content { gap: 7px; }
  .brand { gap: 7px; }
  .header-content, .footer-actions { font-size: .875rem; }
}
