:root {
  --bg: #f3fbff;
  --surface: #ffffff;
  --surface-soft: #f0faff;
  --ink: #143044;
  --muted: #687b8a;
  --line: #dcecf6;
  --line-strong: #afd4e6;
  --accent: #2bb9e8;
  --accent-2: #3bd6c6;
  --accent-soft: #eaf8ff;
  --accent-ink: #ffffff;
  --danger: #e0314f;
  --warning-bg: #fff7e8;
  --warning-line: #ffd08a;
  --success-bg: #ecfdf8;
  --success-line: #9de6d5;
  --shadow: 0 24px 58px rgba(20, 88, 122, 0.15);
  --radius: 8px;
  --tap: 44px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  min-height: 100%;
}

body {
  height: 100%;
  min-height: 100%;
  margin: 0;
  font-family:
    "Plus Jakarta Sans",
    "Noto Sans JP",
    "Noto Sans SC",
    "Noto Sans TC",
    "Noto Sans KR",
    system-ui,
    sans-serif;
  background:
    linear-gradient(135deg, #f2fbff 0%, #eaf8ff 48%, #f1fffd 100%);
  color: var(--ink);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input {
  min-height: var(--tap);
}

button {
  border: 0;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

img,
canvas {
  max-width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px) saturate(1.25);
  box-shadow: 0 8px 26px rgba(40, 50, 80, 0.06);
}

.ad-band {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.62);
}

.ad-band:empty {
  display: none;
}

.ad-band-top {
  border-bottom: 1px solid var(--line);
}

.ad-band-bottom {
  border-top: 1px solid var(--line);
}

.ad-band .adsbygoogle {
  width: min(100%, 970px);
  min-height: 90px;
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: 0;
  color: #141b2d;
}

.brand-block p:last-child {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.language-control {
  flex: 0 0 auto;
}

.language-control select,
.field select,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.field textarea {
  min-height: 82px;
  line-height: 1.55;
  resize: vertical;
}

.field textarea.expandable-input {
  max-height: 44vh;
}

.language-control select {
  min-width: 150px;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible,
.upload-area:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 185, 232, 0.2);
}

.app-main {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(330px, 420px) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.control-panel {
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 18px 42px rgba(42, 53, 82, 0.08);
  backdrop-filter: blur(18px) saturate(1.18);
}

.settings-track {
  min-width: 0;
  max-width: 100%;
  display: contents;
}

.mobile-control-tabs {
  display: none;
}

.mobile-panel-tools,
.mobile-panel-handle,
.mobile-panel-toggle,
.mobile-panel-select-wrap,
.mobile-panel-select,
.mobile-primary-action,
.mobile-quick-export {
  display: none;
}

.flow-steps {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  color: #606879;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.flow-steps span {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, var(--surface-soft));
  text-align: center;
}

.upload-section {
  display: grid;
  gap: 8px;
}

.upload-area {
  display: grid;
  place-items: center;
  gap: 7px;
  min-height: 168px;
  padding: 18px;
  border: 1px dashed rgba(43, 185, 232, 0.44);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(234, 248, 255, 0.82));
  text-align: center;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.upload-area:hover,
.upload-area.is-dragover {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, #ffffff, #eaf8ff);
  box-shadow: inset 0 0 0 1px rgba(43, 185, 232, 0.2), 0 12px 28px rgba(43, 185, 232, 0.16);
}

.upload-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(43, 185, 232, 0.42);
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 10px 22px rgba(43, 185, 232, 0.18);
}

.upload-area strong {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.upload-area p,
.upload-area small,
.section-help,
.export-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.secondary-button,
.primary-button {
  width: 100%;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 800;
  line-height: 1.25;
  transition: transform 0.16s ease, background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
}

.primary-button {
  background: linear-gradient(135deg, #2bb9e8, #3bd6c6);
  color: #fff;
  box-shadow: 0 14px 30px rgba(43, 185, 232, 0.26);
}

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

.secondary-button:disabled,
.primary-button:disabled,
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
}

.status-message {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--warning-line);
  border-radius: var(--radius);
  background: var(--warning-bg);
  color: #8a5a15;
  font-size: 12px;
  line-height: 1.55;
}

.status-message.is-visible {
  display: flex;
}

.status-text {
  flex: 1 1 auto;
  min-width: 0;
}

.status-close-button {
  flex: 0 0 auto;
  width: 28px;
  min-height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  opacity: 0.72;
  cursor: pointer;
}

.status-close-button:hover {
  opacity: 1;
}

.status-message.is-error {
  border-color: rgba(180, 35, 24, 0.38);
  background: #fff1f4;
  color: var(--danger);
}

.status-message.is-success {
  border-color: var(--success-line);
  background: var(--success-bg);
  color: #087c70;
}

.export-dialog[hidden] {
  display: none;
}

.export-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
}

.export-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 25, 39, 0.32);
  backdrop-filter: blur(4px);
}

.export-dialog__panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 70px rgba(34, 47, 72, 0.2);
}

.export-dialog__panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.35;
}

.export-dialog__panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.6;
}

.export-dialog__actions {
  display: grid;
  gap: 10px;
}

.control-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 28px rgba(40, 50, 80, 0.05);
}

.control-section summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  padding: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
  list-style: none;
  cursor: pointer;
}

.control-section summary::-webkit-details-marker {
  display: none;
}

.control-section summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.16s ease;
}

.control-section[open] summary::after {
  transform: rotate(225deg);
}

.control-section[open] {
  padding-bottom: 12px;
}

.control-section > :not(summary) {
  margin-left: 12px;
  margin-right: 12px;
}

.control-section > :not(summary) + :not(summary) {
  margin-top: 10px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.template-card {
  min-width: 0;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #ffffff, #f9fbff);
  color: var(--ink);
  text-align: left;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.template-card:hover {
  transform: translateY(-1px);
  border-color: rgba(43, 185, 232, 0.36);
  background:
    linear-gradient(180deg, #ffffff, #f0faff);
}

.template-card.is-active {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, #ffffff, #eaf8ff);
  box-shadow: inset 0 0 0 1px rgba(43, 185, 232, 0.34), 0 12px 26px rgba(43, 185, 232, 0.16);
}

.template-card__name {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.template-card__desc {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.template-card__ratio {
  margin-top: auto;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
}

.field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field label,
.label-row label {
  color: #40485a;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.label-row output {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--accent);
}

input[type="color"] {
  padding: 4px;
}

.check-row {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  gap: 8px;
  color: #40485a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.preview-pane {
  min-width: 0;
  max-width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
  box-shadow: 0 18px 42px rgba(42, 53, 82, 0.08);
  backdrop-filter: blur(18px) saturate(1.15);
}

.preview-toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.preview-toolbar h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}

.preview-toolbar p {
  max-width: 60vw;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: #40485a;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.canvas-stage {
  position: relative;
  flex: 1;
  min-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 18px;
  background:
    linear-gradient(45deg, rgba(224, 232, 246, 0.72) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(224, 232, 246, 0.72) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(224, 232, 246, 0.72) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(224, 232, 246, 0.72) 75%);
  background-color: #f9fbff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.canvas-shell {
  position: relative;
  display: block;
  background: #fff;
  box-shadow: var(--shadow);
  line-height: 0;
}

.canvas-shell.is-guide-visible {
  outline: 2px solid rgba(43, 185, 232, 0.92);
  outline-offset: 0;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

@media (max-width: 1100px) {
  .app {
    height: auto;
    overflow: visible;
  }

  .app-header {
    position: relative;
  }

  .app-main {
    grid-template-columns: 1fr;
  }

  .preview-pane {
    order: 1;
  }

  .control-panel {
    order: 2;
    overflow: visible;
  }

  .canvas-stage {
    min-height: 460px;
  }
}

@media (max-width: 720px) {
  body {
    overflow: hidden;
  }

  .app {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .app-header {
    flex: 0 0 auto;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    padding: 8px 10px;
  }

  .ad-band {
    padding: 6px 8px;
  }

  .ad-band .adsbygoogle {
    min-height: 50px;
  }

  .eyebrow,
  .brand-block p:last-child {
    display: none;
  }

  .brand-block h1 {
    font-size: 16px;
    line-height: 1.2;
  }

  .language-control select {
    min-width: 104px;
    min-height: 36px;
    padding: 7px 9px;
  }

  .app-main {
    --mobile-panel-reserved: 74px;
    position: relative;
    flex: 1;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    display: block;
    padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .preview-pane {
    height: 100%;
    min-height: 0;
    padding-bottom: var(--mobile-panel-reserved);
    border-radius: 16px;
    transition: padding-bottom 0.18s ease;
  }

  .preview-toolbar {
    min-height: 42px;
    padding: 7px 10px;
  }

  .preview-toolbar h2 {
    font-size: 13px;
  }

  .preview-toolbar p {
    display: none;
  }

  .canvas-stage {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 4px;
    transition: padding 0.18s ease;
  }

  .canvas-shell {
    max-width: 100%;
    max-height: 100%;
  }

  .control-panel {
    position: absolute;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
    width: auto;
    max-width: none;
    min-height: 0;
    max-height: calc(100dvh - 92px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    padding: 8px;
    border-radius: 18px;
    touch-action: pan-y;
    box-shadow: 0 -16px 42px rgba(40, 50, 80, 0.12);
  }

  .export-dialog {
    align-items: end;
    padding: 12px max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }

  .export-dialog__panel {
    width: 100%;
    border-radius: 20px;
  }

  .app-main.is-mobile-panel-expanded .control-panel {
    max-height: min(72dvh, 640px);
    border-radius: 20px 20px 16px 16px;
  }

  .app-main.is-mobile-panel-expanded[data-active-mobile-panel="exif"] .control-panel,
  .app-main.is-mobile-panel-expanded[data-active-mobile-panel="advanced"] .control-panel {
    height: min(72dvh, 640px);
  }

  .flow-steps {
    display: none;
  }

  .mobile-panel-tools {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(108px, 0.68fr);
    align-items: center;
    gap: 8px;
  }

  .app-main.is-mobile-panel-expanded .mobile-panel-tools {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .mobile-panel-handle {
    display: none;
  }

  .mobile-panel-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid rgba(43, 185, 232, 0.42);
    border-radius: 999px;
    background: linear-gradient(135deg, #2bb9e8, #3bd6c6);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 10px 22px rgba(43, 185, 232, 0.24);
  }

  .app-main.is-mobile-panel-expanded .mobile-panel-toggle {
    display: inline-flex;
  }

  .mobile-panel-toggle::before {
    content: "\2630";
    font-size: 16px;
    line-height: 1;
  }

  .app-main.is-mobile-panel-expanded .mobile-panel-toggle::before {
    content: "\00d7";
    font-size: 20px;
  }

  .mobile-panel-select-wrap {
    min-width: 0;
    display: none;
  }

  .app-main.is-mobile-panel-expanded .mobile-panel-select-wrap {
    display: block;
  }

  .mobile-panel-select {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 9px 34px 9px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
  }

  .mobile-primary-action,
  .mobile-quick-export {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid rgba(43, 185, 232, 0.36);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--ink);
    font-size: 13px;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(43, 185, 232, 0.12);
  }

  .mobile-primary-action {
    border-color: rgba(43, 185, 232, 0.42);
    background: linear-gradient(135deg, #2bb9e8, #3bd6c6);
    color: #fff;
    box-shadow: 0 10px 22px rgba(43, 185, 232, 0.24);
  }

  .app-main.has-image .mobile-primary-action::before {
    content: "\2630";
    margin-right: 6px;
    font-size: 16px;
    line-height: 1;
  }

  .app-main.is-mobile-panel-expanded .mobile-primary-action {
    display: none;
  }

  .mobile-quick-export:disabled,
  .primary-button:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    transform: none;
  }

  body.is-resizing-mobile-panel {
    cursor: ns-resize;
    user-select: none;
  }

  .mobile-control-tabs {
    display: none;
  }

  .mobile-control-tabs button {
    min-width: 0;
    min-height: 36px;
    padding: 7px 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    color: #4b5366;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
  }

  .mobile-control-tabs button.is-active {
    border-color: rgba(43, 185, 232, 0.64);
    background: linear-gradient(135deg, #2bb9e8, #3bd6c6);
    color: #fff;
    box-shadow: 0 10px 20px rgba(43, 185, 232, 0.24);
  }

  .settings-track {
    min-height: 0;
    display: contents;
  }

  .control-panel > [data-mobile-panel],
  .settings-track > [data-mobile-panel] {
    display: none;
  }

  .app-main.is-mobile-panel-expanded .control-panel > [data-mobile-panel].is-mobile-active {
    display: grid;
  }

  .app-main.is-mobile-panel-expanded .settings-track > [data-mobile-panel].is-mobile-active {
    display: block;
  }

  .app-main:not(.is-mobile-panel-expanded) .settings-track,
  .app-main:not(.is-mobile-panel-expanded) .control-panel > [data-mobile-panel] {
    display: none;
  }

  .app-main:not(.is-mobile-panel-expanded) .status-message {
    display: none;
  }

  .upload-section {
    min-height: 0;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.9);
  }

  .upload-area {
    min-height: 96px;
    padding: 12px;
  }

  .upload-mark {
    width: 34px;
    height: 34px;
    font-size: 22px;
  }

  .control-section {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
  }

  .control-section summary {
    display: none;
  }

  .status-message {
    flex: 0 0 auto;
    max-height: 64px;
    overflow: auto;
    padding: 7px 9px;
  }

  .control-section[open] {
    padding-bottom: 10px;
  }

  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .template-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .template-card {
    flex: 0 0 172px;
    min-height: 122px;
    scroll-snap-align: start;
  }

  .preview-toolbar {
    flex: 0 0 auto;
    align-items: center;
    flex-direction: row;
    min-height: 46px;
    padding: 8px 10px;
  }

  .preview-toolbar > div {
    min-width: 0;
  }

  .preview-toolbar p {
    max-width: 56vw;
    white-space: nowrap;
  }

  .canvas-badge {
    padding: 6px 8px;
    font-size: 10px;
  }

  .canvas-stage {
    min-height: 0;
    max-height: none;
    padding: 4px;
  }

  .canvas-shell {
    max-width: 100%;
  }

  .primary-button {
    min-height: 52px;
  }
}

@media (max-width: 420px) {
  .brand-block h1 {
    font-size: 16px;
  }

  .canvas-stage {
    min-height: 0;
  }

  .control-section > :not(summary) {
    margin-left: 10px;
    margin-right: 10px;
  }
}
