:root {
  --bg: #e8eef2;
  --bg-accent: #d5e4ec;
  --surface: #f7fafb;
  --ink: #1a2b33;
  --muted: #5a6f7a;
  --line: #c5d4dc;
  --brand: #0d6e6e;
  --brand-dark: #095555;
  --danger: #a33a2c;
  --danger-bg: #f8e8e5;
  --shadow: 0 12px 40px rgba(26, 43, 51, 0.08);
  --radius: 14px;
  --font: "Source Sans 3", "Segoe UI", "Helvetica Neue", sans-serif;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
}

@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: local("Source Sans 3"), local("SourceSans3-Regular");
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #cfe8e4 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #d9e3f0 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-accent) 100%);
}

body {
  line-height: 1.45;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 3rem;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
  background:
    linear-gradient(145deg, #0d6e6e 0%, #1a8f8f 45%, #2a4a5e 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.3rem;
}

.side .block + .block {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 110px;
  padding: 1rem;
  border: 1.5px dashed #7aa0ad;
  border-radius: 12px;
  background: rgba(13, 110, 110, 0.04);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--brand);
  background: rgba(13, 110, 110, 0.1);
}

.dropzone-title {
  font-weight: 600;
}

.dropzone-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.file-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.file-list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: #eef4f6;
  font-size: 0.9rem;
}

.file-list input {
  accent-color: var(--brand);
}

.file-list .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list .size {
  color: var(--muted);
  font-size: 0.78rem;
}

.tool-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.mode-tab {
  border: 1px solid var(--line);
  background: #eef3f5;
  color: var(--ink);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.draw-style {
  margin-bottom: 0.65rem;
}

.field.inline {
  flex: 1 1 auto;
  min-width: 5.5rem;
  margin-bottom: 0;
}

.field.inline input[type="color"] {
  width: 100%;
  height: 2.1rem;
  padding: 0.15rem;
  cursor: pointer;
}

.field.inline input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
  background: #fff;
}

.field.inline.check {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  padding-top: 1.2rem;
}

.field .hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.tool-tab {
  flex: 1;
  border: 1px solid var(--line);
  background: #eef3f5;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.tool-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.help {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}

.field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  background: #fff;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.gap {
  gap: 0.5rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover:not(:disabled) {
  border-color: #9bb0ba;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-danger {
  background: var(--danger-bg);
  border-color: #e0b4ad;
  color: var(--danger);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.btn-sm {
  padding: 0.3rem 0.55rem;
  min-width: 2rem;
}

.status {
  margin: 1rem 0 0;
  min-height: 1.3em;
  font-size: 0.88rem;
  color: var(--brand-dark);
}

.status.error {
  color: var(--danger);
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.workspace-header h2 {
  margin: 0;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.thumbs {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding: 0.25rem 0 0.85rem;
  min-height: 0;
}

.thumb {
  position: relative;
  flex: 0 0 auto;
  width: 88px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #fff;
  padding: 0.3rem;
  cursor: grab;
  user-select: none;
}

.thumb.selected {
  border-color: var(--brand);
}

.thumb.dragging {
  opacity: 0.5;
}

.thumb img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  pointer-events: none;
}

.thumb .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.thumb input {
  accent-color: var(--danger);
}

.preview-wrap {
  display: flex;
  justify-content: center;
  background:
    linear-gradient(45deg, #dfe8ec 25%, transparent 25%),
    linear-gradient(-45deg, #dfe8ec 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe8ec 75%),
    linear-gradient(-45deg, transparent 75%, #dfe8ec 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: #edf3f6;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 1rem;
  overflow: auto;
  max-height: min(72vh, 900px);
}

.preview-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

#preview-img {
  display: block;
  max-width: 100%;
  height: auto;
  vertical-align: top;
}

#overlay {
  position: absolute;
  left: 0;
  top: 0;
  /* size set in JS to match the image pixel-for-pixel (no CSS stretch) */
  margin: 0;
  padding: 0;
  border: 0;
  cursor: crosshair;
  touch-action: none;
}

.empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
}
