/* ==========================================================================
   FurimaPostCalc - プロトコル第18条準拠デザインシステム
   標準トークン: #09090b背景, #121215カード, #27272aボーダー, フォントは OS 標準（Inter 等があれば優先）
   ========================================================================== */

:root {
  --bg-base: #09090b;
  --bg-card: #121215;
  --bg-card-hover: #18181b;
  --bg-input: #18181b;
  --bg-header: rgba(9, 9, 11, 0.85);
  --border-color: #27272a;
  --border-focus: #3b82f6;

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent-emerald: #10b981;
  --accent-emerald-bg: rgba(16, 185, 129, 0.12);
  --accent-blue: #3b82f6;
  --accent-blue-bg: rgba(59, 130, 246, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);
  --accent-rose: #ef4444;
  --accent-rose-bg: rgba(239, 68, 68, 0.12);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", Meiryo, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.2);
}

[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #ffffff;
  --bg-header: rgba(248, 250, 252, 0.85);
  --border-color: #e2e8f0;
  --border-focus: #2563eb;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-emerald-bg: rgba(16, 185, 129, 0.08);
  --accent-blue-bg: rgba(59, 130, 246, 0.08);
  --accent-amber-bg: rgba(245, 158, 11, 0.08);
  --accent-rose-bg: rgba(239, 68, 68, 0.08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 15px rgba(16, 185, 129, 0.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--bg-base); color: var(--text-primary);
  font-family: var(--font-sans); line-height: 1.5; min-height: 100vh;
  transition: background-color 0.2s, color 0.2s;
}

header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-header); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0.85rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
}
.brand-title { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.brand-badge {
  font-family: var(--font-mono); font-size: 0.75rem; background: var(--accent-blue-bg);
  color: var(--accent-blue); border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 0.2rem 0.5rem; border-radius: var(--radius-sm);
}
.header-actions { display: flex; align-items: center; gap: 0.75rem; }

/* スマホ幅（〜600px）では、バッジと共有ボタンが潰れるため折り返す (F-06) */
@media (max-width: 600px) {
  .header-inner { flex-wrap: wrap; row-gap: 0.5rem; padding: 0.65rem 1rem; }
  .brand-title { font-size: 1.05rem; min-width: 0; }
  .brand-badge { display: none; }
  .header-actions { gap: 0.5rem; }
  .header-actions .btn { white-space: nowrap; padding: 0.45rem 0.7rem; }
}

/* 注意喚起バナー（仕様書3.1/10.4準拠） */
.alert-banner {
  background: var(--accent-amber-bg); border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.65rem 1.5rem; font-size: 0.825rem; color: var(--accent-amber);
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; line-height: 1.4;
}
.alert-banner strong { font-weight: 700; }

/* メインレイアウト */
.container {
  max-width: 1200px; margin: 1.5rem auto; padding: 0 1.5rem;
  display: grid; grid-template-columns: 360px 1fr; gap: 1.5rem; align-items: start;
}
@media (max-width: 880px) { .container { grid-template-columns: 1fr; } }

/* カード共通 */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color);
}
.card-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); }

/* 入力フォーム */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: flex; justify-content: space-between; font-size: 0.825rem;
  color: var(--text-secondary); margin-bottom: 0.35rem; font-weight: 500;
}
.input-with-unit { position: relative; display: flex; align-items: center; }
.input-field {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border-color);
  color: var(--text-primary); font-family: var(--font-mono); font-size: 1rem;
  padding: 0.6rem 2.5rem 0.6rem 0.8rem; border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-field:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2); }
.input-unit { position: absolute; right: 0.8rem; font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-mono); pointer-events: none; }

/* 寸法サマリー */
.dimensions-summary {
  background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 0.65rem 0.8rem; margin-top: 0.5rem;
  font-size: 0.8rem; font-family: var(--font-mono); display: flex; justify-content: space-between;
}
.dim-tag { color: var(--text-muted); }
.dim-val { color: var(--text-primary); font-weight: 600; }

/* プリセット・トグル */
.presets-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; margin-top: 0.5rem; }
.btn-preset {
  background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-secondary);
  padding: 0.45rem 0.6rem; font-size: 0.75rem; border-radius: var(--radius-sm);
  cursor: pointer; text-align: left; transition: all 0.15s;
}
.btn-preset:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--text-muted); }

.toggle-item { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.toggle-item:last-child { border-bottom: none; }
.toggle-label { font-size: 0.85rem; color: var(--text-secondary); cursor: pointer; }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: 24px; transition: 0.2s;
}
.slider::before {
  position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px;
  background-color: var(--text-secondary); border-radius: 50%; transition: 0.2s;
}
input:checked + .slider { background-color: var(--accent-blue); border-color: var(--accent-blue); }
input:checked + .slider::before { transform: translateX(18px); background-color: #fff; }

.btn {
  background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-primary);
  font-size: 0.85rem; padding: 0.5rem 0.9rem; border-radius: var(--radius-sm);
  cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; transition: all 0.15s;
}
.btn:hover { background: var(--bg-card-hover); border-color: var(--text-muted); }

/* 結果エリア */
.results-container { display: flex; flex-direction: column; gap: 1rem; }

/* 最安バナー */
.best-choice-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.05) 100%);
  border: 1px solid rgba(16, 185, 129, 0.4); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow-glow); display: flex;
  justify-content: space-between; align-items: center; animation: fadeIn 0.3s ease-in-out;
}
.best-tag {
  display: inline-flex; align-items: center; gap: 0.3rem; background: var(--accent-emerald);
  color: #09090b; font-size: 0.75rem; font-weight: 700; padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm); margin-bottom: 0.4rem;
}
.best-title { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
.best-price { font-family: var(--font-mono); font-size: 1.75rem; font-weight: 700; color: var(--accent-emerald); }

/* 結果カード */
.result-card {
  position: relative; background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 1.25rem; transition: all 0.2s; animation: fadeIn 0.25s ease-in-out;
}
.result-card:hover {
  background: var(--bg-card-hover); border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px); box-shadow: var(--shadow-md);
}
.result-card.is-best { border-color: var(--accent-emerald); }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.6rem; }
.rank-badge {
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 700;
  padding: 0.15rem 0.5rem; border-radius: var(--radius-sm); background: #27272a; color: var(--text-secondary);
}
.rank-1 { background: var(--accent-emerald-bg); color: var(--accent-emerald); border: 1px solid var(--accent-emerald); }
.service-title { font-size: 1.05rem; font-weight: 700; margin-top: 0.2rem; }
.service-carrier { font-size: 0.75rem; color: var(--text-muted); }

.price-box { text-align: right; }
.total-price { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; color: var(--text-primary); }
.price-breakdown { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }

/* バッジ一覧 */
.badges-wrap { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.6rem 0; }
.badge-pill {
  font-size: 0.725rem; font-weight: 600; padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm); display: inline-flex; align-items: center; gap: 0.25rem;
}
.badge-anon { background: var(--accent-blue-bg); color: var(--accent-blue); border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-noanon { background: #27272a; color: var(--text-muted); }
.badge-post { background: rgba(168, 85, 247, 0.12); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-track { background: rgba(16, 185, 129, 0.12); color: #34d399; }

/* 警告アラート */
.card-alert {
  border-radius: var(--radius-sm); padding: 0.5rem 0.75rem; margin: 0.6rem 0;
  font-size: 0.8rem; line-height: 1.4; display: flex; gap: 0.4rem; align-items: flex-start;
}
.card-alert-soft { background: var(--accent-amber-bg); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.card-alert-hard { background: var(--accent-rose-bg); color: var(--accent-rose); border: 1px solid rgba(239, 68, 68, 0.3); font-weight: 600; }
.service-note {
  font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.4rem;
  border-top: 1px dashed var(--border-color); padding-top: 0.4rem;
}

/* フッター */
footer {
  max-width: 1200px; margin: 2rem auto 3rem; padding: 1.5rem;
  border-top: 1px solid var(--border-color); font-size: 0.8rem; color: var(--text-muted); line-height: 1.6;
}
.footer-links { display: flex; gap: 1rem; margin-top: 0.8rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-secondary); text-decoration: none; }
.footer-links a:hover { color: var(--accent-blue); text-decoration: underline; }

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