:root {
  --page: #f5f6ef;
  --paper: #fdfef9;
  --ink: #1e322e;
  --muted: #54665e;
  --line: #cbd4c7;
  --green: #175640;
  --light: #e2ecd7;
  --error: #992e22;
  font: 16px/1.5 "Inter", "Roboto", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; border-radius: 6px; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid #a85d0c; outline-offset: 3px; }
main:focus { outline: none; }

.skip { position: absolute; top: -8em; padding: .7rem; background: var(--paper); color: var(--green); z-index: 3; }
.skip:focus { top: 0; }

.masthead { background: var(--paper); border-bottom: 1px solid var(--line); }
.bar, main { width: min(920px, 94%); margin-inline: auto; }
.bar { min-height: 72px; display: flex; align-items: center; }
.brand { display: inline-flex; gap: 12px; align-items: center; font-size: 1.33rem; font-weight: 750; letter-spacing: -.04em; text-decoration: none; color: var(--ink); }
.brand-icon { position: relative; width: 35px; height: 34px; background: var(--green); border-radius: 8px; }
.brand-icon::before, .brand-icon::after { content: ""; position: absolute; background: #ecf2cd; border-radius: 2px; left: 8px; }
.brand-icon::before { width: 19px; height: 5px; top: 10px; }
.brand-icon::after { width: 13px; height: 5px; top: 19px; }

main { padding-block: clamp(28px, 4vw, 56px) 64px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.9rem, 3.6vw, 2.8rem); line-height: 1.12; letter-spacing: -.048em; font-weight: 680; }
h2 { font-size: clamp(1.2rem, 2vw, 1.48rem); line-height: 1.25; font-weight: 670; letter-spacing: -.03em; }
.muted, .hint { color: var(--muted); }
.hint, .eyebrow { font-size: .86rem; }
.eyebrow { font-weight: 620; color: var(--muted); margin-bottom: .35rem; }
.page-title { margin-bottom: 1.75rem; }
.page-title p:not(:empty) { margin-top: .5rem; }

.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: clamp(18px, 2.5vw, 32px); }
.form-panel { border-top: 3px solid var(--green); }
.result-panel { margin-top: 1.5rem; }

#check-form { margin-top: 1.2rem; display: grid; gap: 1.15rem; }
.field { display: grid; gap: 6px; min-width: 0; }
.row-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
label, legend { font-size: .92rem; font-weight: 620; }
fieldset { border: 0; margin: 0; padding: 0; }
legend { padding: 0; margin-bottom: 6px; }

input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #a8b7a9;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .92rem;
}

.file-field input[type="file"] {
  width: 100%;
  padding: 5px;
  font-size: .92rem;
  color: var(--ink);
  background: #f5f7f0;
  border: 1px dashed #9bac9e;
  border-radius: 6px;
}

input::file-selector-button {
  font: inherit;
  margin-right: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 11px;
  color: var(--ink);
  cursor: pointer;
}

.segmented { display: inline-flex; width: fit-content; padding: 3px; border: 1px solid var(--line); background: #f0f3ea; border-radius: 6px; }
.segmented label { position: relative; cursor: pointer; font-weight: 500; }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segmented span { display: block; padding: 6px 14px; border-radius: 4px; color: var(--muted); }
.segmented input:checked + span { color: var(--green); background: #fff; box-shadow: 0 1px 3px #192c1726; font-weight: 650; }
.segmented input:focus-visible + span { outline: 2px solid #a85d0c; }

code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .88em;
  background: #edf1e7;
  padding: .08rem .35rem;
  border-radius: 4px;
}

.actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: .25rem; }
.primary { padding: 9px 20px; font-size: .95rem; font-weight: 620; color: #fff; background: var(--green); border: 1px solid var(--green); }
.primary:hover:not(:disabled) { background: #0a4430; }
.cancel { padding: 9px 18px; font-size: .95rem; font-weight: 620; color: var(--error); background: #fae9e1; border: 1px solid #d99b8c; }
.cancel:hover:not(:disabled) { background: #f5d8cb; }

.running-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .93rem;
  font-weight: 600;
  color: var(--green);
}
.running-status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .3; }
  50% { opacity: 1; }
}

.feedback { margin-top: 1rem; padding: .7rem .95rem; border-left: 3px solid #58804d; background: #e6efdf; color: var(--green); overflow-wrap: anywhere; }
.feedback.error { background: #fae9e1; color: var(--error); border-color: #b45942; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.result-tag { display: inline-block; border-radius: 5px; padding: .18rem .55rem; font-size: .82rem; font-weight: 650; background: #eceee9; color: var(--ink); }
.result-ok { background: #e1ecd8; color: #2d5930; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.15rem; margin: 1.25rem 0 0; }
.facts div { border-left: 3px solid #bfceb5; padding-left: 12px; min-width: 0; }
.facts dt { font-size: .85rem; color: var(--muted); }
.facts dd { margin: .18rem 0 0; font-weight: 650; font-size: 1.18rem; overflow-wrap: anywhere; }
.matched-code { font-size: 1.05rem; white-space: pre-wrap; background: #e4eedb; color: #1b4a33; padding: .15rem .45rem; }

@media (max-width: 600px) {
  .bar, main { width: 93%; }
  .segmented { width: 100%; }
  .segmented label { flex: 1; text-align: center; }
  .row-fields { grid-template-columns: 1fr; }
}
