/* =====================
   CSS変数・リセット
===================== */
:root {
  --bg: #0f0d08;
  --bg2: #18140a;
  --surface: #221c10;
  --surface2: #2c2415;
  --border: #3d3018;
  --accent: #ea6c00;
  --accent2: #ff9a3c;
  --accent-glow: rgba(234, 108, 0, 0.38);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.3);
  --orange: #f59e0b;
  --red: #ef4444;
  --text: #f0e8d8;
  --text2: #b8a07a;
  --text3: #7a6040;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior: none;
}

/* =====================
   ヘッダー
===================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 15, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-text span {
  background: linear-gradient(135deg, var(--accent2), #ffcc00);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.header-btn:hover {
  color: var(--text);
  border-color: var(--accent2);
}

/* =====================
   メインコンテンツ
===================== */
.main {
  padding: 0 0 120px;
  max-width: 480px;
  margin: 0 auto;
}

/* =====================
   タイマーカード
===================== */
.timer-card {
  margin: 20px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all 0.4s ease;
}

.timer-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, var(--accent-glow), transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}

.timer-card.running::before { opacity: 1; }
.timer-card.running { border-color: var(--accent); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text3);
  transition: all 0.3s;
}

.status-badge.running {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--green);
  color: var(--green);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.running .status-dot {
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.timer-display {
  font-size: 68px;
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  letter-spacing: -3px;
  line-height: 1;
  background: linear-gradient(135deg, #fff 30%, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
  transition: all 0.3s;
}

.timer-sub {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 28px;
}

/* 料金表示 */
.cost-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 28px;
}

.cost-label {
  font-size: 12px;
  color: var(--text3);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.cost-amount {
  font-size: 48px;
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  letter-spacing: -2px;
  color: var(--green);
  transition: all 0.3s;
  position: relative;
}

.cost-amount::before {
  content: '¥';
  font-size: 24px;
  font-weight: 700;
  vertical-align: super;
  margin-right: 2px;
}

.cost-amount.highlight {
  animation: cost-bump 0.3s ease;
}

@keyframes cost-bump {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 100px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green);
  font-size: 12px;
  font-weight: 500;
}

.plan-chip.none {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text3);
}

/* コスト合計バー（タイマーカード内） */
.cost-grand {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text3);
}

.cost-grand span {
  color: var(--accent2);
  font-weight: 600;
}

/* ボタン類 */
.btn-start {
  width: 100%;
  padding: 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(.34, 1.56, .64, 1);
  position: relative;
  overflow: hidden;
}

.btn-start::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background 0.2s;
}

.btn-start:active::after { background: rgba(255, 255, 255, 0.1); }

.btn-start.idle {
  background: linear-gradient(135deg, #c85500, var(--accent2));
  color: #fff;
  box-shadow: 0 8px 32px var(--accent-glow);
}

.btn-start.idle:active { transform: scale(0.97); }

.btn-start.running {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
  box-shadow: 0 8px 32px rgba(239, 68, 68, 0.35);
}

.btn-start.running:active { transform: scale(0.97); }

/* 開始時間表示 */
.start-info {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text3);
}

/* =====================
   最終確定画面
===================== */
.final-card {
  margin: 0 16px 20px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(234, 108, 0, 0.1));
  border: 1px solid var(--green);
  border-radius: 24px;
  padding: 28px 24px;
  text-align: center;
  display: none;
}

.final-card.show {
  display: block;
  animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.final-title {
  font-size: 14px;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.final-amount {
  font-size: 56px;
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  color: #fff;
  letter-spacing: -2px;
  margin-bottom: 4px;
}

.final-amount::before {
  content: '¥';
  font-size: 26px;
  vertical-align: super;
  margin-right: 2px;
}

.final-detail {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 20px;
}

/* 最終カード追加料金内訳 */
.final-breakdown {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 16px;
  text-align: left;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.9;
}

.final-breakdown strong {
  color: var(--text);
  font-weight: 600;
}

.final-grand-total {
  font-size: 22px;
  font-weight: 900;
  color: var(--accent2);
  font-family: 'Inter', sans-serif;
  margin-bottom: 8px;
}

.final-grand-total::before {
  content: '合計 ¥';
  font-size: 14px;
}

.btn-reset {
  padding: 12px 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset:hover { border-color: var(--accent); }

/* =====================
   セクションタイトル
===================== */
.section {
  margin: 0 16px 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .icon {
  width: 26px;
  height: 26px;
  background: var(--surface2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* =====================
   料金プランリスト
===================== */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plan-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s;
}

.plan-item.best {
  border-color: var(--green);
  background: rgba(16, 185, 129, 0.08);
}

.plan-item-icon {
  width: 38px;
  height: 38px;
  background: var(--surface2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.plan-item.best .plan-item-icon { background: rgba(16, 185, 129, 0.2); }

.plan-info {
  flex: 1;
  min-width: 0;
}

.plan-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plan-detail {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

.plan-price {
  font-size: 16px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  flex-shrink: 0;
}

.plan-item.best .plan-price { color: var(--green); }

.best-tag {
  font-size: 10px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--green);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 600;
}

.plan-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
  color: var(--text2);
}

.btn-icon:hover { border-color: var(--red); color: var(--red); }
.btn-icon.edit:hover { border-color: var(--accent2); color: var(--accent2); }

.empty-plans {
  text-align: center;
  padding: 32px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text3);
  font-size: 14px;
  line-height: 1.7;
}

/* =====================
   プラン追加ボタン
===================== */
.btn-add {
  width: 100%;
  padding: 13px;
  background: transparent;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent2);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.btn-add:hover { background: rgba(234, 108, 0, 0.1); }

/* =====================
   追加料金セクション
===================== */
.extra-section {
  margin: 0 16px 16px;
}

.extra-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(234, 108, 0, 0.1);
  border: 1px solid rgba(234, 108, 0, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 10px;
}

.extra-total-label {
  font-size: 13px;
  color: var(--accent2);
  font-weight: 600;
}

.extra-total-val {
  font-size: 18px;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
  color: var(--accent2);
}

.extra-total-val::before {
  content: '¥';
  font-size: 13px;
  margin-right: 1px;
}

.extra-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.extra-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.extra-icon {
  width: 34px;
  height: 34px;
  background: var(--surface2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.extra-info {
  flex: 1;
  min-width: 0;
}

.extra-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.extra-count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--text2);
  transition: all 0.15s;
  line-height: 1;
  font-family: inherit;
}

.qty-btn:hover { border-color: var(--accent2); color: var(--accent2); }
.qty-btn:active { transform: scale(0.9); }

.qty-val {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  min-width: 20px;
  text-align: center;
}

.extra-subtotal {
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  flex-shrink: 0;
}

.extra-subtotal::before {
  content: '¥';
  font-size: 11px;
}

.extra-del {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  color: var(--text3);
  transition: all 0.2s;
  flex-shrink: 0;
  font-family: inherit;
}

.extra-del:hover { border-color: var(--red); color: var(--red); }

.empty-extra {
  text-align: center;
  padding: 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text3);
  font-size: 13px;
  line-height: 1.7;
}

/* =====================
   モーダル
===================== */
.modal-overlay,
.extra-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.show,
.extra-modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 40px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(.34, 1.56, .64, 1);
}

.modal-overlay.show .modal,
.extra-modal-overlay.show .modal {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 7px;
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus { border-color: var(--accent); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 5px;
}

/* プランタイプ選択 */
.plan-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.type-btn {
  padding: 10px 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.type-btn .type-icon { font-size: 18px; }

.type-btn.active {
  border-color: var(--accent);
  background: rgba(234, 108, 0, 0.14);
  color: var(--accent2);
}

/* 延長設定 */
.extend-settings {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 16px;
  display: none;
}

.extend-settings.show { display: block; }

.extend-settings .form-label {
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--orange);
  font-weight: 600;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  margin-top: 20px;
}

.btn-cancel {
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save {
  padding: 14px;
  background: linear-gradient(135deg, #c85500, var(--accent2));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-save:active { transform: scale(0.97); }

/* =====================
   履歴セクション
===================== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-icon {
  width: 36px;
  height: 36px;
  background: var(--surface2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.history-info { flex: 1; min-width: 0; }
.history-date { font-size: 12px; color: var(--text3); }
.history-dur { font-size: 13px; font-weight: 500; color: var(--text); }

.history-price {
  font-size: 16px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
  color: var(--green);
  flex-shrink: 0;
}

.history-price::before { content: '¥'; font-size: 12px; }

.btn-clear-history {
  font-size: 12px;
  color: var(--red);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 8px;
}

.empty-history {
  text-align: center;
  padding: 24px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text3);
  font-size: 13px;
}

/* =====================
   トースト通知
===================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  z-index: 500;
  transition: transform 0.3s cubic-bezier(.34, 1.56, .64, 1);
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* スクロール */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* 区切り */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 16px 20px;
}

/* プリセットボタン */
.preset-section { margin-bottom: 14px; }
.preset-label { font-size: 12px; color: var(--text3); margin-bottom: 8px; }

.preset-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-pill {
  padding: 5px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.preset-pill:hover {
  border-color: var(--accent2);
  color: var(--accent2);
  background: rgba(234, 108, 0, 0.1);
}

/* 料金説明 */
.note-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--orange);
  line-height: 1.7;
  margin: 0 16px 16px;
}

.note-box .note-title {
  font-weight: 600;
  margin-bottom: 4px;
}
