:root {
  --bg-color: #0d0d12;
  --panel-bg: rgba(22, 22, 32, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary-gradient: linear-gradient(135deg, #ff5e62, #ff9966);
  --primary-color: #ff5e62;
  --primary-hover: #ff7b7f;
  --secondary-color: #3b82f6;
  --secondary-gradient: linear-gradient(135deg, #3b82f6, #60a5fa);
  --danger-color: #ef4444;
  --card-bg: rgba(35, 35, 48, 0.5);
  --card-border: rgba(255, 255, 255, 0.05);
  --font-title: 'Outfit', 'Noto Sans JP', sans-serif;
  --font-body: 'Noto Sans JP', sans-serif;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.3);
}

@font-face {
  font-family: 'TachibanaFont';
  src: url('TachibanaFont_3.0.ttf') format('truetype');
  font-display: swap;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* 背景グラデーション装飾 */
.bg-glow {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.15;
  z-index: -1;
  pointer-events: none;
}

.bg-glow-1 {
  background: #ff5e62;
  top: -100px;
  right: -100px;
  animation: float 20s ease-in-out infinite alternate;
}

.bg-glow-2 {
  background: #3b82f6;
  bottom: -150px;
  left: -150px;
  animation: float 25s ease-in-out infinite alternate-reverse;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(60px, 40px) scale(1.1); }
}

/* ヘッダー */
.app-header {
  padding: 20px 0;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(13, 13, 18, 0.95);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-emoji {
  font-size: 28px;
  animation: write 3s ease-in-out infinite;
}

@keyframes write {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(15deg) translateY(-2px); }
}

.app-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.app-title span {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.security-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--panel-border);
}

.security-badge svg {
  color: #10b981;
}

/* メインレイアウト */
.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 150px);
}

/* タブナビゲーション */
.tab-navigation {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 12px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--panel-border);
}

.tab-btn.active svg {
  color: var(--primary-color);
}

/* タブペイン表示切替 */
.tab-pane {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ボタン共通 */
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 94, 98, 0.3);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 94, 98, 0.4);
}

.btn-primary:disabled {
  background: #4b5563;
  color: #9ca3af;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 4px;
}

.badge {
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--panel-border);
}

/* ==========================================================================
   1. 文字入れエディタのデザイン
   ========================================================================== */
.editor-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

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

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.control-section {
  background: rgba(22, 22, 32, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-main);
  border-left: 3px solid var(--primary-color);
  padding-left: 8px;
}

.section-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header-inline .section-title {
  margin-bottom: 0;
}

.image-source-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.text-layers-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  margin-top: 10px;
}

.no-layers-message {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 15px 0;
  border: 1px dashed var(--panel-border);
  border-radius: 8px;
}

/* レイヤーアイテム */
.text-layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: default;
  transition: all 0.2s ease;
}

.text-layer-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.text-layer-item.active {
  background: rgba(255, 94, 98, 0.08);
  border-color: rgba(255, 94, 98, 0.4);
}

.layer-drag-handle {
  cursor: grab;
  color: var(--text-muted);
  user-select: none;
  font-size: 14px;
}

.layer-direct-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 6px !important;
  outline: none;
  width: 100%;
}

.layer-direct-input:focus {
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 4px;
}

.layer-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.btn-layer-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}

.btn-layer-action:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-layer-action.btn-delete:hover {
  background: var(--danger-color);
  border-color: var(--danger-color);
  color: white;
}

/* プロパティインプット */
.prop-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prop-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.prop-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.prop-grid-colors {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

input[type="text"],
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--primary-color);
}

.range-input-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  outline: none;
  background: rgba(255, 255, 255, 0.1);
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.color-picker-wrapper {
  position: relative;
  width: 100%;
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.color-picker-wrapper input[type="color"] {
  position: absolute;
  top: -5px;
  left: -5px;
  width: calc(100% + 10px);
  height: calc(100% + 10px);
  border: none;
  cursor: pointer;
  background: none;
}

/* アコーディオン・詳細パネル */
.accordion-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.prop-details {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
}

.prop-details summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  color: var(--text-main);
  outline: none;
}

.prop-details summary:hover {
  background: rgba(255, 255, 255, 0.02);
}

.details-content {
  padding: 14px;
  border-top: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* チェックボックスカスタム */
.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 18px;
  width: 18px;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.checkbox-container:hover input ~ .checkmark {
  background-color: rgba(255, 255, 255, 0.05);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-container .checkmark:after {
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.layer-actions-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}

/* キャンバスプレビュー */
.preview-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 500px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.preview-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 16px;
}

.preview-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 10px;
  border-radius: 99px;
}

.canvas-container {
  flex: 1;
  position: relative;
  background: #1e1e2d;
  background-image: linear-gradient(45deg, #161622 25%, transparent 25%),
                    linear-gradient(-45deg, #161622 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #161622 75%),
                    linear-gradient(-45deg, transparent 75%, #161622 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 480px;
  box-shadow: var(--shadow-lg);
  user-select: none;
  -webkit-user-select: none;
}

.canvas-container.drag-over {
  border-color: var(--primary-color) !important;
  background-color: rgba(255, 94, 98, 0.05) !important;
  box-shadow: 0 0 15px rgba(255, 94, 98, 0.2);
}

canvas {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
  z-index: 5;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas:active {
  cursor: grabbing;
}

.canvas-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 18, 0.95);
  z-index: 10;
  padding: 40px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.placeholder-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 320px;
}

.placeholder-icon {
  font-size: 48px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.placeholder-content p {
  font-size: 14px;
  color: var(--text-muted);
}

/* ==========================================================================
   2. 絵文字パレットのデザイン
   ========================================================================== */
.emoji-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}

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

.emoji-grid-panel {
  background: rgba(22, 22, 32, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 18px;
}

.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.filter-btn.active {
  color: white;
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 12px;
  max-height: 550px;
  overflow-y: auto;
  padding-right: 6px;
}

.emoji-item {
  aspect-ratio: 1;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'TachibanaFont';
  font-size: 28px;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.emoji-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 94, 98, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.emoji-item.active {
  background: rgba(255, 94, 98, 0.12);
  border-color: var(--primary-color);
  transform: scale(1.05);
}

.emoji-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.emoji-detail-card {
  background: rgba(22, 22, 32, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.emoji-large-preview {
  width: 140px;
  height: 140px;
  background: #151520;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'TachibanaFont';
  font-size: 80px;
  color: var(--text-main);
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}

.emoji-large-preview .empty-state {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-muted);
}

.emoji-info-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--panel-border);
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.info-label {
  color: var(--text-muted);
  font-weight: 600;
}

.info-val {
  color: var(--text-main);
  font-weight: 700;
  font-family: var(--font-title);
}

.action-buttons-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-subtext {
  display: block;
  font-size: 10px;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 2px;
}

.info-card {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 12px;
  padding: 16px;
}

.info-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #60a5fa;
}

.info-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 6px;
}

.info-card p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   3. 共通の足回り（フッター・トースト）
   ========================================================================== */
.app-footer {
  text-align: center;
  padding: 30px 0;
  border-top: 1px solid var(--panel-border);
  color: var(--text-muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(20, 20, 30, 0.95);
  border: 1px solid var(--primary-color);
  padding: 12px 24px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon {
  font-size: 16px;
}

.toast-message {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

/* 文字入れエディタ内 簡易ポップアップ絵文字パレット */
.text-input-wrapper {
  position: relative;
  width: 100%;
}

.text-input-wrapper textarea {
  padding-right: 44px; /* 絵文字ボタンと重ならないようにする */
}

.btn-emoji-trigger {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-family: "TachibanaFont", sans-serif;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-emoji-trigger:hover {
  background: rgba(255, 94, 98, 0.2);
  border-color: rgba(255, 94, 98, 0.6);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(255, 94, 98, 0.3);
  transform: translateY(-1px) scale(1.08);
}

.btn-emoji-trigger:active {
  transform: translateY(1px) scale(0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.emoji-popover {
  position: absolute;
  bottom: calc(100% + 8px); /* テキストエリアの上に表示 */
  right: 0;
  z-index: 100;
  width: 320px;
  background: rgba(30, 30, 42, 0.98);
  border: 1px solid rgba(255, 94, 98, 0.4);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  padding: 12px;
  animation: popoverFadeIn 0.15s ease-out;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-header {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
}

.popover-tabs {
  display: flex;
  gap: 4px;
  justify-content: space-between;
}

.popover-tab-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.popover-tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.popover-tab-btn.active {
  background: var(--primary-gradient);
  border-color: var(--primary-color);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 94, 98, 0.2);
}

.popover-emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.popover-emoji-grid::-webkit-scrollbar {
  width: 4px;
}

.popover-emoji-grid::-webkit-scrollbar-track {
  background: transparent;
}

.popover-emoji-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.popover-emoji-btn {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'TachibanaFont';
  font-size: 18px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  padding: 0;
}

.popover-emoji-btn:hover {
  background: rgba(255, 94, 98, 0.15);
  border-color: var(--primary-color);
  transform: scale(1.12);
}

.footer-bug-report {
  margin-top: 8px;
}

.footer-bug-report a {
  color: rgba(255, 94, 98, 0.8);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.footer-bug-report a:hover {
  color: #ff7b7f;
  text-decoration: underline;
  text-shadow: 0 0 8px rgba(255, 94, 98, 0.3);
}

/* ==========================================================================
   スマホ（モバイル）専用レイアウト最適化
   ========================================================================== */
@media (max-width: 768px) {
  /* メインタブナビゲーション全体をスマホで表示する */
  .tab-navigation {
    display: flex !important;
    margin-bottom: 16px;
    gap: 8px;
  }

  .tab-navigation .tab-btn {
    flex: 1;
    justify-content: center;
    font-size: 13px;
    padding: 8px 6px;
    gap: 6px;
  }

  /* 絵文字プレビュー＆ツールパネルをスマホで非表示にする */
  .emoji-detail-panel {
    display: none !important;
  }

  /* プレビューを上部、コントロールを下に配置 */
  .editor-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  /* プレビューを上部に固定 (Sticky) */
  .preview-panel {
    order: -1;
    position: sticky;
    top: 0;
    z-index: 99;
    background: #11111a;
    padding: 10px 16px;
    border-bottom: 1px solid var(--panel-border);
    margin: -16px -16px 12px -16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    min-height: auto !important;
    height: auto !important;
  }

  .preview-header {
    display: none !important; /* スマホでは不要 */
  }

  /* キャンバス自体のスマホ時高さ制限・アスペクト比縮尺固定 */
  .canvas-container {
    position: relative;
    width: 100%;
    height: 200px;
    background: #0d0d15;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 0 auto;
  }

  #editor-canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
  }

  /* モード切り替えボタン（スマホ専用、右上フローティング） */
  .mobile-mode-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 101;
    background: rgba(255, 94, 98, 0.95);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 94, 98, 0.3);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
  }

  .mobile-mode-badge.mode-move {
    background: rgba(46, 204, 113, 0.95);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
  }
  
  .control-section {
    padding: 16px;
  }

  /* 画像読み込み後は、スマホでヘッダーロゴとセキュリティバッジを非表示にする */
  body.image-loaded .app-header {
    display: none !important;
  }
  
  body.image-loaded .app-main {
    padding-top: 8px !important;
  }

  /* 初期状態（画像未選択）：1だけを表示、2, 3, 4, プレビューは非表示 */
  body:not(.image-loaded) .control-panel > .control-section:nth-child(2),
  body:not(.image-loaded) .control-panel > .control-section:nth-child(3),
  body:not(.image-loaded) .control-panel > .control-section:nth-child(4),
  body:not(.image-loaded) .preview-panel {
    display: none !important;
  }
  
  /* 画像選択後：1を非表示にし、2, 3, 4, プレビューを表示 */
  body.image-loaded .control-panel > .control-section:nth-child(1) {
    display: none !important;
  }

  /* 画像読み込み後、スマホでは従来の縦並びコントロールパネルを完全に非表示にする */
  body.image-loaded .control-panel {
    display: none !important;
  }

  /* 代わりにスマホ用ツールエリアを表示する */
  body.image-loaded .mobile-tool-container {
    display: block !important;
  }
}

/* スマホ用ツールコンテナ */
.mobile-tool-container {
  width: 100%;
  background: #12121a;
  border-top: 1px solid var(--panel-border);
  padding: 12px 16px;
  box-sizing: border-box;
}

/* 2カラムのタイル型ツールグリッド */
.mobile-tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

/* 各ツールタイルのスタイリング */
.tool-btn-tile {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}

.tool-btn-tile .tool-icon {
  font-size: 18px;
}

.tool-btn-tile .tool-label {
  font-size: 12px;
}

.tool-btn-tile:active {
  background: rgba(255, 94, 98, 0.15);
  border-color: var(--primary-color);
  transform: scale(0.96);
}

.tool-btn-tile.active {
  background: rgba(255, 94, 98, 0.2);
  border-color: var(--primary-color);
  box-shadow: 0 0 10px rgba(255, 94, 98, 0.2);
}

/* 重要保存ボタンのハイライト */
.tool-btn-primary {
  background: linear-gradient(135deg, #ff5e62, #ff9966);
  border: none;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(255, 94, 98, 0.3);
}

.tool-btn-primary:active {
  background: linear-gradient(135deg, #e04e52, #e08556);
}

/* スマホ用アクティブゲージパネル */
.mobile-gauge-panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  box-sizing: border-box;
  animation: gaugeSlideIn 0.2s ease-out;
}

@keyframes gaugeSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.mobile-toolbar-scroll {
  display: inline-flex;
  gap: 8px;
}

.mobile-toolbar .tool-btn {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}

.mobile-toolbar .tool-btn:active {
  background: rgba(255, 94, 98, 0.2);
  border-color: var(--primary-color);
  transform: scale(0.95);
}

/* ジェスチャ操作中の数値フィードバックバッジ */
.gesture-badge {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(18, 18, 26, 0.95);
  color: #ffffff;
  padding: 16px 28px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: bold;
  z-index: 2000;
  border: 1px solid var(--primary-color);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  text-align: center;
  font-family: var(--font-title);
  animation: badgePulse 0.15s ease-out;
}

@keyframes badgePulse {
  from { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* スマホ用絵文字挿入モーダルの追加スタイル */
.emoji-modal-tab-btn {
  opacity: 0.6;
  transition: all 0.2s ease;
}

.emoji-modal-tab-btn.active {
  opacity: 1;
  transform: scale(1.15);
  border-bottom: 2px solid var(--primary-color) !important;
}

.emoji-modal-grid-char {
  font-size: 24px;
  padding: 6px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.emoji-modal-grid-char:active {
  background: rgba(255, 94, 98, 0.2);
  transform: scale(0.9);
}

/* 画像保存モーダルのスタイル */
.save-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.save-modal-content {
  background: #161622;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.save-modal-content h3 {
  font-family: var(--font-title);
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 16px;
  color: var(--text-main);
  text-align: center;
}

.save-modal-content p {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.4;
}

.save-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.save-options .btn {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  height: auto;
}

.save-options .btn span:first-child {
  font-size: 13px;
  font-weight: 600;
}

.fallback-hint {
  font-size: 12px !important;
  color: var(--primary-color) !important;
  font-weight: 600;
  margin-bottom: 8px !important;
}

/* カラーチップ（iOSでの表示崩れ・背景色消滅を防止するリセット） */
.color-chip, .bg-color-chip {
  -webkit-appearance: none !important;
  appearance: none !important;
  box-sizing: border-box !important;
  border-style: solid !important;
  border-width: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none;
  display: inline-block;
  vertical-align: middle;
  transition: transform 0.1s ease, outline 0.1s ease;
}

.color-chip:active, .bg-color-chip:active {
  transform: scale(0.9);
}
