:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #f0f4f3;
  --ink: #202326;
  --muted: #5f686d;
  --line: #cfd7d4;
  --accent: #176b5f;
  --accent-2: #a5412d;
  --accent-3: #1f5f99;
  --code-bg: #111614;
  --code-ink: #e6f2ee;
  --warn-bg: #fff5dc;
  --error-bg: #ffe7e2;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p,
.preview-header p,
.checks-result {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.top-actions,
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  min-height: 36px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 7px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button.secondary {
  width: 100%;
  color: var(--accent);
  background: var(--surface);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(360px, 1fr) minmax(250px, 320px);
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 82px);
}

.controls,
.side-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel,
.preview-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.panel {
  padding: 12px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

label span {
  font-size: 12px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 9px;
}

textarea {
  resize: vertical;
  min-height: 76px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: auto;
}

.preview-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.pill-row span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.code-frame {
  flex: 1;
  min-height: 560px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.mini-code {
  margin: 10px 0 0;
  padding: 10px;
  overflow: auto;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12px;
}

.message-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.message-list li {
  border-left: 3px solid var(--accent-3);
  background: var(--surface-2);
  padding: 8px;
  font-size: 13px;
  line-height: 1.35;
}

.message-list li.error {
  border-color: var(--accent-2);
  background: var(--error-bg);
}

.message-list li.warning {
  border-color: #b07800;
  background: var(--warn-bg);
}

.message-list li.ok {
  border-color: var(--accent);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(260px, 340px) minmax(360px, 1fr);
  }

  .side-info {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar,
  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace,
  .side-info {
    grid-template-columns: 1fr;
  }

  .code-frame {
    min-height: 420px;
  }

  .top-actions button {
    flex: 1 1 150px;
  }
}
