/* ===========================
   SandSim - 砂漠ミニマルテーマ
   =========================== */

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

body {
  background: #f5f0e8;
  font-family: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: auto;
}

/* --- メインコンテナ --- */
#app {
  position: relative;
  border: 1px solid #d5cbb8;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(80, 60, 30, 0.1);
}

/* --- ツールバー --- */
.toolbar {
  background: #e2d9ca;
  padding: 10px 14px;
  border-bottom: 1px solid #d5cbb8;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 13px;
  font-weight: 500;
  color: #5a4a35;
  white-space: nowrap;
}

/* --- ボタン --- */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #5a4a35;
  background: #e8dfd0;
  border: 1px solid #d5cbb8;
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(80, 60, 30, 0.12);
}

.btn:hover:not(.btn-disabled) {
  background: #ddd3c2;
  box-shadow: 0 2px 6px rgba(80, 60, 30, 0.18);
}

.btn:active:not(.btn-disabled) {
  transform: translateY(1px);
  box-shadow: 0 0 2px rgba(80, 60, 30, 0.1);
}

.btn-active {
  background: #b8860b;
  color: #fff;
  border-color: #a07608;
  box-shadow: 0 1px 3px rgba(184, 134, 11, 0.3);
}

.btn-active:hover {
  background: #a07608;
}

.btn-disabled {
  opacity: 0.45;
  cursor: default;
}

/* --- セパレータ --- */
.toolbar-separator {
  width: 1px;
  height: 20px;
  background: #d5cbb8;
  margin: 0 4px;
}

/* --- セグメントコントロール --- */
.segment-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.segment-track {
  display: flex;
  background: #d5cbb8;
  border-radius: 6px;
  padding: 2px;
}

.segment-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #5a4a35;
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.segment-btn:hover:not(.segment-active) {
  background: rgba(255, 255, 255, 0.3);
}

.segment-active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(80, 60, 30, 0.15);
  font-weight: 600;
}

/* --- チェックボックス --- */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1px solid #d5cbb8;
  border-radius: 3px;
  background: #e8dfd0;
  cursor: pointer;
  position: relative;
}

.checkbox:checked {
  background: #b8860b;
  border-color: #a07608;
}

.checkbox:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* --- スライダー --- */
.slider-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100px;
  height: 4px;
  border-radius: 2px;
  background: #d5cbb8;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #b8860b;
  cursor: pointer;
  border: 2px solid #f5f0e8;
  box-shadow: 0 1px 3px rgba(80, 60, 30, 0.2);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #b8860b;
  cursor: pointer;
  border: 2px solid #f5f0e8;
  box-shadow: 0 1px 3px rgba(80, 60, 30, 0.2);
}

.slider-value {
  font-size: 12px;
  font-weight: 500;
  color: #9a8b75;
  min-width: 24px;
  text-align: right;
}

/* --- サブツールコンテナ --- */
.sub-tool-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* --- コンテキストパネル --- */
.context-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(90, 74, 53, 0.04);
  border-radius: 4px;
  min-height: 34px;
  flex-wrap: wrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.context-panel.hidden {
  display: none;
}

.context-panel.source-selected {
  border-left: 3px solid rgba(0, 180, 220, 0.7);
  background: rgba(0, 180, 220, 0.05);
  padding-left: 11px;
}

.context-label {
  font-size: 11px;
  font-weight: 600;
  color: rgb(0, 140, 170);
  white-space: nowrap;
  background: rgba(0, 180, 220, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
}

.context-hint {
  font-size: 11px;
  color: #9a8b75;
  font-style: italic;
  white-space: nowrap;
}

/* --- 削除ボタン --- */
.btn-delete {
  background: rgba(180, 60, 40, 0.08);
  color: #b03c28;
  border-color: rgba(180, 60, 40, 0.25);
}

.btn-delete:hover:not(.btn-disabled) {
  background: rgba(180, 60, 40, 0.18);
  border-color: rgba(180, 60, 40, 0.4);
}

/* --- キャンバスコンテナ --- */
.canvas-container {
  position: relative;
  background: #ece5d8;
  cursor: crosshair;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.canvas-container canvas {
  position: absolute;
  top: 0;
  left: 0;
}

/* --- プレビューCanvas --- */
.preview-canvas {
  pointer-events: none;
  z-index: 10;
}


/* ===========================
   ランディングページ
   =========================== */

.landing-body {
  background: linear-gradient(135deg, #f5f0e8 0%, #e8dfd0 50%, #ddd3c2 100%);
  min-height: 100vh;
}

.landing-body #app {
  width: 100%;
  max-width: none;
  border: none;
  box-shadow: none;
  background: transparent;
}

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
}

.landing-title {
  font-size: 2.5rem;
  font-weight: 600;
  color: #5a4a35;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.landing-subtitle {
  font-size: 1rem;
  color: #9a8b75;
  margin-bottom: 48px;
}

.landing-cards {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  justify-content: center;
}

.landing-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 300px;
  padding: 40px 32px;
  border-radius: 16px;
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  background: linear-gradient(145deg, #e8dfd0, #ddd3c2);
  border: 1px solid #d5cbb8;
  box-shadow: 0 4px 20px rgba(80, 60, 30, 0.15);
  color: #5a4a35;
}

.landing-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 32px rgba(184, 134, 11, 0.25);
}

.landing-card h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #5a4a35;
}

.landing-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  text-align: center;
}

.card-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* --- モバイル対応 --- */
@media (max-width: 820px) {
  body {
    align-items: flex-start;
    height: 100dvh;
    overflow: hidden;
  }

  #app {
    width: 100vw;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: #e2d9ca;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .toolbar {
    flex-shrink: 0;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px 10px;
    gap: 6px;
  }

  .canvas-container {
    flex: 1;
    width: 100%;
    overflow: hidden;
  }

  .toolbar-row {
    gap: 4px;
  }

  .btn {
    font-size: 11px;
    padding: 6px 8px;
  }

  .slider {
    width: 70px;
  }

  .toolbar-label {
    font-size: 11px;
  }

  .slider-value {
    font-size: 11px;
  }

  .context-panel {
    padding: 4px 10px;
    gap: 4px;
  }

  .sub-tool-container {
    gap: 2px;
  }

  .landing {
    padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)) 16px;
  }

  .landing-title {
    font-size: 1.8rem;
  }

  .landing-cards {
    gap: 20px;
  }

  .landing-card {
    width: 100%;
    max-width: 320px;
    padding: 28px 24px;
  }

  .landing-body #app {
    height: auto;
    display: block;
    background: transparent;
  }

  .landing-body {
    overflow: auto;
  }
}
