:root {
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --background: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --border: #d9dee8;
  --primary: #3157d5;
  --primary-hover: #2447bd;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(25, 35, 55, 0.08);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1220px;
  margin: 0 auto;
  padding: 32px 24px 18px;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
}

.site-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.privacy-badge {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid #b7e4c7;
  border-radius: 999px;
  background: #ecfdf3;
  color: #16794a;
  font-size: 0.86rem;
  font-weight: 700;
}

.app-shell {
  max-width: 1220px;
  margin: 0 auto;
  padding: 16px 24px 48px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.upload-panel {
  padding: 18px;
}

.drop-zone {
  display: grid;
  min-height: 290px;
  place-items: center;
  align-content: center;
  border: 2px dashed #aeb8ca;
  border-radius: 14px;
  background: var(--surface-muted);
  text-align: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.drop-zone:hover,
.drop-zone:focus-visible,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: #f1f5ff;
  outline: none;
  transform: translateY(-1px);
}

.drop-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: #e8edff;
  color: var(--primary);
  font-size: 2rem;
  font-weight: 300;
}

.drop-zone h2 {
  margin: 16px 0 4px;
}

.drop-zone p,
.drop-zone small {
  margin: 0;
  color: var(--muted);
}

.drop-zone small {
  margin-top: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
}

.pages-panel {
  min-width: 0;
  padding: 20px;
}

.settings-panel {
  align-self: start;
  position: sticky;
  top: 18px;
  padding: 20px;
}

.settings-panel h2 {
  margin-top: 0;
}

.settings-note {
  margin: -4px 0 16px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.heading-actions,
.button-row,
.card-actions,
.editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  transition:
    background 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

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

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

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

.button.secondary {
  border-color: var(--border);
  background: var(--surface);
}

.button.secondary:hover,
.button.compact:hover {
  background: #f3f5f8;
}

.button.danger-text,
.danger-text {
  color: var(--danger);
}

.button.compact {
  min-height: 34px;
  padding: 6px 10px;
  border-color: var(--border);
  font-size: 0.86rem;
}

.full-width {
  width: 100%;
  margin-top: 14px;
}

.image-grid {
  display: grid;
  gap: 12px;
}

.image-card {
  display: grid;
  grid-template-columns: 34px 90px minmax(0, 1fr) auto 24px;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition:
    opacity 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.image-card.dragging {
  opacity: 0.45;
}

.image-card.drag-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(49, 87, 213, 0.12);
}

.image-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: #eef1f6;
  color: #475467;
  font-size: 0.85rem;
  font-weight: 800;
}

.thumbnail-wrap {
  display: grid;
  width: 90px;
  height: 74px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #e8ebf0 25%, transparent 25%),
    linear-gradient(-45deg, #e8ebf0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8ebf0 75%),
    linear-gradient(-45deg, transparent 75%, #e8ebf0 75%);
  background-position:
    0 0,
    0 8px,
    8px -8px,
    -8px 0;
  background-size: 16px 16px;
}

.thumbnail {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.thumbnail.pdf-thumbnail {
  width: 100%;
  height: 100%;
}

.card-info {
  min-width: 0;
}

.card-info strong,
.card-info span {
  display: block;
}

.card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-dimensions {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

.drag-handle {
  color: #98a2b3;
  font-size: 1.2rem;
  letter-spacing: -5px;
  user-select: none;
}

.field {
  display: grid;
  gap: 7px;
  margin: 15px 0;
  color: #344054;
  font-size: 0.92rem;
  font-weight: 700;
}

.field span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.field output {
  color: var(--muted);
  font-weight: 600;
}

.field input[type="text"],
.field select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: white;
  color: var(--text);
}

.field input[type="range"] {
  width: 100%;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 0;
  color: #344054;
  font-size: 0.92rem;
  font-weight: 650;
}

.check-field input {
  width: 17px;
  height: 17px;
}

.status {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

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

.status.success {
  color: #16794a;
}

.privacy-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
  text-align: center;
}

.editor-dialog {
  width: min(1080px, calc(100vw - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(20, 29, 48, 0.3);
}

.editor-dialog::backdrop {
  background: rgba(16, 24, 40, 0.64);
  backdrop-filter: blur(2px);
}

.editor-window {
  margin: 0;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.editor-header h2 {
  margin: 0;
}

.editor-header p {
  max-width: 72vw;
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.85rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f2f4f7;
  color: #344054;
  font-size: 1.7rem;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 560px;
}

.preview-area {
  display: grid;
  min-width: 0;
  min-height: 420px;
  place-items: center;
  overflow: auto;
  padding: 20px;
  background: #29303d;
}

#editorCanvas {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  background: white;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
}

.editor-controls {
  padding: 20px;
  overflow-y: auto;
}

.control-group {
  margin-bottom: 16px;
}

.control-label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 0.92rem;
  font-weight: 700;
}

.editor-actions {
  justify-content: flex-end;
  margin-top: 24px;
}

.hidden {
  display: none !important;
}

@media (max-width: 850px) {
  .workspace,
  .editor-layout {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    position: static;
  }

  .editor-controls {
    max-height: none;
  }

  .image-card {
    grid-template-columns: 30px 74px minmax(0, 1fr) 20px;
  }

  .thumbnail-wrap {
    width: 74px;
    height: 64px;
  }

  .card-actions {
    grid-column: 2 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 560px) {
  .site-header,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .privacy-badge {
    align-self: flex-start;
  }

  .heading-actions .button {
    flex: 1;
  }

  .image-card {
    grid-template-columns: 28px 64px minmax(0, 1fr);
  }

  .drag-handle {
    display: none;
  }

  .thumbnail-wrap {
    width: 64px;
    height: 58px;
  }

  .card-actions {
    grid-column: 1 / -1;
  }
}

.size-estimate {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f3f5f8;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}
