:root {
  color-scheme: light;
  --paper: #f7f5ef;
  --ink: #18201d;
  --muted: #69716b;
  --line: #d8d2c4;
  --panel: #fffdf8;
  --panel-strong: #f0eadf;
  --teal: #0b766a;
  --teal-dark: #07584f;
  --amber: #b96f0a;
  --red: #b93b2d;
  --shadow: 0 18px 50px rgba(43, 37, 27, 0.09);
  font-family: "Avenir Next", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(24, 32, 29, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(24, 32, 29, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1440px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar,
.panel-header,
.workspace,
.metadata-panel {
  display: grid;
  gap: 18px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 520px;
}

.status-strip span,
.metrics span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.84);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.workspace {
  grid-template-columns: minmax(310px, 440px) minmax(0, 1fr);
  align-items: stretch;
}

.control-panel,
.result-panel,
.metadata-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.dropzone {
  position: relative;
  display: grid;
  min-height: 146px;
  align-content: center;
  gap: 8px;
  border: 1px dashed #9c9485;
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 24px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--teal);
  background: #e7f0ea;
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-title {
  font-size: 22px;
  font-weight: 800;
}

.drop-subtitle {
  color: var(--muted);
  word-break: break-word;
}

.field-block {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

textarea,
.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  color: var(--ink);
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea:focus,
.search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(11, 118, 106, 0.12);
}

#requirement {
  min-height: 240px;
  resize: vertical;
  padding: 14px;
  line-height: 1.62;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.button-row.compact {
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  min-height: 44px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.primary-button,
.secondary-button {
  flex: 1;
  padding: 0 15px;
  font-weight: 800;
}

.primary-button {
  background: var(--teal);
  color: white;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  border: 1px solid var(--line);
  background: #fffefa;
  color: var(--ink);
}

.secondary-button:hover,
.icon-button:hover {
  background: #f1ece2;
}

.primary-button:active,
.secondary-button:active,
.icon-button:active {
  transform: translateY(1px);
}

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

.icon-button {
  width: 44px;
  border: 1px solid var(--line);
  background: #fffefa;
  color: var(--ink);
}

.primary-button svg,
.secondary-button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.96);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.secondary-button .spinner,
.icon-button .spinner {
  border-color: rgba(24, 32, 29, 0.18);
  border-top-color: var(--teal);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.form-message.error {
  color: var(--red);
}

.result-panel {
  display: grid;
  grid-template-rows: auto minmax(390px, 1fr) auto;
  gap: 14px;
  padding: 18px;
}

.panel-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

#syntaxOutput {
  min-height: 430px;
  resize: vertical;
  padding: 16px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.58;
  white-space: pre;
  overflow: auto;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.notes-grid > div {
  min-height: 82px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.metadata-panel {
  margin-top: 18px;
  padding: 18px;
}

.search-input {
  max-width: 260px;
  min-height: 40px;
  padding: 0 12px;
}

.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefa;
  max-height: 430px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #ebe5da;
  color: #4c554f;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td:first-child {
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-weight: 700;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  max-width: 220px;
  border: 1px solid #d8cfbe;
  border-radius: 999px;
  padding: 3px 7px;
  color: #4d554e;
  background: #f6f0e5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
  padding: 16px 12px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--teal-dark);
  text-decoration: underline;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 24px, 760px);
    padding-top: 18px;
  }

  .topbar,
  .workspace,
  .panel-header,
  .notes-grid {
    grid-template-columns: 1fr;
  }

  .status-strip,
  .button-row.compact {
    justify-content: flex-start;
  }

  h1 {
    font-size: 36px;
  }

  #syntaxOutput {
    min-height: 340px;
  }

  .search-input {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .button-row.compact {
    flex-direction: row;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .control-panel,
  .result-panel,
  .metadata-panel {
    padding: 14px;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
