/* ============================================================
   Compass — 気持ちインサイト
   compass.css  (レスポンシブ対応: スマホ / タブレット / PC)
   ============================================================ */

:root {
  --bg: #fcf9fb;
  --bg-mesh1: rgba(255, 154, 158, 0.3);
  --bg-mesh2: rgba(176, 136, 249, 0.25);
  --bg-mesh3: rgba(254, 207, 239, 0.4);

  --surface: rgba(255, 255, 255, 0.7);
  --surface2: rgba(255, 255, 255, 0.85);
  --surface3: #ffffff;
  --border: rgba(255, 255, 255, 1);
  --border2: rgba(240, 230, 240, 0.8);

  --text: #4a454d;
  --text2: #7a737d;
  --text3: #a49ea8;

  --accent: #ff6b8b;
  --accent2: #6eb5ff;
  --accent3: #a78bfa;
  --warn: #ffa94d;
  --green: #4ade80;

  --shadow-sm: 0 4px 12px rgba(255, 107, 139, 0.04);
  --shadow-md: 0 8px 32px rgba(176, 136, 249, 0.08);
  --shadow-inner: inset 0 2px 4px rgba(255, 255, 255, 0.8);

  --radius-sm: 16px;
  --radius: 20px;
  --radius-lg: 28px;
  --radius-xl: 36px;

  --font: 'M PLUS Rounded 1c', -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* レイアウト */
  --content-max: 520px;
  --col-gap: 28px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100svh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% 10%, var(--bg-mesh1) 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 80% 80%, var(--bg-mesh2) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 60% 20%, var(--bg-mesh3) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
  filter: blur(40px);
}

main { position: relative; z-index: 1; }

/* ── Header ── */
header {
  padding: calc(var(--safe-top) + 16px) 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--content-max);
  margin: 0 auto;
}

.logo-mark { display: flex; align-items: center; gap: 12px; }

.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 154, 158, 0.4), var(--shadow-inner);
  flex-shrink: 0;
}
.logo-icon svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; }

.logo-text h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; }
.logo-text p { font-size: 11px; color: var(--text2); font-weight: 500; }

.header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

.btn-icon {
  height: 40px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.btn-icon:active { transform: scale(0.9); box-shadow: none; }
.btn-icon svg { width: 18px; height: 18px; stroke: var(--text2); fill: none; stroke-width: 2; }

/* PC/タブレット切り替えボタン */
#btn-view-toggle {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  color: var(--text2);
  gap: 5px;
  width: auto;
  padding: 0 12px;
  white-space: nowrap;
}
#btn-view-toggle svg { width: 14px; height: 14px; }

/* 設定ボタン */
#btn-settings {
  width: 40px;
  padding: 0;
  border-radius: 50%;
  justify-content: center;
}

.badge-on {
  position: absolute; top: 0; right: 0;
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

/* ── Banner ── */
.banner {
  padding: 12px 14px;
  background: linear-gradient(to right, rgba(255,107,139,0.08), rgba(176,136,249,0.08));
  border: 2px solid #fff;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
.banner svg { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; stroke: var(--accent); fill: none; stroke-width: 2; }
.banner p { font-size: 12px; color: var(--text2); line-height: 1.5; font-weight: 500; }
.banner strong { color: var(--accent); font-weight: 700; }

/* ── Segment (3tabs) ── */
.segment-wrap {
  background: rgba(240,235,240,0.6);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 22px;
  padding: 5px;
  display: flex;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.03);
}
.seg-btn {
  flex: 1;
  padding: 11px 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 17px;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
}
.seg-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; flex-shrink: 0; }
.seg-btn.active { background: var(--surface3); color: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,0.06), var(--shadow-inner); }

/* ── 新しい相談バー ── */
.new-consult-bar {
  position: sticky;
  top: 8px;
  z-index: 10;
}
.btn-new-consult {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 20px rgba(255,154,158,0.4), inset 0 -3px 0 rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}
.btn-new-consult::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.4), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.btn-new-consult:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(255,154,158,0.5); }
.btn-new-consult:active { transform: scale(0.96); box-shadow: 0 4px 12px rgba(255,154,158,0.4); }
.btn-new-consult svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2.5; position: relative; z-index: 2; }
.btn-new-consult span { position: relative; z-index: 2; }

/* ── Glass Card ── */
.glass-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(30px) saturate(1.5);
  -webkit-backdrop-filter: blur(30px) saturate(1.5);
  box-shadow: var(--shadow-md);
}

.card-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-label-num {
  width: 22px; height: 22px;
  background: linear-gradient(135deg, #fecfef 0%, #ff9a9e 100%);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px rgba(255,154,158,0.4);
  flex-shrink: 0;
}

/* ── Chip Grid ── */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.chip {
  padding: 14px 10px;
  background: rgba(255,255,255,0.5);
  border: 2px solid #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
  line-height: 1.3;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}
.chip:active { transform: scale(0.94); }
.chip.selected { background: #fff0f3; border-color: #ffb3c6; color: var(--accent); box-shadow: 0 4px 12px rgba(255,107,139,0.15); }
.chip.selected-purple { background: #f3f0ff; border-color: #d8b4fe; color: var(--accent3); box-shadow: 0 4px 12px rgba(167,139,250,0.15); }

/* ── Range Slider ── */
.range-wrap { margin-top: 4px; }
.range-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--text3); font-weight: 600; margin-bottom: 6px; }

/* 4段階ラベル */
.range-labels-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  font-size: 10px;
  color: var(--text3);
  font-weight: 600;
  margin-bottom: 6px;
  text-align: center;
  gap: 2px;
}
.range-labels-4 span:first-child { text-align: left; }
.range-labels-4 span:last-child { text-align: right; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 6px;
  border-radius: 999px;
  background: rgba(0,0,0,0.06);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9a9e, #fecfef);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(255,154,158,0.4);
  cursor: pointer;
  transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.2); }
.range-val {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 6px;
}

/* ── Number Input ── */
.number-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.number-label { font-size: 13px; color: var(--text2); font-weight: 600; flex: 1; }

/* ── Textarea ── */
.char-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.char-count { font-size: 12px; color: var(--text3); font-weight: 600; flex-shrink: 0; }
.hint { font-size: 12px; color: var(--text2); font-weight: 500; line-height: 1.5; }

textarea {
  width: 100%;
  background: rgba(255,255,255,0.8);
  border: 2px solid #fff;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.6;
  transition: all 0.2s;
  font-weight: 500;
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.02);
}
textarea::placeholder { color: var(--text3); }
textarea:focus {
  border-color: #ffb3c6;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255,107,139,0.1), inset 0 2px 5px rgba(0,0,0,0.01);
}

/* ── Submit Button ── */
.btn-submit-wrap { margin-top: 12px; }
.btn-submit {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font);
  color: #fff;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 10px 24px rgba(255,154,158,0.4), inset 0 -3px 0 rgba(0,0,0,0.1);
  position: relative;
  overflow: hidden;
}
.btn-submit::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.4), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(255,154,158,0.5), inset 0 -3px 0 rgba(0,0,0,0.1); }
.btn-submit:active { transform: scale(0.96) translateY(0); box-shadow: 0 4px 12px rgba(255,154,158,0.4); }
.btn-submit svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2.5; position: relative; z-index: 2; }
.btn-submit span { position: relative; z-index: 2; }

/* ── Loading ── */
.loading-panel {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 24px;
  text-align: center;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-md);
}
.loading-ring { width: 64px; height: 64px; margin: 0 auto 24px; }
.loading-ring svg { width: 64px; height: 64px; animation: spin 1.5s cubic-bezier(0.4,0,0.2,1) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-ring-track { stroke: rgba(255,154,158,0.2); }
.loading-ring-fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 140; stroke-dashoffset: 40; }
.loading-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.loading-model { font-size: 13px; color: var(--text3); font-weight: 600; margin-bottom: 20px; }
.loading-sub { font-size: 14px; color: var(--accent); font-weight: 600; background: #fff0f3; display: inline-block; padding: 6px 16px; border-radius: 20px; }

/* ── Result ── */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.result-tag {
  font-size: 12px;
  color: var(--accent3);
  font-weight: 700;
  letter-spacing: 0.5px;
  background: #f3f0ff;
  padding: 4px 12px;
  border-radius: 12px;
}
.btn-copy-sm {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}
.btn-copy-sm:active { transform: scale(0.92); }
.btn-copy-sm svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Score Card */
.score-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 16px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.score-card::before {
  content: '';
  position: absolute;
  top: -50px; left: 50%;
  transform: translateX(-50%);
  width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,154,158,0.2) 0%, transparent 70%);
  pointer-events: none;
}
.score-label { font-size: 12px; color: var(--text2); font-weight: 700; margin-bottom: 16px; }
.score-num {
  font-size: 72px;
  font-weight: 700;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 12px;
  transition: color 0.4s;
}
.score-track {
  height: 8px;
  background: rgba(0,0,0,0.04);
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.05);
}
.score-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 1.2s cubic-bezier(0.34,1.56,0.64,1);
  background: var(--accent);
}
.score-badge { font-size: 14px; font-weight: 700; }

/* Detail Cards */
.detail-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 12px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-sm);
}
.detail-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.detail-card-header > span,
.detail-card-header > div:not(.detail-icon) {
  flex: 1;
  min-width: 0;
}
.btn-copy-card-sm {
  background: transparent;
  border: none;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text3);
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
  flex-shrink: 0;
}
.btn-copy-card-sm:hover {
  background: rgba(255, 107, 139, 0.08);
  color: var(--accent);
}
.btn-copy-card-sm:active {
  transform: scale(0.9);
}
.btn-copy-card-sm svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.btn-copy-card-sm.copied {
  color: var(--green);
}
.detail-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.detail-icon.pink { background: #fff0f3; }
.detail-icon.pink svg { stroke: var(--accent); }
.detail-icon.purple { background: #f3f0ff; }
.detail-icon.purple svg { stroke: var(--accent3); }
.detail-icon.blue { background: #e0f2fe; }
.detail-icon.blue svg { stroke: var(--accent2); }
.detail-icon.green { background: #dcfce7; }
.detail-icon.green svg { stroke: var(--green); }
.detail-icon svg { width: 16px; height: 16px; fill: none; stroke-width: 2; }
.detail-card-title { font-size: 14px; font-weight: 700; }
.detail-card-body { font-size: 14px; color: var(--text2); line-height: 1.8; font-weight: 500; }

/* ── Radar Chart Card ── */
.radar-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  margin-bottom: 12px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-md);
}
.radar-canvas-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.radar-canvas-wrap canvas { max-width: 100%; }

.radar-metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.radar-metric { text-align: center; }
.radar-metric-val { font-size: 18px; font-weight: 700; color: var(--accent); line-height: 1.2; }
.radar-metric-name { font-size: 10px; color: var(--text3); font-weight: 600; margin-top: 2px; line-height: 1.2; }
.radar-interpretation {
  background: linear-gradient(135deg, rgba(255,107,139,0.06), rgba(167,139,250,0.06));
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
  font-weight: 500;
  margin-top: 12px;
}

/* ── Matrix Card ── */
.matrix-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  margin-bottom: 12px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-md);
}
.matrix-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}
.matrix-canvas-wrap canvas { width: 100% !important; height: auto !important; }
.matrix-pos-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text2);
  text-align: center;
  margin-top: 8px;
}

/* ── Language Analysis Card ── */
.lang-analysis {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  margin-bottom: 12px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-md);
}
.lang-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.lang-metric-item {
  background: rgba(255,255,255,0.5);
  border: 1.5px solid rgba(255,255,255,0.8);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
}
.lang-metric-val { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.lang-metric-label { font-size: 11px; color: var(--text2); font-weight: 600; line-height: 1.3; }
.lang-bar-item { margin-bottom: 12px; }
.lang-bar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lang-bar-name { font-size: 12px; font-weight: 700; color: var(--text); }
.lang-bar-num { font-size: 12px; font-weight: 700; color: var(--accent); }
.lang-bar-track { height: 8px; background: rgba(0,0,0,0.05); border-radius: 999px; overflow: hidden; }
.lang-bar-fill { height: 100%; border-radius: 999px; transition: width 1.4s cubic-bezier(0.34,1.56,0.64,1); }

/* ── Approach Card ── */
.approach-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 20px;
  margin-bottom: 12px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-md);
}
.approach-item {
  background: rgba(255,255,255,0.5);
  border: 1.5px solid rgba(255,255,255,0.8);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.approach-item:last-child { margin-bottom: 0; }
.approach-law {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent3);
  background: #f3f0ff;
  padding: 3px 10px;
  border-radius: 999px;
  display: inline-block;
  margin-bottom: 8px;
}
.approach-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.approach-body { font-size: 13px; color: var(--text2); line-height: 1.7; font-weight: 500; }
.approach-example {
  margin-top: 10px;
  background: rgba(255,107,139,0.05);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text2);
  font-weight: 500;
  font-style: italic;
}

.model-line { font-size: 12px; color: var(--text3); text-align: right; margin: 12px 0 20px; font-weight: 600; }

/* ── History ── */
.history-section {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: var(--shadow-md);
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 2px solid #fff;
}
.history-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.history-title svg { width: 16px; height: 16px; stroke: var(--text2); fill: none; stroke-width: 2; }
.btn-clear { font-size: 12px; color: var(--text3); background: none; border: none; font-family: var(--font); cursor: pointer; font-weight: 600; transition: color 0.2s; }
.btn-clear:hover { color: var(--warn); }
.history-empty { padding: 32px 20px; text-align: center; font-size: 13px; color: var(--text3); font-weight: 600; line-height: 1.8; }
.history-item { padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.5); cursor: pointer; transition: background 0.2s; }
.history-item:last-child { border-bottom: none; }
.history-item:active { background: rgba(255,255,255,0.8); }
.history-item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.history-meta { font-size: 12px; color: var(--text3); font-weight: 600; }
.history-score-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.history-score-high { background: #fff0f3; color: var(--accent); }
.history-score-mid { background: #f3f0ff; color: var(--accent3); }
.history-score-low { background: #e0f2fe; color: var(--accent2); }
.history-text { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.history-input-preview {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  font-style: italic;
}
.history-model { font-size: 11px; color: var(--text3); margin-top: 6px; font-weight: 600; }

/* 履歴タブのパネル */
.history-panel-card {
  padding: 0;
  overflow: hidden;
}
.history-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 2px solid rgba(255,255,255,0.7);
}
.history-panel-title { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; color: var(--text); }
.history-panel-title svg { width: 16px; height: 16px; stroke: var(--text2); fill: none; stroke-width: 2; }
#history-list-main .history-empty { padding: 40px 20px; }
#history-list-main .history-item { border-bottom: 1px solid rgba(255,255,255,0.5); }
#history-list-main .history-item:last-child { border-bottom: none; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(255,245,250,0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: flex-end;
  padding: 0 0 var(--safe-bottom);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  width: 100%;
  background: #fff;
  border-radius: 32px 32px 0 0;
  padding: 24px 24px 32px;
  transform: translateY(100%);
  transition: transform 0.45s cubic-bezier(0.16,1,0.3,1);
  box-shadow: 0 -10px 40px rgba(176,136,249,0.15);
  max-width: 480px;
  margin: 0 auto;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle { width: 48px; height: 5px; background: #e5e0e5; border-radius: 3px; margin: 0 auto 24px; }
.modal-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.modal-sub { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 24px; font-weight: 500; }
.field-label { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.key-row { display: flex; gap: 10px; margin-bottom: 10px; }

input[type="password"], input[type="text"], select {
  background: #faf8f9;
  border: 2px solid #eee8ec;
  border-radius: 14px;
  padding: 16px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: all 0.2s;
  font-weight: 500;
  width: 100%;
}
input:focus, select:focus { border-color: #ffb3c6; background: #fff; box-shadow: 0 0 0 4px rgba(255,107,139,0.1); }
select { appearance: none; }

.btn-verify {
  padding: 0 16px;
  background: #fff0f3;
  border: none;
  border-radius: 14px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-weight: 700;
  flex-shrink: 0;
}
.btn-verify:active { transform: scale(0.94); }
.verify-msg { font-size: 12px; color: var(--text3); margin-bottom: 16px; line-height: 1.5; font-weight: 600; }
.verify-msg.ok { color: var(--green); }
.verify-msg.err { color: var(--warn); }
.modal-field { margin-bottom: 20px; }

.btn-save {
  width: 100%;
  padding: 18px;
  background: #f3f0ff;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-family: var(--font);
  color: var(--accent3);
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s cubic-bezier(0.34,1.56,0.64,1);
  margin-top: 8px;
}
.btn-save:active { transform: scale(0.96); background: #e9e4ff; }

.link-small { display: block; text-align: center; font-size: 13px; color: #a78bfa; margin-top: 16px; text-decoration: none; font-weight: 600; }
.link-small:hover { text-decoration: underline; }

/* ── Utilities ── */
.hidden { display: none !important; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.5s cubic-bezier(0.34,1.56,0.64,1) both; }

/* ──────────────────────────────────────────
   モバイル（デフォルト）
   ────────────────────────────────────────── */
.page-wrap {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 16px;
  padding-bottom: calc(32px + var(--safe-bottom));
}

/* セクション間マージン */
.section-gap { margin-bottom: 16px; }

/* モバイルでは pc-right を pc-left の直後に流す */
#pc-layout {
  display: flex;
  flex-direction: column;
}
.pc-left, .pc-right { width: 100%; }

/* ──────────────────────────────────────────
   PC表示（view-desktop クラス時）
   ────────────────────────────────────────── */
body.view-desktop header {
  max-width: 100%;
  padding: 24px 40px 16px;
}

body.view-desktop .page-wrap {
  max-width: 100%;
  padding: 0 40px 48px;
}

body.view-desktop .banner {
  max-width: none;
}

body.view-desktop .segment-wrap {
  max-width: 480px;
}

body.view-desktop #pc-layout {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--col-gap);
  align-items: start;
}

body.view-desktop .pc-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 24px;
}

body.view-desktop .pc-right {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* PC: チップグリッドを3列に */
body.view-desktop #rel-group {
  grid-template-columns: repeat(2, 1fr);
}

/* PC: scene-group は3列 */
body.view-desktop #scene-group {
  grid-template-columns: repeat(3, 1fr);
}

/* PC: スコア数値を少しコンパクト */
body.view-desktop .score-num { font-size: 64px; }

/* PC: ローディング */
body.view-desktop .loading-wrap { width: 100%; }
body.view-desktop #result-panel { margin: 0; }
body.view-desktop #loading-panel { margin: 0; }

/* PC: モーダル中央表示 */
body.view-desktop .modal-overlay {
  align-items: center;
  padding: 24px;
}
body.view-desktop .modal-sheet {
  border-radius: 32px;
  transform: translateY(30px);
}
body.view-desktop .modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

/* ──────────────────────────────────────────
   タブレット自動PC化（768px〜）
   ────────────────────────────────────────── */
@media (min-width: 900px) {
  body:not(.view-mobile) #pc-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--col-gap);
    align-items: start;
  }
  body:not(.view-mobile) .pc-left {
    min-width: 0;
    position: sticky;
    top: 24px;
  }
  body:not(.view-mobile) .pc-right {
    min-width: 0;
  }
}

/* ── 入力内容サマリーカード ── */
.input-summary-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border2);
  padding-bottom: 12px;
}

.summary-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  color: #fff;
}

.summary-type-badge.line-type {
  background: linear-gradient(135deg, #ff9a9e 0%, #ff6b8b 100%);
  box-shadow: 0 2px 8px rgba(255,107,139,0.25);
}

.summary-type-badge.sit-type {
  background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
  box-shadow: 0 2px 8px rgba(167,139,250,0.25);
}

.summary-date {
  font-size: 12px;
  color: var(--text3);
  font-weight: 600;
}

.summary-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.summary-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.6);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}

.summary-item-label {
  font-size: 12px;
  color: var(--text3);
  font-weight: 700;
}

.summary-item-val {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
}

.summary-section.text-section {
  background: rgba(255,255,255,0.5);
  border: 1px solid var(--border2);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  gap: 8px;
}

.summary-text-label {
  font-size: 11px;
  color: var(--text3);
  font-weight: 700;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.summary-text-val, .summary-text-val-extra {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  font-weight: 500;
  white-space: pre-wrap;
  word-break: break-all;
}