:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.975 0.004 150);
  --panel: oklch(0.948 0.008 150);
  --ink: oklch(0.185 0.018 150);
  --muted: oklch(0.445 0.018 150);
  --line: oklch(0.862 0.012 150);
  --primary: oklch(0.56 0.142 150);
  --primary-hover: oklch(0.50 0.142 150);
  --accent: oklch(0.66 0.145 65);
  --danger: oklch(0.56 0.17 30);
  --success: oklch(0.52 0.13 150);
  --focus: oklch(0.70 0.13 150);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  min-height: 100vh;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.heading {
  display: grid;
  gap: 6px;
}

.kicker {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
}

.heading p:not(.kicker),
.preview-toolbar p,
.empty-preview span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.form {
  display: grid;
  gap: 14px;
}

.field,
.file-field {
  display: grid;
  gap: 6px;
}

.field span,
.file-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field-row,
.upload-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.upload-row {
  grid-template-columns: 1fr 1fr;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

input::placeholder {
  color: oklch(0.55 0.012 150);
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px oklch(0.85 0.08 150 / 0.45);
}

.file-field {
  cursor: pointer;
}

.file-field input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-control {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.file-field:focus-within .file-control {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px oklch(0.85 0.08 150 / 0.45);
}

.file-meta {
  min-height: 16px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 750;
  cursor: pointer;
}

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

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

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

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

.status {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.status.error {
  color: var(--danger);
  border-color: oklch(0.77 0.09 30);
}

.status.success {
  color: var(--success);
  border-color: oklch(0.76 0.08 150);
}

.rows-panel {
  min-height: 0;
  display: grid;
  gap: 10px;
}

.rows-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#rowCount {
  min-width: 30px;
  border-radius: 999px;
  background: var(--panel);
  padding: 4px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.entries-list {
  min-height: 160px;
  max-height: 38vh;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}

.entries-list li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.entries-list li:last-child {
  border-bottom: 0;
}

.preview-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  padding: 24px;
  background: var(--bg);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-toolbar div {
  display: grid;
  gap: 4px;
}

.preview-stage {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, oklch(0.96 0 0) 25%, transparent 25%),
    linear-gradient(-45deg, oklch(0.96 0 0) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, oklch(0.96 0 0) 75%),
    linear-gradient(-45deg, transparent 75%, oklch(0.96 0 0) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
  padding: 24px;
}

.preview-stage svg {
  display: block;
  max-width: none;
  background: white;
}

.empty-preview {
  min-height: 360px;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  color: var(--ink);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .preview-panel {
    min-height: 70vh;
  }
}

@media (max-width: 640px) {
  .control-panel,
  .preview-panel {
    padding: 16px;
  }

  .field-row,
  .upload-row,
  .actions {
    grid-template-columns: 1fr;
  }
}
