:root {
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --accent: #4caf50;
  --accent-dark: #388e3c;
  --text: #333;
  --text-secondary: #666;
  --border: #e0e0e0;
  --error: #f44336;
  --warning: #ff9800;
  --success: #4caf50;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
  --radius: 16px;
  --bottom-nav-height: 64px;
  --header-height: 56px;
}

[data-theme="dark"] {
  --bg: #121212;
  --card-bg: #1e1e1e;
  --text: #e0e0e0;
  --text-secondary: #999;
  --border: #333;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  padding-bottom: var(--bottom-nav-height);
  transition: background 0.3s ease;
}

/* ヘッダー - 最小化 */
.header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle:active {
  transform: scale(0.9);
  background: var(--border);
}

/* メインコンテンツエリア */
.main-content {
  position: relative;
  min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
  overflow: hidden;
}

.section {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity;
}

.section.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) !important;
  position: relative;
  z-index: 1;
}

.section.next {
  transform: translateX(100%);
  visibility: visible;
  opacity: 1;
}

.section.prev {
  transform: translateX(-100%);
  visibility: visible;
  opacity: 1;
}

.section.switching {
  transition: none !important;
}

/* カードスタイル */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.card:active {
  transform: scale(0.98);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* 入力グループ */
.input-row {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.input-label {
  min-width: 100px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  flex: 1;
  position: relative;
}

.input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  transition: all 0.2s ease;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.1);
}

.input.error {
  border-color: var(--error);
  animation: shake 0.3s;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-4px);
  }

  75% {
    transform: translateX(4px);
  }
}

/* 結果表示 */
.result-card {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  padding: 24px;
  border-radius: var(--radius);
  text-align: center;
  margin: 20px 0;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-label {
  font-size: 0.9rem;
  opacity: 0.9;
  margin-bottom: 8px;
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
}

/* ボタン */
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:active::before {
  width: 300px;
  height: 300px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

/* テーブルスタイル（モバイル最適化） */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.data-row {
  background: var(--bg);
  border-radius: 8px;
}

.data-cell {
  padding: 12px;
}

.data-cell:first-child {
  border-radius: 8px 0 0 8px;
  font-weight: 500;
  color: var(--text-secondary);
}

.data-cell:last-child {
  border-radius: 0 8px 8px 0;
  text-align: right;
  font-weight: 600;
  color: var(--accent);
}

/* ボトムナビゲーション */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  z-index: 1000;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 12px;
}

.nav-item:active {
  background: var(--border);
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active .material-symbols-outlined {
  animation: bounce 0.4s ease;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

.nav-icon {
  font-size: 24px;
}

.nav-label {
  font-size: 0.75rem;
  font-weight: 500;
}

/* FAB（フローティングアクションボタン） */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 99;
}

.fab:active {
  transform: scale(0.9);
}

.fab.visible {
  opacity: 1;
  transform: scale(1);
}

.fab.hidden {
  opacity: 0;
  transform: scale(0);
}

/* スナックバー（通知） */
.snackbar {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #323232;
  color: white;
  padding: 14px 24px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  z-index: 1001;
  opacity: 0;
  transition: all 0.3s ease;
}

.snackbar.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* レスポンシブ調整 */
@media (min-width: 768px) {
  .main-content {
    max-width: 768px;
    margin: 0 auto;
  }

  .bottom-nav {
    max-width: 768px;
    left: 50%;
    transform: translateX(-50%);
  }
}