:root {
  /* Colors - Light Theme */
  --bg: #f8f9fb;
  --panel: #ffffff;
  --panel-secondary: #f5f6f8;
  --ink: #09090b;
  --ink-secondary: #52525b;
  --muted: #71717a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #dbeafe;
  --accent-ultra-light: #eff6ff;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --pill: #f5f5f5;
  --pill-active: #3b82f6;
  --pill-ink: #1a1a1a;
  --pill-ink-active: #ffffff;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.03);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.08), 0 8px 10px -6px rgb(0 0 0 / 0.08);

  /* Typography */
  --mono: 'IBM Plex Mono', 'Consolas', 'Monaco', monospace;
  --sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;

  /* Spacing & Borders */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  color-scheme: light;
}

body.dark {
  /* Colors - Dark Theme */
  --bg: #09090b;
  --panel: #18181b;
  --panel-secondary: #27272a;
  --ink: #fafafa;
  --ink-secondary: #d4d4d8;
  --muted: #a1a1aa;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --accent-light: #1e3a8a;
  --accent-ultra-light: #1e293b;
  --line: #3f3f46;
  --line-strong: #52525b;
  --success: #34d399;
  --success-light: #064e3b;
  --warning: #fbbf24;
  --warning-light: #78350f;
  --danger: #f87171;
  --danger-light: #7f1d1d;
  --pill: #27272a;
  --pill-active: #60a5fa;
  --pill-ink: #e5e5e5;
  --pill-ink-active: #09090b;

  /* Shadows - Enhanced for dark mode */
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.5);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.6), 0 1px 2px -1px rgb(0 0 0 / 0.6);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.6), 0 2px 4px -2px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.6), 0 4px 6px -4px rgb(0 0 0 / 0.6);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.6), 0 8px 10px -6px rgb(0 0 0 / 0.6);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding: 24px;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 300ms ease, color 300ms ease;
}

@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .theme-toggle-fixed {
    width: 40px;
    height: 40px;
  }

  .lang-toggle-fixed {
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 11px;
  }

  .help-toggle-fixed {
    width: 40px;
    height: 40px;
  }

  .help-toggle-fixed .help-icon {
    font-size: 16px;
  }

  .header-buttons {
    gap: 8px;
  }

  .preview-canvas {
    position: relative;
    padding: 24px;
    min-height: 300px;
  }

  /* プレビューセクション全体を調整 */
  .preview {
    position: static;
  }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.theme-toggle-fixed {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
}

.theme-toggle-fixed:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-xl);
  border-color: var(--accent);
  background: var(--accent-ultra-light);
}

.theme-toggle-fixed:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 100ms;
}

.theme-toggle-fixed .theme-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.theme-toggle-fixed:hover .theme-icon {
  transform: rotate(25deg) scale(1.1);
}

.lang-toggle-fixed {
  min-width: 48px;
  height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.lang-toggle-fixed:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-xl);
  border-color: var(--accent);
  background: var(--accent-ultra-light);
  color: var(--accent);
}

.lang-toggle-fixed:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 100ms;
}

.lang-text {
  line-height: 1;
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.lang-toggle-fixed:hover .lang-text {
  transform: scale(1.05);
}

.help-toggle-fixed {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.help-toggle-fixed:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-xl);
  border-color: var(--accent);
  background: var(--accent-ultra-light);
}

.help-toggle-fixed:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 100ms;
}

.help-toggle-fixed .help-icon {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.help-toggle-fixed:hover .help-icon {
  color: var(--accent);
  transform: scale(1.1);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 8px;
}

h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.lede {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 14px;
  line-height: 1.5;
  max-width: 600px;
}

.badge-chip {
  padding: 6px 12px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--pill-ink-active);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.layout {
  display: grid;
  grid-template-columns: 520px 1fr;
  gap: 24px;
  align-items: start;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.panel.preview {
  /* allow sticky child to escape clipping */
  overflow: visible;
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  opacity: 0;
  transition: opacity 300ms ease;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
}

.panel:hover::before {
  opacity: 1;
}

.controls {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
}

.controls::-webkit-scrollbar {
  width: 6px;
}

.controls::-webkit-scrollbar-track {
  background: transparent;
}

.controls::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 3px;
}

.controls::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

.controls .field {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.controls .field:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

label::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}

input[type='text'],
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-xs);
}

input[type='text']:hover,
textarea:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

input[type='text']:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-sm);
  background: var(--panel);
  transform: translateY(-1px);
}

input[type='text']::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

textarea {
  resize: vertical;
  min-height: 50px;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  align-items: start;
  gap: 6px;
}

.hint::before {
  content: 'ℹ';
  display: inline-block;
  font-style: normal;
  opacity: 0.6;
  flex-shrink: 0;
}

.segmented {
  display: inline-flex;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--panel-secondary);
  padding: 3px;
  gap: 4px;
}

.segmented button {
  border: none;
  padding: 8px 16px;
  background: transparent;
  color: var(--ink-secondary);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all 200ms ease;
  letter-spacing: -0.01em;
}

.segmented button:hover:not(.active) {
  background: var(--panel);
  color: var(--ink);
}

.segmented button.active {
  background: var(--accent);
  color: var(--pill-ink-active);
  box-shadow: var(--shadow-sm);
}

.field.inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.pitch-set {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8px;
}

.pitch-set.sub {
  grid-template-columns: 1fr;
  gap: 4px;
}

.icon-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.icon-actions input[type='text'] {
  flex: 1;
  padding: 6px 8px;
  font-size: 12px;
}

.icon-actions .upload-button {
  padding: 6px 8px;
  font-size: 12px;
}

.icon-actions button {
  padding: 6px 8px;
  font-size: 12px;
}

button {
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 18px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  background: var(--accent);
  color: var(--pill-ink-active);
  font-family: var(--sans);
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: -0.01em;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
}

button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transform: translate(-50%, -50%);
  transition: width 0.5s ease-out, height 0.5s ease-out;
  pointer-events: none;
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--accent-hover);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
  transition-duration: 100ms;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.ghost {
  background: var(--panel);
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}

button.ghost::before {
  background: var(--accent-ultra-light);
}

button.ghost:hover {
  border-color: var(--accent);
  background: var(--accent-ultra-light);
  color: var(--accent-hover);
  transform: translateY(-1px);
}

button.primary {
  background: var(--accent);
  color: var(--pill-ink-active);
  border: 1px solid var(--accent);
  box-shadow: var(--shadow-md);
  font-weight: 700;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

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

/* Row count buttons */
.row-count-buttons {
  display: flex;
  gap: 8px;
}

.row-count-btn {
  flex: 1;
  padding: 10px 16px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all 200ms ease;
}

.row-count-btn:hover:not(.active) {
  border-color: var(--accent);
  color: var(--accent);
}

.row-count-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.pill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.palette-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.palette-group {
  margin-bottom: 0;
  padding: 16px;
  background: var(--panel-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.palette-group:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.palette-group h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.palette-group h3::before {
  content: '';
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

.group-desc {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 3px solid var(--accent-light);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.group-desc div + div {
  margin-top: 4px;
}

.pill-grid button {
  background: var(--panel);
  color: var(--ink);
  border: 1.5px solid var(--line);
  position: relative;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.pill-grid button::before {
  background: var(--panel-secondary);
}

.pill-grid button:hover:not(.active) {
  border-color: var(--accent);
  background: var(--accent-ultra-light);
  color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.pill-grid button.active {
  background: var(--accent);
  color: var(--pill-ink-active);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-md);
  transform: scale(1.02);
}

.pill-grid button.active::before {
  background: rgba(255, 255, 255, 0.2);
}

.pill-grid button.active:hover {
  background: var(--accent-hover);
  transform: scale(1.02) translateY(-1px);
}

.pill-grid button {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  padding: 10px 14px;
}

.pill-grid button .icon-preview {
  width: 24px;
  height: 24px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  background-color: var(--panel-secondary);
  transition: all 250ms ease;
}

.pill-grid button.active .icon-preview {
  background-color: rgba(255, 255, 255, 0.2);
}

.pill-grid button .button-text {
  flex: 1;
  text-align: left;
}

.selected-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-secondary);
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.selected-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 250ms ease;
}

.selected-list li:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateX(4px);
  background: var(--panel);
}

.selected-list li:hover::before {
  opacity: 1;
}

.selected-list .label {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.selected-list .meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  margin-top: 2px;
}

.selected-list .desc {
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 1.6;
  margin-top: 4px;
}

.selected-list button {
  padding: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.selected-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.not-supported-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--panel-secondary);
  border: 1.5px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: all 200ms ease;
}

.not-supported-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--panel);
}

.not-supported-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.not-supported-btn svg {
  width: 16px;
  height: 16px;
}

.selected-list li.not-supported {
  opacity: 0.6;
}

.selected-list li.not-supported::before {
  background: var(--muted);
}

/* Multi-add list for pointing/features */
.multi-add-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.multi-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel-secondary);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
}

.multi-add-row .icon-preview {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.multi-add-row .item-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.multi-add-row .item-count {
  min-width: 24px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.multi-add-row .item-count:empty,
.multi-add-row .item-count[data-count="0"] {
  display: none;
}

.multi-add-row.has-count {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-secondary));
}

.multi-add-list .ghost {
  margin-top: 4px;
}

.count-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1.5px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  transition: all 200ms ease;
}

.count-btn:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.count-btn:active {
  background: var(--accent);
  color: #fff;
}

.count-btn.minus:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.module-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1.5px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: all 200ms ease;
  margin-left: 4px;
}

.module-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.module-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.module-btn svg {
  width: 16px;
  height: 16px;
}

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

.gap-sm {
  gap: 8px;
}

.wrap {
  flex-wrap: wrap;
}

.export .row button {
  flex: none;
}

.preview {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-canvas {
  border: 2px dashed var(--line);
  border-radius: var(--radius-xl);
  padding: 40px;
  background:
    radial-gradient(circle at 20% 30%, var(--accent-ultra-light) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, var(--accent-ultra-light) 0%, transparent 50%),
    linear-gradient(135deg, var(--panel) 0%, var(--panel-secondary) 100%);
  min-height: 400px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  transition: border-color 300ms ease;
}

.floating-download {
  position: absolute;
  top: 12px;
  right: 12px;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 13px;
  background: var(--accent);
  color: var(--pill-ink-active);
  box-shadow: var(--shadow-lg);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  backdrop-filter: blur(8px);
}

.floating-download:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
  background: var(--accent-hover);
}

.floating-download:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-md);
}

.export-actions {
  margin-top: 16px;
  padding: 16px;
  background: var(--panel-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.export-actions .row {
  justify-content: center;
  gap: 10px;
}

.export-actions .hint {
  justify-content: center;
  text-align: center;
}

/* remove unused export card on desktop (kept for structure safety if needed later) */
.export-actions {
  display: none;
}

.preview-canvas:hover {
  border-color: var(--accent);
}

.preview-canvas::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at center, var(--accent-light) 0%, transparent 50%),
    radial-gradient(circle at 30% 30%, var(--accent-ultra-light) 0%, transparent 60%);
  opacity: 0.15;
  animation: rotate 25s linear infinite;
  pointer-events: none;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#badge-svg {
  width: 100%;
  max-width: 900px;
  height: auto;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.12));
  transition: all 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

#badge-svg:hover {
  transform: scale(1.025) translateY(-4px);
  filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.16));
}

.footnote {
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--panel-secondary);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--ink-secondary);
  font-size: 12px;
  line-height: 1.6;
}

code {
  background: var(--accent-light);
  color: var(--accent);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
  border: 1px solid var(--accent);
}

/* Upload button improvements */
.upload-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--line);
  background: var(--panel-secondary);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-xs);
}

.upload-button::after {
  content: '📁';
  font-size: 16px;
  transition: transform 250ms ease;
}

.upload-button:hover {
  border-color: var(--accent);
  background: var(--accent-ultra-light);
  color: var(--accent-hover);
  border-style: solid;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.upload-button:hover::after {
  transform: scale(1.1);
}

.upload-button input[type='file'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Responsive improvements */
@media (max-width: 1280px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .controls {
    position: static;
    max-height: none;
  }

  .preview {
    position: static;
  }
}

@media (max-width: 980px) {
  body {
    padding: 12px;
    padding-top: 0;
  }

  .topbar {
    padding: 12px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--line);
  }

  .theme-toggle-fixed {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }

  .theme-toggle-fixed .theme-icon {
    font-size: 18px;
  }

  .layout {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .preview {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    padding: 12px;
    margin: 0 -12px 12px;
    border-bottom: 2px solid var(--line);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }

  .preview .panel {
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 0;
  }

  .preview-canvas {
    padding: 16px;
    min-height: 180px;
    border-radius: var(--radius-md);
  }

  .preview-canvas::before {
    opacity: 0.2;
  }

  #badge-svg {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
  }

  .controls {
    padding: 12px;
    order: 1;
  }

  .field.inline {
    grid-template-columns: 1fr;
  }

  .segmented {
    font-size: 12px;
  }

  .segmented button {
    padding: 6px 12px;
    font-size: 12px;
  }
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* Selection styling */
::selection {
  background: var(--accent);
  color: var(--pill-ink-active);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Freeform icon section */
.freeform-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.freeform-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.freeform-preview {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background-color: var(--pill);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.freeform-text-preview {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-align: center;
  line-height: 1;
}

.freeform-label {
  flex: 1;
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}

.freeform-edit-btn,
.freeform-remove-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, transform 150ms ease;
}

.freeform-edit-btn {
  background: var(--accent-light);
  color: var(--accent);
}

.freeform-edit-btn:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.1);
}

.freeform-remove-btn {
  background: var(--danger-light);
  color: var(--danger);
}

.freeform-remove-btn:hover {
  background: var(--danger);
  color: white;
  transform: scale(1.1);
}

.freeform-add-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.freeform-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
}

.freeform-add-icon {
  font-size: 16px;
}

/* Freeform input form */
.freeform-input-form {
  background: var(--panel-secondary);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.freeform-input-row {
  margin-bottom: 10px;
}

.freeform-input-row:last-of-type {
  margin-bottom: 12px;
}

.freeform-input-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 4px;
}

.freeform-input-row textarea,
.freeform-input-row input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  font-family: var(--sans);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  resize: vertical;
}

.freeform-input-row textarea:focus,
.freeform-input-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.freeform-input-row textarea:disabled {
  background: var(--panel-secondary);
  color: var(--muted);
  cursor: not-allowed;
}

.freeform-input-row .hint {
  margin-top: 4px;
  font-size: 11px;
}

.freeform-input-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.freeform-input-actions button {
  padding: 6px 14px;
  font-size: 13px;
}
