/* =====================================================
   外壁カラーシミュレーター - スタイルシート
   ===================================================== */

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

:root {
  --blue: #1a56db;
  --blue-dark: #1240a8;
  --green: #16a34a;
  --red: #dc2626;
  --gray0: #f8fafc;
  --gray1: #f1f5f9;
  --gray2: #e2e8f0;
  --gray3: #cbd5e1;
  --gray4: #94a3b8;
  --gray5: #64748b;
  --gray6: #334155;
  --gray7: #1e293b;
  --shadow: 0 2px 12px rgba(0,0,0,.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.18);
  --radius: 16px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Noto Sans JP', sans-serif;
  background: #000;
  -webkit-text-size-adjust: 100%;
}

/* ===================== 画面管理 ===================== */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  background: #fff;
  overflow: hidden;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ===================== ホーム画面 ===================== */
.home-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 32px 24px;
  background: linear-gradient(160deg, #e8f0fe 0%, #f0f4ff 50%, #fff 100%);
  gap: 0;
}

.home-logo {
  width: 80px;
  height: 80px;
  background: var(--blue);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(26,86,219,.3);
}
.home-logo i { font-size: 38px; color: #fff; }

.home-title {
  font-size: 28px;
  font-weight: 900;
  color: var(--gray7);
  text-align: center;
  line-height: 1.3;
  margin-bottom: 10px;
}
.home-sub {
  font-size: 15px;
  color: var(--gray5);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 28px;
}

.home-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 340px;
  justify-content: center;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.step-num {
  width: 30px;
  height: 30px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-text { font-size: 11px; color: var(--gray5); font-weight: 500; }
.step-arrow { font-size: 18px; color: var(--gray4); }

.home-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}
.btn-home-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 4px 16px rgba(26,86,219,.35);
}
.btn-home-main i { font-size: 22px; }
.btn-home-main:active { transform: scale(.97); opacity: .9; }
.btn-home-sub {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
  border: 2px solid var(--blue);
}

/* ===================== 共通ヘッダー ===================== */
.paint-header, .done-header {
  display: flex;
  align-items: center;
  height: 52px;
  padding: 0 8px;
  background: var(--blue);
  flex-shrink: 0;
  gap: 4px;
}
.hdr-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 18px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s;
  font-family: inherit;
}
.hdr-btn:active { background: rgba(255,255,255,.2); }
.hdr-btn-text { font-size: 15px; }
.hdr-title {
  flex: 1;
  text-align: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

/* ===================== 色バー ===================== */
.color-bar {
  display: flex;
  align-items: center;
  height: 62px;
  padding: 0 8px;
  background: var(--gray7);
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.color-bar::-webkit-scrollbar { display: none; }

.color-chip {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .15s, border-color .15s;
  position: relative;
}
.color-chip.active {
  border-color: #fff;
  transform: scale(1.2);
  box-shadow: 0 0 0 2px var(--blue);
}
.color-chip:active { transform: scale(1.1); }

.color-more-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px dashed var(--gray4);
  background: transparent;
  color: var(--gray4);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.color-more-btn:active { border-color: #fff; color: #fff; }

/* ===================== キャンバスエリア ===================== */
.canvas-area {
  flex: 1;
  position: relative;
  background: #111;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas-base, #canvas-paint {
  position: absolute;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  display: block;
}
#canvas-paint {
  cursor: crosshair;
  z-index: 2;
}
#canvas-base { z-index: 1; }

.hint-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.hint-box {
  background: rgba(0,0,0,.65);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}
.hint-box i { font-size: 28px; color: #fbbf24; }

/* ===================== ツールバー ===================== */
.paint-toolbar {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 8px;
  gap: 6px;
  background: #fff;
  border-top: 1px solid var(--gray2);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.paint-toolbar::-webkit-scrollbar { display: none; }

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 10px;
  height: 44px;
  border: 1.5px solid var(--gray2);
  border-radius: 10px;
  background: #fff;
  color: var(--gray5);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .15s;
}
.tool-btn i { font-size: 16px; }
.tool-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(26,86,219,.3);
}
.tool-btn:active { opacity: .8; }
.tool-btn-reset {
  color: var(--red);
  border-color: #fecaca;
}
.tool-btn-reset:active { background: #fee2e2; }

.sens-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 100px;
}
.sens-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gray5);
  white-space: nowrap;
}
.sens-slider {
  flex: 1;
  height: 4px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ===================== 塗り絵フッター ===================== */
.paint-footer {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--gray2);
  flex-shrink: 0;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.btn-done-only {
  flex: 1;
  padding: 14px;
  border: 2px solid var(--blue);
  border-radius: var(--radius);
  background: #fff;
  color: var(--blue);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.btn-done-only:active { background: #e8f0fe; }

.btn-done-proposal {
  flex: 1.4;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(26,86,219,.35);
  transition: all .15s;
}
.btn-done-proposal:active { opacity: .85; }

/* ===================== 色選択モーダル ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-sheet {
  background: #fff;
  width: 100%;
  max-width: 540px;
  border-radius: 20px 20px 0 0;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--gray2);
  flex-shrink: 0;
}
.modal-title { flex: 1; font-size: 18px; font-weight: 700; color: var(--gray7); }
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray1);
  border-radius: 50%;
  font-size: 16px;
  color: var(--gray5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-tabs {
  display: flex;
  overflow-x: auto;
  padding: 10px 16px;
  gap: 8px;
  flex-shrink: 0;
  scrollbar-width: none;
}
.modal-tabs::-webkit-scrollbar { display: none; }
.modal-tab {
  padding: 6px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--gray3);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray5);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all .15s;
  flex-shrink: 0;
}
.modal-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.modal-color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  padding: 12px 16px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-color-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform .15s;
}
.modal-color-item:active { transform: scale(.92); }
.modal-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color .15s;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.modal-color-item.active .modal-color-swatch {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26,86,219,.3);
}
.modal-color-code {
  font-size: 10px;
  color: var(--gray5);
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
}

/* ===================== 完成画面 ===================== */
.done-compare {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #111;
}
.done-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
#done-canvas {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

.done-color-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #fff;
  border-top: 1px solid var(--gray2);
  flex-shrink: 0;
}
.done-color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.done-color-texts { flex: 1; }
.done-color-name { font-size: 14px; font-weight: 700; color: var(--gray7); }
.done-color-code { font-size: 12px; color: var(--blue); font-weight: 600; }
.done-maker { font-size: 11px; color: var(--gray4); }

.done-actions {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--gray2);
  flex-shrink: 0;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.btn-done-action {
  flex: 1;
  padding: 12px 6px;
  border: 1.5px solid var(--gray2);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--gray6);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all .15s;
}
.btn-done-action i { font-size: 18px; }
.btn-done-action:active { background: var(--gray1); }
.btn-proposal-go {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 10px rgba(26,86,219,.3);
}
.btn-proposal-go:active { opacity: .85; }

/* ===================== フォーム画面 ===================== */
.form-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--gray1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-section {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray5);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-row label { font-size: 12px; font-weight: 600; color: var(--gray5); }
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--gray2);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--blue); }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--gray3);
  background: #fff;
  color: var(--gray6);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  font-weight: 700;
}
.chip:active { opacity: .8; }

.btn-create-proposal {
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26,86,219,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all .15s;
  width: 100%;
}
.btn-create-proposal:active { opacity: .85; }

/* ===================== 提案書画面 ===================== */
.proposal-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 max(16px, env(safe-area-inset-bottom));
  background: var(--gray1);
}

.proposal-doc {
  background: #fff;
  margin: 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.prop-top {
  background: var(--blue);
  color: #fff;
  padding: 20px 20px 16px;
}
.prop-title { font-size: 20px; font-weight: 900; margin-bottom: 4px; }
.prop-date { font-size: 12px; opacity: .8; }
.prop-body { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }

.prop-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
  border-left: 3px solid var(--blue);
  padding-left: 8px;
  margin-bottom: 8px;
}

.prop-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.prop-info-item { display: flex; flex-direction: column; gap: 2px; }
.prop-info-label { font-size: 11px; color: var(--gray4); font-weight: 600; }
.prop-info-val { font-size: 14px; font-weight: 700; color: var(--gray7); }

.prop-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.prop-img-wrap { position: relative; border-radius: 10px; overflow: hidden; }
.prop-img-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.prop-img-wrap img, .prop-img-wrap canvas {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}

.prop-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--gray1);
  border-radius: 12px;
}
.prop-color-swatch {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.prop-color-info .name { font-size: 15px; font-weight: 700; color: var(--gray7); }
.prop-color-info .code { font-size: 13px; color: var(--blue); font-weight: 600; }
.prop-color-info .maker { font-size: 11px; color: var(--gray4); }

.prop-work-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prop-work-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--gray1);
  border-radius: 10px;
  align-items: flex-start;
}
.prop-work-num {
  width: 22px;
  height: 22px;
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.prop-work-title { font-size: 14px; font-weight: 700; color: var(--gray7); }
.prop-work-desc { font-size: 12px; color: var(--gray5); margin-top: 2px; }

.prop-note {
  font-size: 11px;
  color: var(--gray4);
  line-height: 1.6;
  padding: 10px;
  background: #fffbeb;
  border-radius: 8px;
  border-left: 3px solid #fbbf24;
}

.prop-print-btn {
  margin: 12px;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 3px 14px rgba(22,163,74,.3);
  width: calc(100% - 24px);
}

/* ===================== ローディング ===================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-inner {
  background: #fff;
  border-radius: 20px;
  padding: 28px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-lg);
}
.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--gray2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { font-size: 15px; font-weight: 600; color: var(--gray6); }

/* ===================== トースト ===================== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,41,59,.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: all .25s;
  z-index: 200;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===================== 印刷 ===================== */
@media print {
  body > *:not(#screen-proposal) { display: none !important; }
  #screen-proposal { display: block !important; position: static !important; }
  .done-header { display: none !important; }
  .proposal-scroll { overflow: visible !important; padding: 0 !important; }
  .proposal-doc { margin: 0; border-radius: 0; box-shadow: none; }
}
