:root {
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #0b1018;
  color: #f2f5fa;
  --surface: #121a27;
  --field: #0c1420;
  --border: #2b3a50;
  --muted: #b2bfd5;
  --accent: #80efdc;
  --danger: #ffb5be;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; line-height: 1.55; }
input, select, button, textarea { font: inherit; }
button, select, summary { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.wrap { width: min(100% - 48px, 1140px); margin-inline: auto; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.skip-link:focus { position: fixed; top: 1rem; left: 1rem; z-index: 4; padding: .6rem 1rem; background: var(--field); color: var(--accent); }

.topbar { background: #0d1420; border-bottom: 1px solid #202c3d; }
.topbar-inner, .topbar-actions { display: flex; align-items: center; gap: 1rem; }
.topbar-inner { min-height: 68px; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; font-weight: 600; text-decoration: none; white-space: nowrap; }
.brand-mark { display: flex; gap: 3px; transform: rotate(-12deg); }
.brand-mark i { position: relative; width: 10px; height: 20px; border: 1.5px solid var(--accent); border-radius: 6px 2px 2px 6px; }
.brand-mark i + i { border-radius: 2px 6px 6px 2px; background: var(--accent); }
.brand-mark i::after { content: ""; position: absolute; left: 2px; top: 5px; width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
.brand-mark i + i::after { top: 9px; background: #0b1820; }
.text-link { color: var(--muted); text-underline-offset: 4px; }
.text-link:hover { color: var(--accent); }

main { padding-block: 26px 52px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.15rem); line-height: 1.08; letter-spacing: -.05em; }
h2 { font-size: 1.3rem; line-height: 1.22; letter-spacing: -.025em; overflow-wrap: anywhere; }
.eyebrow { display: block; margin-bottom: .35rem; color: var(--accent); font-size: .875rem; font-weight: 650; }
.muted, small { color: var(--muted); }
small { font-size: .875rem; }

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  min-width: 0;
  background: var(--surface);
}
.login-panel {
  width: min(100%, 490px);
  margin: clamp(18px, 7vw, 75px) auto 0;
  padding: clamp(23px, 5vw, 42px);
  background: radial-gradient(ellipse at 101% 0, #173552 0, transparent 55%), var(--surface);
}
.login-panel p { margin-top: .9rem; color: var(--muted); }
.login-panel form { display: grid; gap: .7rem; margin-top: 1.5rem; }
.login-panel .button { margin-top: .45rem; justify-self: start; min-width: 100px; }

.notice {
  margin-bottom: 20px;
  padding: .65rem .9rem;
  border: 1px solid #33516a;
  border-radius: 10px;
  color: #dceaff;
  background: #122337;
  overflow-wrap: anywhere;
}
.notice[data-tone="success"] { border-color: #326259; color: #aef5e4; background: #122c2b; }
.notice[data-tone="error"] { border-color: #744653; color: #ffd6dc; background: #32202a; }

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.workspace-actions, .dialog-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: .5rem .8rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 650;
  font-size: .9375rem;
  text-align: center;
  white-space: nowrap;
}
.button-primary { color: #09221e; background: var(--accent); }
.button-primary:not(:disabled):hover { background: #a7fae8; }
.button-secondary { color: inherit; background: #192537; border-color: #34455f; }
.button-secondary:not(:disabled):hover { background: #233449; }
.button-danger { color: var(--danger); background: #31202a; border-color: #714455; }
.button-danger:not(:disabled):hover { background: #462934; }
button:disabled { opacity: .55; cursor: not-allowed; }

.editor-grid { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); align-items: start; gap: 18px; }
.records { padding: 16px; }
.records-header, .form-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.records-filter { display: grid; gap: 9px; margin-top: 14px; }
#entry-count { margin: 11px 0 6px; font-size: .875rem; }
.entry-list { list-style: none; display: grid; align-content: start; gap: 4px; margin: 0; padding: 2px; max-height: 50vh; min-height: 84px; overflow-y: auto; scrollbar-color: #3a5169 var(--surface); }
.entry-list button {
  appearance: none;
  width: 100%;
  min-height: 51px;
  display: grid;
  justify-items: start;
  gap: 2px;
  padding: .4rem .65rem;
  text-align: left;
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 7px;
  line-height: 1.32;
  overflow-wrap: anywhere;
}
.entry-list button:hover { background: #1b293b; }
.entry-list button[aria-pressed="true"] { border-color: #42867e; background: #133032; color: #d6fff5; }
.entry-list .entry-meta { color: var(--muted); font-size: .875rem; }
.entry-list .no-results { padding: .6rem; color: var(--muted); }
.catalog-date { display: grid; gap: .4rem; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

.editor { padding: clamp(17px, 2.5vw, 28px); }
.form-heading { margin-bottom: 18px; }
#dirty-status { margin-top: .3rem; font-size: .9375rem; }
#dirty-status[data-dirty="true"] { color: #ffdfad; }
.empty { padding: 22px 0; color: var(--muted); }
.entry-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  padding: 0;
  margin: 0;
  border: 0;
  min-width: 0;
}
.field { min-width: 0; display: grid; gap: .35rem; align-content: start; }
.full { grid-column: 1 / -1; }
label { font-size: .9375rem; font-weight: 600; }
label .muted { font-weight: 400; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  color: inherit;
  padding: .52rem .67rem;
  border: 1px solid #354862;
  border-radius: 8px;
  background: var(--field);
}
input::placeholder, textarea::placeholder { color: #9bacc5; }
select {
  appearance: none;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, #afc2dc 50%), linear-gradient(135deg, #afc2dc 50%, transparent 50%);
  background-position: right 15px center, right 10px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
[aria-invalid="true"] { border-color: #ff8698; }
.field-error { color: var(--danger); font-size: .875rem; }
textarea { resize: vertical; }
.id-field { padding-top: .75rem; border-top: 1px solid var(--border); }
.id-field summary { color: var(--muted); font-size: .9375rem; }
.id-field[open] summary { margin-bottom: .6rem; }
.id-field label, .id-field small { display: block; }
.id-field label { margin-bottom: .35rem; }
.id-field small { margin-top: .35rem; }

dialog { width: min(100% - 32px, 425px); padding: 24px; border: 1px solid #465e7c; border-radius: 14px; color: inherit; background: var(--surface); }
dialog::backdrop { background: #02050acd; }
dialog p { margin: .8rem 0 1.3rem; color: var(--muted); overflow-wrap: anywhere; }
.dialog-actions { justify-content: end; }

@media (max-width: 740px) {
  .wrap { width: calc(100% - 32px); }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .entry-list { max-height: 235px; }
  .records-filter { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 495px) {
  .topbar-inner { flex-wrap: wrap; padding-block: .7rem; gap: .5rem; }
  .topbar-actions { gap: .65rem; }
  .topbar-actions .text-link, .topbar-actions .button { font-size: .875rem; }
  .workspace-heading { align-items: start; flex-direction: column; }
  .entry-fields, .records-filter { grid-template-columns: minmax(0, 1fr); }
}
