* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #00a0e9;
  --primary-dark: #0080c0;
  --secondary: #FF6B6B;
  --accent: #FFE66D;
  --dark: #1A1A2E;
  --dark-light: #2D2D44;
  --gray: #6B7280;
  --success: #10B981;
}
body {
  font-family: 'Noto Sans JP', sans-serif;
  background: linear-gradient(135deg, #1A1A2E 0%, #16213E 100%);
  min-height: 100vh;
  color: #fff;
}
.header {
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(10px);
  padding: 0.6rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
.logo-text {
  font-size: 1.25rem; font-weight: 900;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.steps { display: flex; gap: 2rem; }
.step { display: flex; align-items: center; gap: 0.35rem; opacity: 0.5; transition: all 0.3s; font-size: 0.8rem; }
.step.active { opacity: 1; }
.step-number {
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
}
.step.active .step-number { background: var(--primary); }
.main-container { display: flex; height: calc(100vh - 58px); }
.sidebar {
  width: 260px;
  background: rgba(0,0,0,0.2);
  border-right: 1px solid rgba(255,255,255,0.1);
  display: flex; flex-direction: column; overflow-y: auto;
}
.sidebar-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-section.hidden { display: none; }
.sidebar-section h3 {
  font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--gray); margin-bottom: 0.5rem;
}
.size-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
.size-card {
  background: rgba(255,255,255,0.05);
  border: 2px solid transparent; border-radius: 8px;
  padding: 0.4rem 0.3rem; cursor: pointer; transition: all 0.3s; text-align: center;
}
.size-card:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.size-card.selected { border-color: var(--primary); background: rgba(0,160,233,0.1); }

.size-card .size-name { font-weight: 700; font-size: 0.8rem; line-height: 1.2; }
.size-card .size-height { font-size: 0.65rem; color: var(--gray); line-height: 1.2; }
.size-card .size-arc { font-size: 0.6rem; color: var(--primary); margin-top: 1px; }
.size-card .size-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--dark);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.55rem;
  font-weight: 700;
  margin-top: 0.15rem;
}
.material-options { display: flex; gap: 0.35rem; }
.material-btn {
  flex: 1; padding: 0.4rem 0.35rem;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1); border-radius: 6px;
  color: #fff; cursor: pointer; font-size: 0.7rem;
  transition: all 0.2s; text-align: center;
}
.material-btn:hover { background: rgba(255,255,255,0.1); }
.material-btn.selected { border-color: var(--primary); background: rgba(0,160,233,0.1); }
.material-btn .material-name { font-weight: 700; display: block; }
.material-btn .material-desc { font-size: 0.65rem; color: var(--gray); margin-top: 2px; }
.bg-type-tabs { display: flex; gap: 0.2rem; margin-bottom: 0.5rem; }
.bg-type-tab {
  flex: 1; padding: 0.35rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 5px;
  color: #fff; cursor: pointer; font-size: 0.65rem;
  transition: all 0.2s; text-align: center;
}
.bg-type-tab:hover { background: rgba(255,255,255,0.1); }
.bg-type-tab.active { background: var(--primary); border-color: var(--primary); }
.bg-panel { display: none; }
.bg-panel.visible { display: block; }
.bg-pattern-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.375rem; }
.bg-pattern {
  width: 100%; aspect-ratio: 1; border-radius: 6px;
  cursor: pointer; border: 2px solid transparent; transition: all 0.2s;
}
.bg-pattern:hover { transform: scale(1.1); }
.bg-pattern.selected { border-color: var(--primary); }
.bg-image-upload { display: flex; flex-direction: column; gap: 0.5rem; }
.bg-image-preview {
  height: 60px; background: rgba(255,255,255,0.05);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; border: 2px dashed rgba(255,255,255,0.2); cursor: pointer;
}
.bg-image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.bg-image-preview.empty { color: var(--gray); font-size: 0.75rem; }
.bg-image-fit-row { display: flex; gap: 0.35rem; }
.bg-image-fit-btn {
  flex: 1; padding: 0.35rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 5px;
  color: #fff; cursor: pointer; font-size: 0.65rem;
}
.bg-image-fit-btn:hover { background: rgba(255,255,255,0.1); }
.bg-image-fit-btn.active { background: var(--primary); border-color: var(--primary); }
.tool-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.tool-btn {
  flex: 1; min-width: calc(50% - 0.25rem); padding: 0.75rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
  color: #fff; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
  gap: 0.5rem; font-size: 0.875rem;
}
.tool-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--primary); }
.tool-btn svg { width: 18px; height: 18px; }
.tool-btn.active { background: rgba(245,158,11,0.22); border-color: rgba(245,158,11,0.9); }
.text-options { display: none; flex-direction: column; gap: 0.75rem; }
.text-options.visible { display: flex; }

/* エディタツールバー（キャンバス上部） */
.editor-toolbar {
  width: 600px;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(10px);
  border-radius: 12px 12px 0 0;
  border: 1px solid rgba(255,255,255,0.1);
  border-bottom: none;
  overflow: hidden;
  position: sticky;
  top: 0;
  z-index: 30;
}
.toolbar-main {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.75rem; gap: 0.75rem;
}
.toolbar-tools {
  display: flex; gap: 0.5rem;
}
.toolbar-btn {
  padding: 0.5rem 1rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 8px;
  color: #fff; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; font-weight: 600; font-family: inherit;
  white-space: nowrap;
}
.toolbar-btn:hover { background: rgba(0,160,233,0.3); border-color: var(--primary); }
.toolbar-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.toolbar-btn:disabled { opacity: 0.45; cursor: default; }
.toolbar-hint {
  font-size: 0.65rem; color: var(--gray); white-space: nowrap;
}
.toolbar-text-options {
  display: none;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 0.5rem 0.75rem;
  background: rgba(0,0,0,0.15);
}
.toolbar-text-options.visible { display: block; }
.toolbar-text-row {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}
.toolbar-group {
  display: flex; align-items: center; gap: 0.25rem;
}
.toolbar-group .writing-mode-toggle { gap: 0.2rem; }
.toolbar-group .writing-mode-btn {
  padding: 0.35rem 0.5rem; font-size: 0; /* icon only in toolbar */
}
.toolbar-group .writing-mode-btn svg { width: 16px; height: 16px; }
.toolbar-select {
  padding: 0.35rem 0.5rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
  color: #fff; font-size: 0.75rem; font-family: inherit;
  min-width: 190px;
  max-width: 220px;
}
.toolbar-select:focus { outline: none; border-color: var(--primary); }
.toolbar-select option { background: var(--dark); }
.toolbar-select-sm {
  padding: 0.35rem 0.5rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
  color: #fff; font-size: 0.75rem; font-family: inherit;
  max-width: 80px;
}
.toolbar-select-sm:focus { outline: none; border-color: var(--primary); }
.toolbar-select-sm option { background: var(--dark); }
.toolbar-input {
  padding: 0.35rem 0.5rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px;
  color: #fff; font-size: 0.75rem; font-family: inherit;
  width: 60px;
}
.toolbar-input:focus { outline: none; border-color: var(--primary); }
.toolbar-color {
  width: 28px; height: 28px; border: none; border-radius: 6px;
  cursor: pointer; background: none; padding: 0;
}
.toolbar-color::-webkit-color-swatch-wrapper { padding: 0; }
.toolbar-color::-webkit-color-swatch { border: 2px solid rgba(255,255,255,0.25); border-radius: 5px; }
.toolbar-group .color-presets { display: flex; gap: 0.2rem; }
.toolbar-group .color-preset { width: 22px; height: 22px; border-radius: 4px; }
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group label { font-size: 0.75rem; color: var(--gray); }
.form-group select, .form-group input[type="text"], .form-group input[type="number"], .form-group textarea {
  padding: 0.625rem 0.75rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  color: #fff; font-size: 0.875rem; font-family: inherit;
}
.form-group select:focus, .form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-group select option { background: var(--dark); }
.color-row { display: flex; gap: 0.5rem; align-items: center; }
.color-input { width: 40px; height: 40px; border: none; border-radius: 8px; cursor: pointer; background: none; }
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 2px solid rgba(255,255,255,0.2); border-radius: 6px; }
.color-presets { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.color-preset { width: 28px; height: 28px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s; }
.color-preset:hover { transform: scale(1.1); }
.writing-mode-toggle { display: flex; gap: 0.5rem; }
.writing-mode-btn {
  flex: 1; padding: 0.5rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  color: #fff; cursor: pointer; font-size: 0.75rem;
  transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 0.25rem;
}
.writing-mode-btn:hover { background: rgba(255,255,255,0.1); }
.writing-mode-btn.active { background: var(--primary); border-color: var(--primary); }
.writing-mode-btn svg { width: 16px; height: 16px; }
.canvas-area {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 1.5rem 2rem 2rem; position: relative; overflow: auto;
  gap: 0;
}
.canvas-wrapper {
  background: #ffffff; border-radius: 0 0 16px 16px; padding: 0;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
  position: relative; overflow: hidden;
  width: 600px;
}
.canvas-container {
  position: relative;
  overflow: hidden;
  border-radius: 0 0 16px 16px;
  width: 100%;
  background: transparent;
  box-shadow: none;
}
.canvas-controls {
  position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
  display: flex; gap: 0.5rem;
  background: rgba(0,0,0,0.8); padding: 0.5rem; border-radius: 8px;
}
.canvas-control-btn {
  width: 36px; height: 36px; border: none;
  background: rgba(255,255,255,0.1); border-radius: 6px;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.canvas-control-btn:hover { background: var(--primary); }
.canvas-control-btn.active { background: var(--secondary); }
.canvas-control-btn svg { width: 18px; height: 18px; }
.right-panel {
  width: 280px; background: rgba(0,0,0,0.2);
  border-left: 1px solid rgba(255,255,255,0.1);
  display: flex; flex-direction: column;
}
.order-summary { padding: 1.25rem; flex: 1; }
.order-summary h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--gray); margin-bottom: 1rem; }
.summary-item { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.875rem; }
.summary-item .label { color: var(--gray); }
.summary-safety-note {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.06);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--gray);
}
.summary-safety-note.is-ok {
  background: rgba(16,185,129,0.12);
  color: #b8f5de;
}
.summary-safety-note.is-warning {
  background: rgba(245,158,11,0.14);
  color: #fde8b2;
}
.summary-safety-note.is-error {
  background: rgba(239,68,68,0.14);
  color: #ffc2c2;
}
.action-buttons { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }
.btn {
  padding: 1rem 1.5rem; border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: all 0.3s; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 4px 15px rgba(0,160,233,0.4);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,160,233,0.5); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-secondary { background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2); }
.btn-secondary:hover { background: rgba(255,255,255,0.15); }
.btn-small { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.btn-row { display: flex; gap: 0.5rem; }
.btn-row .btn { flex: 1; }
.btn-full { width: 100%; }
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
  z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal { background: var(--dark-light); border-radius: 16px; padding: 2rem; max-width: 500px; width: 90%; max-height: 90vh; overflow-y: auto; }
.modal h2 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.modal .form-group { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }
.modal-actions .btn { flex: 1; }
.success-content { text-align: center; }
.success-icon { width: 80px; height: 80px; background: var(--success); border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 1.5rem; }
.success-icon svg { width: 40px; height: 40px; color: #fff; }
.order-number { background: rgba(255,255,255,0.1); padding: 1rem; border-radius: 8px; font-size: 1.25rem; font-weight: 700; margin: 1rem 0; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }
.object-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  gap: 0.35rem;
  z-index: 20;
  flex-wrap: wrap;
  max-width: calc(100% - 16px);
  justify-content: flex-end;
}
.object-controls.visible { display: flex; }
.object-control-btn {
  background: rgba(0,0,0,0.8); color: #fff; border: none;
  padding: 0.5rem 0.75rem; border-radius: 6px; cursor: pointer;
  font-size: 0.75rem; display: flex; align-items: center; gap: 0.25rem;
}
.object-control-btn:hover { background: var(--secondary); }
.object-control-btn svg { width: 14px; height: 14px; }
.object-control-btn-small { min-width: 2.8rem; justify-content: center; padding: 0.45rem 0.55rem; }
.object-control-btn.active { background: rgba(245,158,11,0.9); }
.canvas-container.has-bg-edit {
  box-shadow: inset 0 0 0 2px rgba(245,158,11,0.9);
}
.canvas-container.has-bg-edit::after {
  content: '背景編集中';
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(245,158,11,0.9);
  color: #111;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.info-text { font-size: 0.75rem; color: var(--gray); margin-top: 0.5rem; padding: 0.5rem; background: rgba(255,255,255,0.05); border-radius: 6px; }
.loading-spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: #fff; animation: spin 1s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.canvas-container.pan-mode canvas { cursor: grab !important; }
.canvas-container.pan-mode.panning canvas { cursor: grabbing !important; }

/* ズームインジケーター */
.zoom-indicator {
  position: absolute; top: 1rem; right: 1rem;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(8px);
  padding: 0.5rem 0.875rem; border-radius: 8px;
  display: flex; align-items: center; gap: 0.625rem;
  z-index: 10; transition: all 0.3s;
}
.zoom-indicator.actual-size {
  background: rgba(0,160,233,0.85);
  box-shadow: 0 0 12px rgba(0,160,233,0.4);
}
.zoom-mode-label {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem; border-radius: 4px;
  background: rgba(255,255,255,0.15); color: #fff;
}
.zoom-indicator.actual-size .zoom-mode-label {
  background: rgba(255,255,255,0.25);
}
.zoom-percentage {
  font-size: 0.8rem; font-weight: 600;
  color: rgba(255,255,255,0.85); font-variant-numeric: tabular-nums;
}

/* ミニマップ */
.minimap-section {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.minimap-section h3 {
  font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--gray); margin-bottom: 0.75rem;
}
.minimap-container {
  position: relative; width: 100%;
  background: rgba(255,255,255,0.08); border-radius: 8px;
  overflow: hidden; border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
}
.minimap-container canvas {
  display: block; width: 100%; height: auto;
}
.minimap-viewport {
  position: absolute; border: 2px solid var(--primary);
  background: rgba(0,160,233,0.1);
  border-radius: 2px; pointer-events: none;
  transition: opacity 0.2s;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(0,160,233,0.3);
}
.minimap-viewport.full-view {
  border-color: var(--success);
  background: rgba(16,185,129,0.08);
}
.minimap-info {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.5rem; font-size: 0.7rem; color: var(--gray);
}
.minimap-info span:first-child {
  font-weight: 600; font-variant-numeric: tabular-nums;
}

/* 注文完了モーダル: データ保存セクション */
.success-download-section {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.1);
}
.success-download-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--light);
  margin-bottom: 0.75rem;
  text-align: center;
}
.success-download-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  width: 100%;
}
.success-download-btn:last-of-type {
  margin-bottom: 0;
}
.success-download-btn svg {
  flex-shrink: 0;
}
.success-download-hint {
  font-size: 0.7rem;
  color: var(--gray);
  margin-top: 0.75rem;
  text-align: center;
}


/* ============================================================
   レスポンシブ対応
   ・PC (>=1024px): 現状維持（3カラム）
   ・タブレット (768px〜1023px): サイドバードロワー化、キャンバス+右パネル横並び
   ・スマホ (<=767px): 縦積み、注文ボタン画面下部 sticky 固定
   ============================================================ */

/* ---- ハンバーガーボタン（モバイル/タブレット表示） ---- */
.menu-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  color: #fff; padding: 0.5rem; border-radius: 6px;
  transition: background 0.2s;
}
.menu-toggle:hover { background: rgba(255,255,255,0.1); }
.menu-toggle svg { width: 22px; height: 22px; display: block; }

/* ---- サイドバーオーバーレイ ---- */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ---- サイドバー内の閉じるボタン ---- */
.sidebar-close {
  display: none;
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.6); padding: 0.25rem;
  margin-left: auto; border-radius: 4px;
  transition: color 0.2s;
}
.sidebar-close:hover { color: #fff; }
.sidebar-close svg { width: 20px; height: 20px; display: block; }
.sidebar-header {
  display: none;
  align-items: center; padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: rgba(255,255,255,0.7);
}

/* ---- FAB: 廃止済み、全デバイスで非表示 ---- */
.mobile-order-fab { display: none !important; }

/* ---- canvas-footer: PC/タブレットでは通常の縦積みラッパー ---- */
.canvas-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
  max-width: 600px;
}
.canvas-footer .canvas-controls {
  position: static; transform: none;
  margin-top: 0.5rem;
  display: flex; gap: 0.5rem;
  background: rgba(0,0,0,0.8); padding: 0.5rem; border-radius: 8px;
}
.canvas-footer .zoom-indicator {
  position: static; margin-top: 0.5rem; align-self: flex-end;
}

/* スマホ用注文ボタン: PC/タブレットでは非表示 */
.mobile-order-inline-btn { display: none; }

/* ツールバー内ズームインジケーター: PC/タブレットでは非表示 */
.toolbar-zoom-indicator { display: none; }

/* canvas-with-side: PC/タブレットではラッパーとして透過 */
.canvas-with-side { display: contents; }

/* canvas-side-panel: PC/タブレットでは非表示 */
.canvas-side-panel { display: none; }

/* ============================================================
   タブレット〜スマホ共通 (<=1023px): ヘッダー固定・ハンバーガー・ドロワー
   ============================================================ */
@media (max-width: 1023px) {
  .header { position: sticky; top: 0; z-index: 200; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .step span:last-child { display: none; }
  .steps { gap: 1rem; }
  .sidebar-header { display: flex; }
  .sidebar-close { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 210;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 280px; overflow-y: auto;
    background: rgba(26,26,46,0.98);
    backdrop-filter: blur(20px);
  }
  .sidebar.open { transform: translateX(0); }
  .minimap-section { display: none; }
  .toolbar-hint { display: none; }
  .toolbar-btn { padding: 0.625rem 0.875rem; min-height: 44px; }
  .canvas-control-btn { width: 44px; height: 44px; }
  .btn { min-height: 44px; }
}

/* ============================================================
   タブレット (768px〜1023px): 横並び維持
   right-panel: flex列 + order-summary スクロール + action-buttons 下部固定
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  .main-container {
    flex-direction: row;
    /* Safariのアドレスバー/ツールバーを除いた実表示高さに合わせる */
    /* dvh: dynamic viewport height = Safariのバー表示/非表示を動的に反映 */
    height: calc(100vh - 58px);
    height: calc(100dvh - 58px);
    overflow: hidden;
  }
  .canvas-area {
    flex: 1; min-width: 0;
    padding: 1rem; overflow: auto;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
  }
  .editor-toolbar { width: 100%; max-width: 600px; border-radius: 12px 12px 0 0; }
  .canvas-wrapper  { width: 100%; max-width: 600px; overflow: hidden; }
  .zoom-indicator  { position: static; margin-top: 0.5rem; align-self: flex-end; }
  .canvas-controls { position: static; transform: none; margin-top: 0.5rem; }

  /* ★ 右パネル: 高さ固定 + flex列 + 内部スクロール
     Safariはアドレスバー分だけ実際の表示領域が縮まるため
     safe-area-inset-bottom を padding-bottom に加算して確保する */
  .right-panel {
    width: 220px;
    flex-shrink: 0;
    height: calc(100vh - 58px);
    height: calc(100dvh - 58px);
    border-left: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;   /* パネル自体はスクロールしない */
  }
  .order-summary {
    flex: 1;            /* 残り高さを全て使う */
    min-height: 0;      /* flex子要素スクロールに必須 */
    overflow-y: auto;
    padding: 1rem;
  }
  .action-buttons {
    flex-shrink: 0;     /* 押し出されず常に最下部 */
    padding: 1rem;
    /* ★ Safariのホームインジケーター/ツールバー分のSafe Areaを確保 */
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    gap: 0.5rem;
  }
}

/* ============================================================
   スマホ (<=767px): 縦積み + 注文ボタン sticky 固定
   ============================================================ */
@media (max-width: 767px) {
  .steps { display: none; }
  .header { padding: 0.5rem 0.875rem; }

  /* 縦積み */
  .main-container { flex-direction: column; height: auto; overflow: visible; }

  /* キャンバスエリア */
  .canvas-area {
    order: 1; padding: 0.625rem; overflow: visible; justify-content: flex-start;
  }

  /* ツールバー */
  .editor-toolbar { width: 100%; max-width: 100%; border-radius: 8px 8px 0 0; }
  .toolbar-main { padding: 0.5rem; flex-wrap: wrap; gap: 0.4rem; }
  .toolbar-tools { gap: 0.4rem; }
  .toolbar-btn { padding: 0.5rem 0.75rem; font-size: 0.75rem; min-height: 44px; }

  /* テキスト属性バー: スマホでは折り返し2行表示にして全項目を一目で見えるようにする */
  .toolbar-text-options {
    padding: 0.5rem;
    overflow-x: visible;  /* 横スクロール廃止 */
  }
  .toolbar-text-row {
    flex-wrap: wrap;        /* 折り返し許可 */
    min-width: unset;       /* min-width: max-content を解除 */
    gap: 0.35rem;
    row-gap: 0.4rem;
  }
  /* フォント選択は幅を広げて読みやすく */
  .toolbar-select { max-width: unset; width: auto; font-size: 0.7rem; flex: 1; min-width: 140px; }
  .toolbar-select-sm { max-width: 72px; font-size: 0.7rem; }
  /* 書式グループは横幅いっぱいに広げる */
  .toolbar-group:has(.toolbar-select) { flex: 1; min-width: 90px; }

  /* ================================================================
     canvas-with-side: キャンバスと右サイドパネルを横並び
     canvas-wrapper は flex:1 で残り幅を埋める
     ================================================================ */
  .canvas-with-side {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    /* サイドパネル(44px)分を引いてキャンバスが画面幅に収まるよう制限 */
    max-width: 100%;
    overflow: hidden;
  }
  /* canvas-wrapper: スマホではPC用の固定幅・影・角丸を上書き */
  .canvas-wrapper {
    flex: 1;
    min-width: 0;
    /* PC用の width:600px を上書き。サイドパネル44px分を引く */
    width: calc(100% - 44px) !important;
    max-width: calc(100% - 44px) !important;
    /* 四隅すべて丸める（サイドパネルは独立要素なので接合不要） */
    border-radius: 16px 16px 16px 16px;
    overflow: hidden;
    box-shadow: none;
  }
  /* canvas-container の角丸もスマホ向けに上書き */
  .canvas-container {
    border-radius: 16px 16px 16px 16px;
  }
  /* editor-toolbar の角丸 */
  .editor-toolbar {
    border-radius: 12px 12px 0 0;
  }

  /* ================================================================
     canvas-side-panel: キャンバス右に縦並びでボタンを配置
     幅: 44px固定（タップターゲットサイズ確保）
     背景: キャンバスに揃した暗色のサイドバー
     ================================================================ */
  .canvas-side-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 44px;
    /* flex-shrink:0 で幅が潰れないようにする */
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 0 16px 16px 0;
    padding: 4px 2px 6px 2px;
    /* overflow:hidden でボタンがパネル外にはみ出さないようにする */
    overflow: hidden;
  }

  /* side-ctrl-btn: サイドパネルの各ボタン */
  .side-ctrl-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
  }
  .side-ctrl-btn svg { width: 18px; height: 18px; }
  .side-ctrl-btn:active { background: var(--primary); }
  .side-ctrl-btn.active  { background: var(--secondary); }

  /* side-zoom-indicator: ズーム率表示 */
  .side-zoom-indicator {
    margin-top: auto;
    padding-top: 4px;
    text-align: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
    line-height: 1.2;
    letter-spacing: -0.02em;
  }

  /* canvas-footer: スマホではズームボタン行・インジケーターを非表示（右サイドに移動したため） */
  .canvas-footer .canvas-controls { display: none !important; }
  .canvas-footer .zoom-indicator  { display: none !important; }
  .canvas-footer { max-width: 100%; }

  /* オブジェクト操作ボタン:
     canvas-wrapper（position:relative）内に absolute で配置されるため
     スマホでも canvas 内に収まる。
     ★ 下部 sticky 注文ボタンとは物理的に重ならない（canvas内上部固定）*/
  .object-controls { top: 4px; right: 4px; gap: 0.25rem; }
  .object-control-btn { padding: 0.45rem 0.6rem; font-size: 0.7rem; min-height: auto; }
  .object-control-btn-small { min-width: 2.4rem; padding: 0.42rem 0.5rem; }

  /* 右パネル: キャンバス下に縦積み */
  .right-panel {
    order: 2; width: 100%;
    border-left: none; border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: column;
  }
  .order-summary { padding: 0.75rem 1rem; }
  .order-summary h3 { margin-bottom: 0.5rem; }
  .summary-item { font-size: 0.8rem; padding: 0.35rem 0; }

  /* 右パネル内 action-buttons は非表示（sticky ボタンで代替） */
  .action-buttons { display: none; }

  /* ================================================================
     スマホ用「注文へ進む": position sticky で画面最下部に常時固定
     ・スクロールしても常に画面下部に追従する
     ・bottom: 0 により Safariのツールバー直上に貼り付く
     ・env(safe-area-inset-bottom) でホームインジケーター分の内側余白確保
     ・z-index: 150 で object-controls(z:20) より確実に前面に来ない問題解消:
       object-controls は canvas-wrapper 内の absolute なので
       このボタン（canvas-wrapper の外）と z-index 競合しない
     ================================================================ */
  .mobile-order-inline-btn {
    display: block;
    /* sticky: スクロール追従で常に画面下部に表示 */
    position: sticky;
    bottom: 0;
    left: 0;
    z-index: 100;
    width: 100%;
    margin: 0.75rem 0 0;
    padding: 1rem 1.5rem;
    /* ★ Safariのホームインジケーター分を safe-area で確保 */
    padding-bottom: max(1rem, calc(0.75rem + env(safe-area-inset-bottom, 0px)));
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    /* 四隅すべて丸める */
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 -6px 24px rgba(0,160,233,0.45);
    min-height: 56px;
    font-family: inherit;
    /* Safari で border-radius が確実に効くよう isolation 設定 */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
  }
  .mobile-order-inline-btn:active {
    background: linear-gradient(135deg, var(--primary-dark), #006090);
  }

  /* sticky ボタンは flow 内なので right-panel の余分な padding 不要 */
  .right-panel { padding-bottom: 0; }

  /* モーダル */
  .modal { width: calc(100% - 1rem); max-height: 85vh; margin: 0.5rem; padding: 1.5rem; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { flex: none; }
}
