:root {
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  --ink: #1f2933;
  --muted: #64748b;
  --line: #d7dee8;
  --panel: #ffffff;
  --surface: #f3f6fa;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #a16207;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  margin-top: 22px;
  margin-bottom: 8px;
  font-size: 14px;
}

p,
.muted {
  color: var(--muted);
}

.upload-button,
.primary-button,
.secondary-button,
.refresh-button,
.tab-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 14px;
}

.upload-button,
.primary-button {
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  background: #e2e8f0;
  color: var(--ink);
}

.refresh-button {
  min-height: 32px;
  padding: 6px 10px;
  background: #e2e8f0;
  color: var(--ink);
  font-size: 13px;
}

.tab-button {
  flex: 1;
  min-height: 34px;
  padding: 8px 10px;
  background: #e2e8f0;
  color: var(--ink);
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
}

.upload-button:hover,
.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button:hover,
.refresh-button:hover,
.tab-button:hover {
  background: #cbd5e1;
}

.tab-button.active:hover {
  background: var(--accent-strong);
}

.primary-button:disabled,
.secondary-button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.upload-button input {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
}

.preview-panel {
  min-width: 0;
  overflow: auto;
  padding: 20px;
}

.page-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.preview-frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
}

.preview-frame img {
  display: block;
  max-width: min(100%, 1100px);
  height: auto;
  user-select: none;
}

.preview-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.empty-state {
  display: grid;
  min-height: 320px;
  place-items: center;
  border: 1px dashed var(--line);
  background: #fff;
  color: var(--muted);
}

.side-panel {
  overflow: auto;
  padding: 18px;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.field-row {
  display: grid;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 700;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 14px;
  padding: 9px 10px;
}

.primary-button {
  width: 100%;
  margin-top: 12px;
}

.full-width {
  width: 100%;
  margin-top: 8px;
}

.list {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 22px;
  margin-bottom: 8px;
}

.section-header h2 {
  margin: 0;
}

.tab-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 8px;
  text-align: left;
}

.item-button {
  cursor: pointer;
  font: inherit;
  width: 100%;
}

.item-button:hover {
  border-color: var(--accent);
}

.item.selected {
  border-color: #2563eb;
  box-shadow: inset 3px 0 0 #2563eb;
}

.item strong {
  display: block;
  font-size: 13px;
}

.output-item {
  display: grid;
  gap: 4px;
}

.output-item span {
  overflow-wrap: anywhere;
}

.output-item small {
  color: var(--muted);
  font-size: 12px;
}

.detail-panel {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px;
  font-size: 13px;
}

.detail-panel h3,
.detail-panel h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.detail-panel h4 {
  margin-top: 12px;
}

.detail-panel dl {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 4px 8px;
  margin: 0;
}

.detail-panel dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-panel dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-panel ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.detail-panel li {
  overflow-wrap: anywhere;
}

.detail-panel p {
  font-size: 13px;
}

.detail-panel span {
  color: var(--muted);
}

.detail-link {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  padding: 8px;
  text-align: left;
}

.detail-link:hover {
  border-color: var(--accent);
}

.detail-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.danger-button {
  width: 100%;
  border: 1px solid #fecaca;
  border-radius: 6px;
  background: #fee2e2;
  color: #991b1b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 10px;
  text-align: center;
}

.danger-button:hover {
  background: #fecaca;
}

.status {
  border-left: 3px solid var(--line);
  padding-left: 10px;
  font-size: 13px;
}

.status.warn {
  border-color: var(--warn);
  color: var(--warn);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
