:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1a1d22;
  --ink-soft: #5a6473;
  --line: #dde1e6;
  --brand: #0066cc;
  --brand-ink: #ffffff;
  --ok: #1f8a44;
  --warn: #b9871d;
  --err: #c4321e;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand { font-weight: 700; letter-spacing: 0.2px; }
.topbar__product { color: var(--ink-soft); font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 53px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 85px);
  padding-right: 4px;
}

.sidebar__section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 16px;
  box-shadow: var(--shadow);
}

.sidebar__section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.info-list {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 4px 10px;
  margin: 0 0 10px;
  font-size: 13px;
}
.info-list dt { color: var(--ink-soft); }
.info-list dd { margin: 0; color: var(--ink); }

.notes { margin: 8px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: 12px; }
.notes li { margin-bottom: 4px; }

.upload {
  display: inline-block;
  position: relative;
  width: 100%;
  margin-bottom: 4px;
}
.upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload__cta {
  display: block;
  text-align: center;
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fafbfc;
  font-weight: 500;
}
.upload:hover .upload__cta { border-color: var(--brand); color: var(--brand); }

.hint { color: var(--ink-soft); font-size: 12px; margin: 6px 0; }
.filename { font-size: 12px; margin: 4px 0; word-break: break-all; }
.preflight { font-size: 12px; color: var(--err); margin: 4px 0; min-height: 1em; }

.placement {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 10px 0 4px;
}
.placement__label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-right: 4px;
}
.placement__option {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #fafbfc;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  user-select: none;
}
.placement__option input { position: absolute; opacity: 0; pointer-events: none; }
.placement__option:has(input:checked) {
  background: var(--brand);
  color: var(--brand-ink);
  border-color: var(--brand);
}
.placement-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: #eef1f5;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn--primary { background: var(--brand); color: var(--brand-ink); }
.btn--primary:disabled { background: #a8c4e6; cursor: not-allowed; }
.btn--primary:not(:disabled):hover { filter: brightness(0.95); }

.status {
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin: 6px 0 10px;
  display: inline-block;
  font-size: 13px;
}
.status--ok    { background: rgba(31, 138, 68, 0.12); color: var(--ok); }
.status--warning { background: rgba(185, 135, 29, 0.14); color: var(--warn); }
.status--error { background: rgba(196, 50, 30, 0.12); color: var(--err); }

.issues { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.issue {
  border-left: 3px solid var(--line);
  padding: 8px 10px;
  background: #fafbfc;
  border-radius: 4px;
}
.issue--error   { border-color: var(--err); }
.issue--warning { border-color: var(--warn); }
.issue--info    { border-color: var(--brand); }

.issue__header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.issue__severity { font-weight: 700; }
.issue--error   .issue__severity { color: var(--err); }
.issue--warning .issue__severity { color: var(--warn); }
.issue--info    .issue__severity { color: var(--brand); }
.issue__message { margin: 0 0 4px; font-size: 13px; }
.issue__diff { margin: 0; font-size: 12px; color: var(--ink-soft); }
.issue__diff code {
  background: #eef1f5;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
}

.canvas-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  padding: 12px;
  box-shadow: var(--shadow);
  min-height: 0;
}
.canvas-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-conic-gradient(#fafbfc 0% 25%, #f0f2f4 0% 50%) 50% / 24px 24px;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 400px;
}
.canvas-stage .canvas-container { /* fabric injects this wrapper */
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.canvas-hint {
  margin: 10px 4px 0;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}

/* Mobile: stack the sidebar above the canvas */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
  }
  .sidebar {
    order: 2;
    max-height: none;
    overflow: visible;
  }
  .canvas-wrap { order: 1; }
  .canvas-stage { min-height: 360px; }
}
