/* ============================================================
   Generative Canvas - Modern Dark & Glassmorphism Styling
   ============================================================ */

:root {
  --bg-main: #0c0f17;
  --bg-surface: rgba(22, 27, 40, 0.75);
  --bg-surface-hover: rgba(30, 38, 56, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-active: rgba(0, 229, 255, 0.5);

  --text-main: #f0f4f8;
  --text-muted: #8e9bb0;
  --text-dim: #5c687e;

  --accent-cyan: #00e5ff;
  --accent-purple: #b388ff;
  --accent-glow: rgba(0, 229, 255, 0.35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --transition-fast: 0.18s ease;
  --shadow-elevation: 0 12px 36px rgba(0, 0, 0, 0.55);
}

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

body {
  font-family: 'Inter', 'Zen Kaku Gothic New', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(124, 77, 255, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(0, 229, 255, 0.10) 0%, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* --- Layout --- */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px 24px;
  gap: 18px;
}

/* --- Header --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  color: var(--accent-cyan);
  -webkit-text-fill-color: initial;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

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

/* --- Main Workspace (Grid layout) --- */
.main-workspace {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  flex: 1;
  align-items: start;
}

@media (max-width: 1024px) {
  .main-workspace {
    grid-template-columns: 1fr;
  }
}

/* --- Canvas Section --- */
.canvas-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.canvas-container {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 75vh;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-elevation);
  border: 1px solid var(--border-subtle);
  display: flex;
  justify-content: center;
  align-items: center;
}

.canvas-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-playback-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ランダム再生成ボタンの強調スタイル (ガチャ感・コズミックネオングロー) */
.btn-reseed-highlight {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.4) 0%, rgba(236, 72, 153, 0.45) 50%, rgba(0, 229, 255, 0.35) 100%) !important;
  border: 1px solid rgba(236, 72, 153, 0.7) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.35), inset 0 0 8px rgba(255, 255, 255, 0.15) !important;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  transition: all var(--transition-fast) !important;
}

.btn-reseed-highlight:hover {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.6) 0%, rgba(236, 72, 153, 0.75) 50%, rgba(0, 229, 255, 0.6) 100%) !important;
  border-color: rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 0 22px rgba(236, 72, 153, 0.6), 0 0 12px rgba(0, 229, 255, 0.5) !important;
  transform: translateY(-1px) scale(1.02);
}

.btn-reseed-highlight:active {
  transform: translateY(1px) scale(0.99);
}

/* 宇宙を持ち帰る (エクスポートブロック) */
.toolbar-export-group {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(18, 24, 38, 0.65);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: var(--radius-md);
  padding: 4px 8px 4px 12px;
  box-shadow: inset 0 0 12px rgba(0, 229, 255, 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.toolbar-group-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.04em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.toolbar-group-label::before {
  content: "🚀";
  font-size: 0.82rem;
}

.toolbar-export-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 640px) {
  .canvas-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-playback-group,
  .toolbar-export-group {
    justify-content: space-between;
    width: 100%;
  }
}

/* --- Control Sidebar --- */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Panel Tabs Navigation --- */
.panel-tabs {
  display: flex;
  gap: 6px;
  background: rgba(14, 18, 28, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 5px;
}

.panel-tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

.panel-tab-btn .tab-icon {
  font-size: 0.95rem;
  line-height: 1;
}

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

.panel-tab-btn.active {
  color: #ffffff;
  background: rgba(0, 229, 255, 0.14);
  border-color: rgba(0, 229, 255, 0.4);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.tab-content {
  display: none !important;
}

.tab-content.active {
  display: flex !important;
  animation: fadeInTab 0.18s ease forwards;
}

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

/* --- Parameter Subtabs (線 / 点 / 全体) --- */
.subtabs-bar {
  display: flex;
  gap: 4px;
  background: rgba(10, 14, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 4px;
}

.subtab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.subtab-btn .subtab-icon {
  font-size: 0.82rem;
  line-height: 1;
}

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

.subtab-btn.active {
  color: #ffffff;
  background: rgba(0, 229, 255, 0.16);
  border-color: rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

.subtab-content {
  display: none !important;
}

.subtab-content.active {
  display: block !important;
  animation: fadeInSubTab 0.15s ease forwards;
}

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

.panel-card {
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-cyan);
}

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

.section-sublabel {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* --- Layer Selector & Manager --- */
.layer-depth-hint {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 6px;
  text-align: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

.layer-depth-hint.depth-top {
  color: var(--accent-cyan);
  border-color: rgba(0, 229, 255, 0.25);
}

.layer-depth-hint.depth-bottom {
  color: var(--accent-purple);
  border-color: rgba(179, 136, 255, 0.25);
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 2px;
}

.layer-list::-webkit-scrollbar {
  width: 4px;
}
.layer-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
.layer-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.layer-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  font-weight: 500;
  transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  user-select: none;
  position: relative;
}

.layer-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.layer-item.active {
  background: rgba(0, 229, 255, 0.06);
  border-color: rgba(0, 229, 255, 0.35);
  color: var(--text-main);
}

.layer-item.focused {
  background: rgba(179, 136, 255, 0.15) !important;
  border-color: var(--accent-purple) !important;
  box-shadow: 0 0 10px rgba(179, 136, 255, 0.3);
  color: #ffffff;
}

.layer-item.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent-purple) !important;
  transform: scale(0.98);
  background: rgba(179, 136, 255, 0.1);
}

.layer-item.drag-over-top {
  border-top: 2px solid var(--accent-cyan) !important;
}

.layer-item.drag-over-bottom {
  border-bottom: 2px solid var(--accent-cyan) !important;
}

.drag-handle {
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: grab;
  padding: 0 2px;
  display: inline-flex;
  align-items: center;
  transition: color var(--transition-fast);
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle:hover {
  color: var(--accent-cyan);
}

.layer-num {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-cyan);
  font-family: monospace;
}

.layer-item.focused .layer-num {
  color: #ffffff;
}

.layer-emoji {
  font-size: 0.95rem;
  line-height: 1;
}

.layer-title {
  font-size: 0.74rem;
  font-weight: 600;
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-pal-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.layer-item:hover .layer-pal-dot {
  transform: scale(1.15);
}

.layer-order-btns {
  display: inline-flex;
  gap: 2px;
  opacity: 0.45;
  transition: opacity var(--transition-fast);
}

.layer-item:hover .layer-order-btns {
  opacity: 0.9;
}

.btn-order-move {
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 1px 3px;
  font-size: 0.6rem;
  border-radius: 3px;
  cursor: pointer;
  line-height: 1;
  transition: all var(--transition-fast);
}

.btn-order-move:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
  border-color: rgba(0, 229, 255, 0.3);
}

.layer-toggle-btn {
  font-size: 0.75rem;
  opacity: 0.35;
  padding: 2px 4px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.layer-item.active .layer-toggle-btn {
  opacity: 0.95;
}

.layer-toggle-btn:hover {
  opacity: 1.0;
  transform: scale(1.15);
}

/* 編集中のレイヤー名インジケーター */
.current-layer-indicator {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-purple);
  background: rgba(179, 136, 255, 0.12);
  padding: 3px 8px;
  border-radius: 12px;
  border: 1px solid rgba(179, 136, 255, 0.3);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.current-layer-indicator:hover {
  background: rgba(179, 136, 255, 0.25);
  border-color: var(--accent-purple);
}

.indicator-tag {
  color: var(--accent-cyan);
}

/* レイヤー操作ツールバー (Soloプレビュー / 単体再生成) */
.layer-action-bar {
  display: flex;
  gap: 8px;
  margin: 10px 0 12px 0;
  align-items: center;
}

.btn-solo-toggle {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn-solo-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-solo-toggle.active {
  background: rgba(0, 229, 255, 0.16);
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.45);
}

.btn-reseed-layer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(179, 136, 255, 0.35);
  background: rgba(179, 136, 255, 0.09);
  color: var(--accent-purple);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-reseed-layer:hover {
  background: rgba(179, 136, 255, 0.2);
  border-color: var(--accent-purple);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(179, 136, 255, 0.4);
  transform: translateY(-1px);
}

.reseed-icon {
  display: inline-block;
  transition: transform var(--transition-fast);
}

.btn-reseed-layer:active .reseed-icon {
  transform: rotate(180deg);
}
/* --- Advanced Params Accordion --- */
.advanced-params {
  margin-top: 6px;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 8px;
}

.advanced-summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-purple);
  padding: 6px 0;
  user-select: none;
  transition: color var(--transition-fast);
}

.advanced-summary:hover {
  color: var(--accent-cyan);
}

.advanced-sliders {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

/* 原点位置コントロールグループ */
.origin-control-group {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.slider-title-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 500;
}

.btn-reset-origin {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 0.68rem;
  padding: 2px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn-reset-origin:hover {
  background: rgba(0, 229, 255, 0.12);
  color: var(--accent-cyan);
  border-color: rgba(0, 229, 255, 0.35);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.25);
}


/* --- Sliders --- */
.sliders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.slider-title {
  color: var(--text-muted);
}

.slider-val {
  font-weight: 600;
  color: var(--accent-cyan);
  font-family: monospace;
}

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

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-glow);
  transition: transform var(--transition-fast);
}

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

/* --- Palette Controls --- */
.palette-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.palette-name-badge {
  font-size: 0.75rem;
  color: var(--accent-purple);
  font-weight: 500;
}

.palette-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.palette-preview {
  display: flex;
  gap: 4px;
  align-items: center;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: inline-block;
}

.palette-select {
  flex: 1;
  padding: 8px 10px;
  background: rgba(10, 13, 20, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
}

.btn-apply-palette-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 229, 255, 0.35);
  background: rgba(0, 229, 255, 0.08);
  color: var(--accent-cyan);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn-apply-palette-all:hover {
  background: rgba(0, 229, 255, 0.18);
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
  transform: translateY(-1px);
}

.btn-apply-palette-all.success {
  background: rgba(0, 230, 118, 0.2);
  border-color: #00e676;
  color: #00e676;
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.4);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, #00e5ff 0%, #0099ff 100%);
  color: #05101a;
  box-shadow: 0 4px 14px rgba(0, 229, 255, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.45);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

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

.btn-tool {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 8px 14px;
  font-size: 0.82rem;
}

.btn-tool:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-secondary {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.22) 0%, rgba(179, 136, 255, 0.25) 100%);
  border: 1px solid rgba(0, 229, 255, 0.45);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(179, 136, 255, 0.2);
}

.btn-secondary:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.4);
  border-color: var(--accent-cyan);
}

.btn-full {
  width: 100%;
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-text:hover {
  text-decoration: underline;
}

.btn.copied {
  background: #00e676 !important;
  color: #000 !important;
}

/* --- Modal Overlay & Dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(4, 7, 13, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: #0d121f;
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 25px rgba(0, 229, 255, 0.15);
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: modalEnter 0.22s ease-out;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
}

.modal-title {
  font-size: 1.0rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.radio-pill-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.radio-pill {
  cursor: pointer;
  user-select: none;
}

.radio-pill input[type="radio"] {
  display: none;
}

.radio-pill span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  font-size: 0.73rem;
  font-weight: 500;
  text-align: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  transition: all var(--transition-fast);
}

.radio-pill:hover span {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.radio-pill input[type="radio"]:checked + span {
  background: rgba(0, 229, 255, 0.14);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
  font-weight: 600;
}

.modal-hint {
  font-size: 0.73rem;
  color: var(--text-dim);
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.025);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--accent-cyan);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* --- Progress Bar --- */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 0 6px;
}

.progress-bar-wrapper {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 10px;
  transition: width 0.12s ease-out;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.progress-status-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
}

.progress-status-text {
  color: var(--accent-cyan);
  font-weight: 600;
}

.progress-count-text {
  color: var(--text-dim);
  font-family: monospace;
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 12px;
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.app-footer a:hover {
  color: var(--accent-cyan);
}

/* ============================================================
   Onboarding Guide (インタラクティブ吹き出しガイドツアー)
   ============================================================ */
.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  pointer-events: auto;
  transition: opacity 0.25s ease;
}

.guide-overlay.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* スポットライト（対象要素を浮き上がらせる枠＆暗転マスク） */
.guide-spotlight {
  position: fixed;
  border-radius: 8px;
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 0 9999px rgba(3, 7, 18, 0.72), 0 0 22px rgba(0, 229, 255, 0.45);
  pointer-events: none;
  transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9991;
}

/* コズミック調フロストガラス吹き出しカード */
.guide-popover {
  position: fixed;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: rgba(10, 15, 28, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75), 0 0 30px rgba(0, 229, 255, 0.2);
  padding: 16px;
  z-index: 9995;
  transition: top 0.24s cubic-bezier(0.16, 1, 0.3, 1), left 0.24s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  animation: popoverFadeIn 0.22s ease-out;
}

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

/* 吹き出しの矢印 */
.guide-arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: rgba(10, 15, 28, 0.94);
  border: 1px solid rgba(0, 229, 255, 0.35);
  transform: rotate(45deg);
  z-index: 9996;
}

/* 矢印の位置バリエーション */
.guide-arrow.placement-left {
  right: -7px;
  border-left: none;
  border-bottom: none;
}

.guide-arrow.placement-top {
  bottom: -7px;
  border-top: none;
  border-left: none;
}

.guide-arrow.placement-bottom {
  top: -7px;
  border-bottom: none;
  border-right: none;
}

/* 吹き出しヘッダー */
.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.guide-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.12);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(0, 229, 255, 0.25);
  letter-spacing: 0.5px;
}

.guide-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.guide-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* 吹き出し本文 */
.guide-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-desc {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* 吹き出しフッター */
.guide-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}

.guide-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.guide-dots {
  display: flex;
  gap: 6px;
}

.guide-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: all var(--transition-fast);
}

.guide-dot.active {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
  transform: scale(1.25);
}

.guide-btn-skip {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.73rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: all var(--transition-fast);
}

.guide-btn-skip:hover {
  color: #ff6b81;
  text-decoration-color: #ff6b81;
}

.guide-actions {
  display: flex;
  gap: 8px;
}

.guide-actions .btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
}

/* ヘッダーのガイドボタン用スタイル */
.btn-guide-trigger {
  border-color: rgba(0, 229, 255, 0.35);
  color: var(--accent-cyan);
}

.btn-guide-trigger:hover {
  background: rgba(0, 229, 255, 0.14);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
}
