:root {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  font-weight: 400;

  color-scheme: light;
  color: #2c2c35;
  background-color: #f5f5f7;

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* ライトテーマの変数 */
  --primary-gradient: linear-gradient(135deg, #4a4a5e 0%, #2c2c35 100%);
  --accent-color: #007aff;
  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(255, 255, 255, 0.6);
  --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
  --input-bg: rgba(0, 0, 0, 0.03);
  --input-border: rgba(0, 0, 0, 0.05);
  --input-focus-border: rgba(0, 0, 0, 0.2);
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --dialog-bg-purple: #f3e5f5;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-width: 320px;
  min-height: 100vh;
  height: 100vh;
  /* Android環境でキーボード表示時にビューポート高さを固定 */
  background: radial-gradient(circle at top left, #ffffff 0%, #f0f2f5 100%);
  overflow-x: hidden;
  position: relative;
  /* absoluteで配置されるフッターの基準点 */
}

#app {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 6rem 0.5rem 6rem;
  /* Increased bottom padding */
  box-sizing: border-box;
}


.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.5s ease;
}





.close-dialog-btn {
  position: absolute;
  top: 0.75rem;
  right: 1.5rem;
  background: rgba(149, 117, 205, 0.1);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: rgba(242, 242, 247, 0.8);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  backdrop-filter: blur(4px);
}

.close-dialog-btn:hover {
  background: rgba(149, 117, 205, 0.2);
  color: rgba(255, 255, 255, 0.95);
  transform: rotate(90deg);
}

.cell-sort-btn {
  position: absolute;
  top: 0.75rem;
  right: 4.5rem;
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.cell-sort-btn:hover {
  color: rgba(255, 255, 255, 0.9);
}



/* ダイアログ内の個別のセルエディタ */
.cell-editor-item {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  position: relative;
}

/* セルの生成時刻表示 */
.cell-timestamp {
  position: absolute;
  top: 0.2rem;
  right: 0.75rem;
  font-size: 0.625rem;
  color: rgba(0, 0, 0, 0.25);
  font-weight: 400;
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

.cell-title-input {
  font-size: 1.25rem;
  font-weight: 700;
  border: none;
  background: transparent;
  outline: none;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: border-bottom-color 0.3s;
  width: 100%;
  resize: none;
  overflow: hidden;
  font-family: inherit;
  box-sizing: border-box;
}

.add-cell-btn.dimmed {
  opacity: 0.3;
}

.cell-title-input:focus {
  border-bottom-color: #9575cd;
}

.cell-value-input {
  font-size: 1.125rem;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  overflow: hidden;
  color: var(--text-secondary);
  line-height: 1.5;
  transition: color 0.3s, height 0.2s ease;
  box-sizing: border-box;
  padding: 4px 0;
}

.cell-value-input::placeholder {
  font-size: 1.125rem;
  color: rgba(0, 0, 0, 0.25);
  line-height: 1.5;
}

.cell-value-input:focus {
  color: var(--text-primary);
}

/* カード追加ボタン (FAB) */
.add-card-btn {
  position: fixed;
  bottom: 6rem;
  /* Moved up above footer */
  right: 2.5rem;
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: white;
  color: #9575cd;
  border: 1px solid rgba(149, 117, 205, 0.3);
  font-weight: 400;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  -webkit-tap-highlight-color: transparent;
}

.add-card-btn::before {
  content: '+';
  line-height: 1;
}

.add-card-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.add-card-btn:active {
  transform: scale(0.95);
}

.add-cell-btn {
  position: absolute;
  bottom: 2rem;
  right: 2rem;
  width: 56px;
  height: 56px;
  background: white;
  color: #9575cd;
  border: none;
  border-radius: 50%;
  font-weight: 500;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  user-select: none;
  opacity: 0.7;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 480px) {
  .add-cell-btn {
    bottom: 0.5rem;
    right: 0.5rem;
  }
}

.add-cell-btn::before {
  content: '+';
  line-height: 1;
}

.add-cell-btn:hover {
  transform: translateY(-4px) scale(1.08);
  box-shadow: none;
  opacity: 1;
}


.add-cell-btn:active {
  transform: scale(0.95);
}

/* ツールチップ */






.close-dialog-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
  transform: rotate(90deg);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}




@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(60px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 6rem;
  padding-bottom: 6rem;
  animation: fadeIn 0.5s ease;
}

/* ビューモード: リスト (デフォルト) */
.card-list.view-list {
  display: flex;
  flex-direction: column;
}

/* ビューモード: 複数セル表示 (旧 Grid-2/詳細表示) -> 1列表示に変更 */
.card-list.view-grid-2 {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-list-item {
  background: white;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  scroll-margin-top: 80px;
  /* Header (60px) + 20px margin */
}

/* Grid表示時の調整 */
.view-grid-2 .card-list-item {
  padding: 1.25rem;
  border-radius: 20px;
}

.card-list-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.08);
}

/* カードコンテンツ (共通) */
/* .view-grid-2 以外に適用されるデフォルト */
.card-content-preview {
  font-size: 1.125rem;
  /* デフォルトサイズ */
  font-weight: 700;
  color: #f2f2f7;
  /* 少し灰色寄りの白 */
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.75rem;
  line-height: 1.5;
  width: 100%;

  /* 1行で省略 (リスト、タイムライン共通) */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}


/* Grid-2（詳細表示）の場合は複数行表示を許可 */
.view-grid-2 .card-content-preview {
  white-space: normal;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  padding-right: 0;
}

.view-grid-2 .card-title-line {
  font-size: 1rem;
  line-height: 1.4;
  padding-bottom: 0.25rem;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.05);
}

.view-grid-2 .card-title-line:last-child {
  border-bottom: none;
}

/* 旧メタデータ表示エリア (リスト表示等で下部に出る日付) */
.card-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-feature-settings: "tnum";
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  opacity: 0.7;
}

.empty-icon {
  width: 24px;
  height: 24px;
  opacity: 0.5;
}

/* 時間表示 (共通UI: 右上に配置) */
.card-time-display {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.625rem;
  color: rgba(242, 242, 247, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  background: transparent;
  padding: 0;
}

/* 固定カードカウント表示 */
.card-count-fixed {
  position: fixed;
  top: 75px;
  /* ヘッダー(60px)の下に配置 */
  right: 1.5rem;
  z-index: 80;
  /* ヘッダー(100)より低く、コンテンツより高く */
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  animation: fadeIn 0.5s ease;
}

/* グローバルローディングアニメーション */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.3);
  /* 少しだけ白くして操作不能感を出す */
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.loading-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(0, 122, 255, 0.2);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* キーワード強調表示 */
mark.keyword-highlight {
  background-color: #fff59d;
  /* 明るい黄色 */
  color: inherit;
  padding: 2px 4px;
  border-radius: 3px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}