/* ===========================
   ベース・リセット
=========================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --primary-light: #e8f0fe;
  --success: #34a853;
  --warning: #fbbc04;
  --danger: #ea4335;
  --danger-light: #fce8e6;
  --orange: #ff6d00;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 20px rgba(0,0,0,0.14);
  --radius: 16px;
  --radius-sm: 8px;
  --font: 'Noto Sans JP', sans-serif;
  --font-mono: 'Roboto Mono', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ===========================
   アプリ全体ラッパー
=========================== */
.app-wrapper {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 40px;
}

/* ===========================
   ヘッダー
=========================== */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 28px 8px 20px;
}

.header-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #1a73e8, #0d47a1);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.35);
}

.header-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.header-text p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===========================
   カード
=========================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-light);
}

.section-title i {
  color: var(--primary);
  font-size: 1rem;
}

/* ===========================
   フォームグループ
=========================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.form-label i {
  color: var(--primary);
  width: 16px;
  text-align: center;
}

.form-label .note {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.help-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: help;
  margin-left: 4px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font-mono);
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-with-unit .form-input {
  flex: 1;
}

.unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 40px;
}

/* ===========================
   ボンベ種別セレクター
=========================== */
.cylinder-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cylinder-btn {
  flex: 1;
  min-width: 72px;
  padding: 10px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  transition: all 0.2s;
  line-height: 1.3;
}

.cylinder-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.cylinder-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.cyl-icon {
  display: block;
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.cyl-icon.small { font-size: 0.9rem; }
.cyl-icon.large { font-size: 1.7rem; }

/* ===========================
   タブスイッチ
=========================== */
.tab-switch {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

.input-panel {
  display: none;
  margin-top: -4px;
}

.input-panel.active {
  display: block;
}

/* ===========================
   圧力スライダー
=========================== */
.pressure-slider-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slider-container {
  position: relative;
  width: 100%;
}

.pressure-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--primary) 0%, var(--primary) 100%);
  outline: none;
  cursor: pointer;
}

.pressure-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(26, 115, 232, 0.4);
  border: 3px solid white;
  transition: box-shadow 0.2s;
}

.pressure-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 2px 10px rgba(26, 115, 232, 0.6);
}

.pressure-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid white;
  box-shadow: 0 2px 6px rgba(26, 115, 232, 0.4);
}

/* ===========================
   圧力ゲージ
=========================== */
.gauge-display {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.gauge-visual {
  position: relative;
  width: 200px;
  text-align: center;
}

#gaugeCanvas {
  display: block;
  margin: 0 auto;
}

.gauge-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: -4px;
}

/* ===========================
   パーセントバー
=========================== */
.percent-bar-container {
  width: 100%;
  height: 12px;
  background: var(--bg);
  border-radius: 6px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.percent-bar {
  height: 100%;
  background: linear-gradient(to right, #ea4335, #fbbc04, #34a853);
  border-radius: 6px;
  transition: width 0.3s ease;
}

/* ===========================
   流量プリセットボタン
=========================== */
.flow-rate-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.flow-btn {
  padding: 7px 12px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.flow-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.flow-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* ===========================
   安全マージン
=========================== */
.margin-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
  background: #fff;
}

.radio-label:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.radio-label input[type="radio"] {
  accent-color: var(--primary);
}

.recommend {
  background: var(--success);
  color: white;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 2px;
}

/* ===========================
   計算ボタン
=========================== */
.calc-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.35);
  letter-spacing: 0.03em;
}

.calc-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark), #0d3a7a);
  box-shadow: 0 6px 16px rgba(26, 115, 232, 0.45);
  transform: translateY(-1px);
}

.calc-btn:active {
  transform: translateY(0);
}

/* ===========================
   結果セクション
=========================== */
.result-section {
  background: var(--card-bg);
}

.result-main {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.result-time-card {
  text-align: center;
  padding: 24px 40px;
  background: linear-gradient(135deg, #e8f0fe, #d2e3fc);
  border-radius: var(--radius);
  border: 2px solid var(--primary-light);
  width: 100%;
  max-width: 360px;
  transition: all 0.3s;
}

.result-time-card.danger {
  background: linear-gradient(135deg, #fce8e6, #fad2cf);
  border-color: #f5c6c2;
}

.result-time-card.warning-state {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border-color: #ffe082;
}

.result-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.result-time {
  font-family: var(--font-mono);
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 2px;
  line-height: 1.1;
}

.result-time-card.danger .result-time {
  color: var(--danger);
}

.result-time-card.warning-state .result-time {
  color: var(--orange);
}

.result-time-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ===========================
   詳細情報
=========================== */
.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.detail-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.detail-label i {
  color: var(--primary);
  font-size: 0.75rem;
}

.detail-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

/* ===========================
   タイムライン
=========================== */
.timeline-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.timeline-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-title i {
  color: var(--primary);
}

.timeline-input {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.time-input {
  width: auto;
  flex: 1;
  min-width: 120px;
  max-width: 180px;
  font-size: 1rem;
  padding: 10px 12px;
}

.now-btn {
  padding: 10px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

.now-btn:hover {
  background: var(--primary);
  color: white;
}

.timeline-result {
  padding: 10px 0;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 4px;
}

.timeline-dot.green { background: var(--success); box-shadow: 0 0 0 3px rgba(52,168,83,0.2); }
.timeline-dot.orange { background: var(--orange); box-shadow: 0 0 0 3px rgba(255,109,0,0.2); }
.timeline-dot.red { background: var(--danger); box-shadow: 0 0 0 3px rgba(234,67,53,0.2); }

.timeline-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  padding: 8px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.tl-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.tl-time {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.timeline-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  margin: 4px 0 4px 22px;
  overflow: hidden;
}

.timeline-fill {
  height: 100%;
  background: linear-gradient(to right, var(--success), var(--warning), var(--danger));
  width: 100%;
}

/* ===========================
   警告セクション
=========================== */
.warning-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--danger-light);
  color: var(--danger);
  border: 2px solid #f5c6c2;
}

.warning-card.warn {
  background: #fff8e1;
  color: #e65100;
  border-color: #ffe082;
}

.warning-card i {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ===========================
   比較テーブル
=========================== */
.comparison-section {
  background: var(--card-bg);
}

.comparison-note {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  margin-top: -12px;
}

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.comparison-table thead tr {
  background: var(--primary);
  color: white;
}

.comparison-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
}

.comparison-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.comparison-table tbody tr:nth-child(even) {
  background: #f8f9fa;
}

.comparison-table tbody tr:hover {
  background: var(--primary-light);
}

.comparison-table .current-row {
  background: #e8f0fe !important;
  font-weight: 700;
}

.comparison-table .current-row td:first-child::after {
  content: " ◀";
  color: var(--primary);
  font-size: 0.75rem;
}

.no-data {
  text-align: center;
  color: var(--text-secondary);
  padding: 24px !important;
  font-family: var(--font);
  font-size: 0.9rem;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font);
}

.status-ok { background: #e6f4ea; color: var(--success); }
.status-warn { background: #fff8e1; color: #f57c00; }
.status-danger { background: var(--danger-light); color: var(--danger); }

/* ===========================
   フッター
=========================== */
.app-footer {
  text-align: center;
  padding: 16px 8px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.8;
  border-top: 1px solid var(--border);
  margin-top: 10px;
}

.app-footer i {
  color: var(--primary);
}

/* ===========================
   アニメーション
=========================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.result-section, .comparison-section {
  animation: fadeIn 0.3s ease;
}

.result-time-card {
  animation: fadeIn 0.4s ease;
}

/* ===========================
   レスポンシブ
=========================== */
@media (max-width: 500px) {
  .app-wrapper { padding: 0 12px 32px; }
  .card { padding: 18px 16px; }
  .header-text h1 { font-size: 1.1rem; }
  .result-time { font-size: 2.6rem; }
  .result-details { grid-template-columns: 1fr; }
  .cylinder-selector { gap: 6px; }
  .cylinder-btn { min-width: 58px; font-size: 0.76rem; padding: 8px 4px; }
  .flow-btn { padding: 6px 9px; font-size: 0.78rem; }
  .margin-options { gap: 7px; }
  .timeline-input { flex-direction: column; align-items: flex-start; }
  .time-input { max-width: 100%; width: 100%; }
}
