:root {
  color-scheme: dark;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --background: #101416;
  --surface: #181e21;
  --control: #20282c;
  --hover: #2a3539;
  --editor: #101719;
  --border: #36434a;
  --text: #eff4f3;
  --muted: #a4b3b7;
  --accent: #c1f67f;
  --accent-text: #152309;
  --error: #ffb5af;
  --warning: #f8d38a;
  background: var(--background);
  color: var(--text);
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
h1, h2, p, pre { margin: 0; }
h1, h2 { line-height: 1.15; letter-spacing: -.035em; overflow-wrap: anywhere; }
h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); font-weight: 650; }
h2 { font-size: 1.18rem; font-weight: 650; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.muted { color: var(--muted); }

.masthead { background: var(--editor); border-bottom: 1px solid var(--border); }
.masthead-inner {
  width: min(100% - 2rem, 76rem);
  min-height: 4.65rem;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.wordmark { display: flex; align-items: center; gap: .65rem; font-weight: 650; }
.mark, .chip { display: grid; place-items: center; color: var(--accent); font-family: var(--mono); }
.mark { flex: none; min-width: 2.45rem; height: 2.2rem; border-radius: .5rem; background: #243520; border: 1px solid #466346; font-size: .9rem; }
.account, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
.account { justify-content: end; }
.pill {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .24rem .62rem;
  font-size: .8125rem;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}
.pill.current { color: var(--accent); background: #253621; border-color: #466346; }
.pill.current::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; margin-right: .4rem; }

.button {
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  padding: .55rem .9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms, border-color 140ms;
}
.button.primary { background: var(--accent); color: var(--accent-text); }
.button.primary:hover { background: #d5ffa6; }
.button.primary:active { background: #aadf6d; }
.button.secondary { background: var(--control); border-color: var(--border); color: var(--text); }
.button.quiet { background: transparent; color: var(--muted); }
.button.secondary:hover, .button.quiet:hover { background: var(--hover); color: var(--text); }
.button:disabled { opacity: .48; cursor: default; }
.full { width: 100%; }

main { width: min(100% - 2rem, 76rem); margin: 0 auto; }
.loading { padding: 3rem 0; color: var(--muted); }
.login {
  width: min(100%, 61rem);
  min-height: 27rem;
  display: grid;
  grid-template-columns: 1.18fr 1fr;
  margin: clamp(2.5rem, 9vh, 7.5rem) auto 2rem;
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  overflow: hidden;
  box-shadow: 0 1.5rem 6rem #0004;
}
.intro {
  min-height: 100%;
  display: flex;
  position: relative;
  isolation: isolate;
  flex-direction: column;
  justify-content: end;
  gap: 2.75rem;
  padding: clamp(1.6rem, 5vw, 3.35rem);
  background:
    radial-gradient(ellipse at 34% 26%, #375b36 0%, transparent 57%),
    linear-gradient(145deg, #233c2e 0%, #182720 58%, #15211d 100%);
}
.intro::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background-image: linear-gradient(90deg, #a1e98d17 1px, transparent 1px), linear-gradient(#a1e98d17 1px, transparent 1px);
  background-size: 1.65rem 1.65rem;
  mask-image: linear-gradient(#000, transparent 97%);
}
.intro h1 { position: relative; font-size: clamp(2rem, 4.8vw, 3.4rem); line-height: 1.04; letter-spacing: -.06em; }
.intro h1 span { color: var(--accent); }
.circuit { position: relative; display: grid; place-items: center; height: 8.4rem; width: min(100%, 17rem); }
.circuit::before, .circuit::after {
  content: "";
  position: absolute;
  inset: 12% 0;
  border: 1px solid #7db47670;
  border-radius: 1.5rem .65rem;
  transform: rotate(-13deg) scale(.85);
}
.circuit::after { inset: 3% 12%; transform: rotate(13deg); opacity: .7; }
.chip {
  z-index: 1;
  width: 6.2rem;
  aspect-ratio: 1;
  border-radius: 1.2rem;
  border: 1px solid #aae5a0;
  background: #1c2e22;
  box-shadow: 0 0 2rem #b8ff9945, inset 0 0 0 .35rem #88b58016;
  font-size: 1.9rem;
}
.login-panel { align-content: center; background: var(--surface); padding: clamp(1.6rem, 5vw, 3rem); }
.login-panel h2, dialog h2 { font-size: 1.65rem; }
.login-panel > p, dialog p { color: var(--muted); margin-top: .55rem; }
#login-form { margin-top: 1.6rem; }
.password-row { display: flex; gap: .35rem; margin-top: .45rem; }
.password-row button { min-width: 3.75rem; }
label { display: block; font-size: .9rem; font-weight: 600; }
input, .field textarea, .field select {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  background: var(--editor);
  color: var(--text);
}
.field { min-width: 0; display: grid; gap: .35rem; align-content: start; }
.field textarea { resize: vertical; }
.feedback { color: var(--accent); font-size: .9rem; margin: .75rem 0; overflow-wrap: anywhere; }
.feedback:empty { margin: 0; }
.feedback.error { color: var(--error); }
#login-form .full { margin-top: .85rem; }

.dashboard { padding-block: clamp(1.65rem, 5vw, 3.25rem); }
.page-heading, .panel-heading, .editor-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .85rem;
}
.page-heading { margin-bottom: 1.25rem; }
.page-heading p { color: var(--muted); margin-top: .4rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: .85rem; overflow: hidden; min-width: 0; }
.panel-heading { min-height: 4.35rem; padding: .75rem 1.15rem; border-bottom: 1px solid var(--border); }
.version-summary { display: flex; align-items: center; flex-wrap: wrap; gap: .7rem; min-width: 0; }
.empty { padding: clamp(1.4rem, 5vw, 3rem); }
.empty p { color: var(--muted); margin-top: .4rem; }
.version-detail { padding: .75rem 1.15rem; font-size: .875rem; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: .35rem; }
.workspace { display: grid; grid-template-columns: minmax(13rem, 16rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.sidebar-heading { padding: 1.1rem; border-bottom: 1px solid var(--border); }
.sidebar-empty { color: var(--muted); padding: 1rem 1.1rem; font-size: .9rem; }
.history { list-style: none; margin: 0; padding: .5rem; max-height: 36rem; overflow: auto; }
.history:empty { padding: 0; }
.history li + li { margin-top: .25rem; }
.history button {
  width: 100%;
  min-height: 3.2rem;
  display: grid;
  gap: .2rem;
  text-align: left;
  border: 1px solid transparent;
  border-radius: .45rem;
  padding: .55rem .6rem;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.history button:hover { background: var(--control); }
.history button[aria-current="true"] { background: #263522; border-color: #506844; }
.history-name { font-weight: 600; font-size: .9rem; }
.history-meta { font-size: .8125rem; color: var(--muted); }
.version-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: .8rem; padding: 1rem 1.15rem .4rem; }
.source-label { padding: .75rem 1.15rem .6rem; }
.source {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  background: var(--editor);
  border-block: 1px solid var(--border);
  font: 400 .9rem/1.65 var(--mono);
  tab-size: 4;
}
.source textarea, .gutter { height: clamp(16rem, 47vh, 34rem); margin: 0; padding: .85rem .9rem; font: inherit; }
.source textarea {
  width: 100%;
  overflow: auto;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  white-space: pre;
}
.source textarea:focus-visible { outline-offset: -3px; }
.source textarea::placeholder, .field textarea::placeholder, input::placeholder { color: var(--muted); }
.gutter { min-width: 3.2rem; text-align: right; color: var(--muted); border-right: 1px solid var(--border); user-select: none; overflow: hidden; }
.source-footer, .editor-footer { min-height: 3rem; padding: .55rem 1.15rem; }
.source-footer, .editor-info { color: var(--muted); font: 400 .8125rem/1.5 var(--mono); }
.editor-info { display: flex; flex-wrap: wrap; gap: .85rem; }
.dirty { color: var(--warning); }

dialog {
  width: min(100% - 2rem, 29rem);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: .9rem;
  background: var(--surface);
  padding: 1.4rem;
  max-height: calc(100% - 2rem);
}
dialog::backdrop { background: #080c0de0; }
dialog .field { margin-top: 1rem; }
.dialog-actions { justify-content: end; margin-top: 1.2rem; }

@media (max-width: 720px) {
  .login { grid-template-columns: 1fr; width: min(100%, 29rem); }
  .intro { min-height: 10rem; gap: 1rem; }
  .circuit { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .history { max-height: 11rem; }
}
@media (max-width: 460px) {
  .version-fields { grid-template-columns: 1fr; }
  .account .pill { display: none; }
}
@media (prefers-reduced-motion: reduce) { .button { transition: none; } }
