:root {
  color-scheme: light;
  --ink: #152c24;
  --body: #40584d;
  --muted: #63746b;
  --green: #155b45;
  --green-hover: #104a38;
  --paper: #f5f7f6;
  --surface: #ffffff;
  --input: #f8faf9;
  --line: #dce5e0;
  --input-line: #c9d5ce;
  --success-surface: #f1f8f4;
  --error: #9b382b;
  --error-surface: #fff7f3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
}

button,
a,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

button,
a {
  touch-action: manipulation;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

[hidden] {
  display: none !important;
}

.topbar,
main,
footer {
  width: calc(100% - 48px);
  max-width: 720px;
  margin-right: auto;
  margin-left: auto;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--green);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-decoration: none;
}

.section-label {
  color: var(--muted);
  font-size: 13px;
}

main {
  margin-top: 36px;
  margin-bottom: 48px;
}

.intro {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
}

h1 {
  margin: 0;
  font-size: 44px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.subtitle {
  margin: 14px 0 0;
  color: var(--body);
  font-size: 16px;
  line-height: 1.7;
}

.steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
}

.steps span {
  white-space: nowrap;
}

.steps i {
  color: var(--muted);
  font-style: normal;
}

.workspace {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(21 44 36 / 4%);
}

.field-heading {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}

.text-button {
  min-height: 44px;
  flex-shrink: 0;
  padding: 10px 0 10px 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
}

.text-button:hover:not(:disabled) {
  color: var(--green-hover);
  text-decoration: underline;
  text-underline-offset: 4px;
}

textarea {
  display: block;
  width: 100%;
  min-height: 124px;
  max-height: 260px;
  padding: 16px;
  resize: vertical;
  border: 1px solid var(--input-line);
  border-radius: 10px;
  background: var(--input);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
}

textarea::placeholder {
  color: #617468;
  opacity: 1;
}

textarea:focus {
  border-color: var(--green);
  outline: 2px solid var(--green);
  outline-offset: 2px;
  background: var(--surface);
}

textarea[aria-invalid="true"] {
  border-color: var(--error);
  outline-color: var(--error);
  background: var(--error-surface);
}

textarea:disabled {
  color: var(--body);
}

.field-help {
  margin: 12px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.primary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--green);
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
}

.primary:hover:not(:disabled) {
  background: var(--green-hover);
}

.primary:active:not(:disabled) {
  background: #0d3f30;
}

.primary:disabled {
  background: #526c60;
  opacity: 1;
}

.wide {
  width: 100%;
}

button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 4px;
}

.secondary {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--input-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}

.secondary:hover:not(:disabled) {
  background: var(--input);
  border-color: var(--green);
}

.status {
  margin: 16px 0 0;
  color: var(--body);
  font-size: 14px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.status:empty {
  display: none;
}

.error-panel {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid #e8cfc5;
  border-radius: 12px;
  background: var(--error-surface);
  color: var(--error);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.error-panel strong {
  font-size: 16px;
  font-weight: 600;
}

.error-panel p {
  margin: 8px 0 16px;
}

.error-panel small {
  display: block;
  margin-top: 16px;
  color: #79584b;
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.error-panel small:empty {
  display: none;
}

.result {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid #d3e4d9;
  border-radius: 12px;
  background: var(--success-surface);
}

.result-tag {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
}

.result h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.result .muted {
  margin: 10px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.result-actions button {
  flex: 1 1 120px;
}

.result .field-help {
  margin-top: 16px;
  margin-bottom: 0;
}

.result textarea {
  margin-top: 8px;
  font-size: 14px;
  word-break: break-all;
}

.result label {
  display: block;
  margin-top: 20px;
  font-size: 13px;
}

/* Existing DOM attributes remain the only source of UI state. */
@supports selector(:has(*)) {
  .workspace:has(#result:not([hidden])) #submit {
    border-color: var(--input-line);
    background: var(--surface);
    color: var(--green);
  }

  .workspace:has(#result:not([hidden])) #submit:hover {
    border-color: var(--green);
    background: var(--input);
  }

  .workspace:has(#result:not([hidden])) .status {
    color: var(--green);
  }

  .workspace:has(#source[aria-invalid="true"]) .status {
    color: var(--error);
  }

  #parse-form[aria-busy="true"] + .status {
    color: var(--muted);
  }
}

.help {
  margin-top: 32px;
}

.help h2 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

details {
  border-bottom: 1px solid var(--line);
}

summary {
  min-height: 52px;
  padding: 14px 0;
  cursor: pointer;
  color: var(--body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
}

summary::marker {
  color: var(--muted);
  font-size: 11px;
}

details[open] summary {
  color: var(--ink);
}

details p {
  margin: 0 0 18px;
  color: var(--body);
  font-size: 14px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.usage-note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 24px 0 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

footer .filing {
  flex-basis: 100%;
  text-align: center;
  text-underline-offset: 3px;
}

footer span:first-child {
  font-weight: 600;
  letter-spacing: 1.4px;
}

@media (max-width: 600px) {
  .topbar,
  main,
  footer {
    width: calc(100% - 32px);
  }

  .topbar {
    min-height: 64px;
  }

  .brand {
    font-size: 17px;
  }

  main {
    margin-top: 28px;
    margin-bottom: 36px;
  }

  .intro {
    margin-bottom: 24px;
  }

  h1 {
    font-size: 32px;
    line-height: 1.3;
    letter-spacing: 0;
  }

  .subtitle {
    margin-top: 12px;
    font-size: 14px;
  }

  .steps {
    gap: 10px;
    margin-top: 18px;
  }

  .workspace {
    padding: 20px;
  }

  .field-heading {
    gap: 8px;
  }

  .text-button {
    padding-left: 8px;
  }

  textarea {
    padding: 14px;
  }

  .result,
  .error-panel {
    padding: 18px;
  }

  .result h2 {
    font-size: 18px;
    line-height: 1.55;
  }

  .result textarea {
    font-size: 16px;
  }

  .help {
    margin-top: 28px;
  }

  footer {
    padding: 20px 0 24px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  button,
  a,
  textarea {
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  }
}
