:root {
  /* Colors */
  --color-bg: #fafaf9;
  --color-surface: #ffffff;
  --color-surface-muted: #f5f5f4;
  --color-border: #e7e5e4;
  --color-border-focus: #a8a29e;
  --color-text: #1c1917;
  --color-text-muted: #57534e;
  --color-accent: #ea580c;
  --color-accent-hover: #c2410c;

  /* Spacing */
  --space-xs: 0.15rem;
  --space-sm: 0.25rem;
  --space-md: 0.4rem;
  --space-lg: 0.6rem;
  --space-xl: 0.8rem;
  --space-2xl: 1rem;
  --space-3xl: 1.2rem;

  /* Border radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-md: 0 1px 3px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 2px 4px 0 rgb(0 0 0 / 0.06);

  /* Typography */
  --font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

.preview-area svg {
  transition: opacity var(--transition-base);
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  max-width: 80vw;
  margin: 0 auto;
  width: 80vw;
  padding: var(--space-lg) var(--space-lg) var(--space-lg) var(--space-lg);
  line-height: 1.6;
}

h1 {
  display: none;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-xl);
  letter-spacing: -0.025em;
}

.inputs-panel > h1 {
  display: block;
}

main.layout {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--space-2xl);
}

.inputs-panel {
  display: flex;
  flex-direction: column;
  flex: 0 0 380px;
  max-width: 420px;
  width: 100%;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 520px;
  width: 100%;
}

.inputs-panel > h1 {
  margin-bottom: var(--space-lg);
}

.inputs-panel > .inputs {
  flex: 1;
}

.preview-panel {
  padding-bottom: calc(var(--space-xl) + var(--space-lg));
}

.preview-panel > .previews {
  flex: 1;
  min-height: 100%;
  padding-bottom: var(--space-lg);
  margin-bottom: calc(-1 * var(--space-lg));
}

section {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.donate-card {
  background-color: var(--color-accent);
  color: var(--color-surface);
  padding: var(--space-sm) var(--space-md);
}

.inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-section h3 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-icon {
  width: 20px;
  height: 20px;
  color: var(--color-accent);
  flex-shrink: 0;
}

.form-row {
  display: grid;
  gap: var(--space-md);
}

.form-row.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-row.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-field label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
}

.advanced-section {
  gap: var(--space-sm);
}

.advanced-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.advanced-toggle {
  border: 1px solid var(--color-border);
  background-color: var(--color-surface-muted);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast),
    border-color var(--transition-fast);
}

.advanced-toggle:hover {
  background-color: var(--color-surface);
  border-color: var(--color-border-focus);
}

.advanced-section.is-collapsed .advanced-content {
  display: none;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0;
}

.form-field input,
.form-field select {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--color-border-focus);
}

.form-field input:hover:not(:focus),
.form-field select:hover:not(:focus) {
  border-color: var(--color-border-focus);
}

.form-field input:disabled,
.form-field select:disabled {
  background-color: var(--color-surface-muted);
  color: var(--color-text-muted);
  border-color: var(--color-border);
  cursor: not-allowed;
  opacity: 0.6;
}

.form-field input:disabled:hover,
.form-field select:disabled:hover {
  border-color: var(--color-border);
  transform: none;
}

input[type="color"] {
  height: 38px;
  padding: var(--space-xs);
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
}

input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
}

/* Preset chips */
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  background-color: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.preset-chip:hover {
  border-color: var(--color-border-focus);
  background-color: var(--color-surface);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.preset-chip.active {
  color: var(--color-surface);
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.preset-chip.active:hover {
  background-color: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.color-swatch {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.preset-chip.active .color-swatch {
  border-color: rgba(255, 255, 255, 0.3);
}

.inputs .checkbox-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.inputs .checkbox-option:hover {
  color: var(--color-text);
}

.inputs .checkbox-option:has(input:disabled) {
  color: var(--color-text-muted);
  opacity: 0.6;
  cursor: not-allowed;
}

.inputs .checkbox-option:has(input:disabled):hover {
  color: var(--color-text-muted);
}

.inputs .checkbox-option input {
  margin-top: 0;
  width: auto;
  cursor: pointer;
}

.inputs .checkbox-option input:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.previews {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: var(--space-lg);
  height: 100%;
  align-content: stretch;
  grid-auto-rows: 1fr;
}

.previews > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  height: 100%;
  align-items: stretch;
  justify-content: space-between;
}

.preview-area {
  flex: 1;
}

.previews h3 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin: 0;
}

.preview-area {
  background-color: var(--color-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  min-height: 220px;
  padding: var(--space-xs);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-area > div {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-area svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.previews > div button {
  align-self: stretch;
  margin-top: var(--space-sm);
}

button {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-surface);
  background-color: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

button:hover {
  background-color: var(--color-accent-hover);
}

button:active {
  background-color: var(--color-accent-hover);
}

button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.2);
}

.donate-section {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.donate-media {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.donate-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.donate-section p {
  color: var(--color-surface);
  margin: 0;
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

.donate-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  background-color: #0070ba;
  color: var(--color-surface);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  transition: background-color var(--transition-fast);
}

.donate-section .donate-button {
  align-self: stretch;
}

.donate-button:hover,
.donate-section .donate-button:hover {
  background-color: #005b95;
}

@media (max-width: 900px) {
  main.layout {
    flex-direction: column;
  }

  .previews {
    grid-template-columns: 1fr;
  }

  .form-row.cols-3,
  .form-row.cols-2 {
    grid-template-columns: 1fr;
  }
}

.instructions-banner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.instructions-banner:hover {
  border-color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.banner-icon {
  color: var(--color-accent);
  display: flex;
}

.banner-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.banner-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  line-height: 1.2;
}

.banner-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.banner-arrow {
  color: var(--color-accent);
  font-weight: 500;
}

/* Instructions View Styles */
.instructions-layout {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-2xl);
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
  display: none;
}

.instructions-layout.active {
  opacity: 1;
  display: block;
}

#app-view {
  transition: opacity 0.15s ease-in-out;
}

#app-view.hidden {
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}

.instructions-header {
  margin-bottom: var(--space-2xl);
  text-align: center;
}
.instructions-header h1 {
  display: block;
  margin-bottom: var(--space-md);
}
.back-link {
  display: inline-block;
  margin-bottom: var(--space-xl);
  color: var(--color-accent);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  position: sticky;
  top: 1rem;
  z-index: 100;
  background: rgba(250, 250, 249, 0.95);
  backdrop-filter: blur(4px);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
}
.back-link:hover {
  text-decoration: underline;
}
.steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3xl);
}
.step-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.step-image-container {
  width: 100%;
  aspect-ratio: 4/3;
  background-color: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
}
.step-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.step-content {
  padding: var(--space-xl);
}
.step-number {
  display: inline-block;
  background-color: var(--color-accent);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  text-align: center;
  line-height: 28px;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}
.step-description {
  font-size: var(--font-size-base);
  color: var(--color-text);
}
@media (min-width: 768px) {
  .steps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.section-header {
  grid-column: 1 / -1;
  margin-top: var(--space-xl);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-border);
}
.section-header h2 {
  color: var(--color-text);
  font-size: var(--font-size-xl);
  margin: 0;
}
.tools-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-3xl);
  box-shadow: var(--shadow-sm);
}
.tools-section h2 {
  margin-top: 0;
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-xl);
  color: var(--color-text);
}
.tools-list {
  list-style-type: disc;
  padding-left: var(--space-xl);
  margin: 0;
}
.tools-container {
  display: grid;
  gap: var(--space-xl);
}
.tools-image img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  display: block;
}
@media (min-width: 768px) {
  .tools-container {
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
}
.warning-message {
  display: none;
  margin-top: 1rem;
  padding: 0.75rem;
  background-color: #fff7ed;
  border: 1px solid #ffedd5;
  border-radius: 0.375rem;
  color: #9a3412;
  font-size: 0.875rem;
}
.warning-message a {
  text-decoration: underline;
  cursor: pointer;
  font-weight: 500;
}
.dimensions-info {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
}
.dimensions-info.exceeds-paper {
  background-color: #fff7ed;
  color: #c2410c;
  border: 1px solid #ffedd5;
  border-radius: 4px;
  padding: 4px;
}
