@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --primary: #1a73e8;
  --primary-hover: #1557b0;
  --secondary: #5f6368;
  --background: #f8f9fa;
  --surface: #ffffff;
  --text-main: #202124;
  --text-muted: #5f6368;
  --border: #e0e0e0;
  --danger: #d93025;
  --success: #1e8e3e;
  --warning: #f9ab00;
  --info: #1a73e8;
  --border-radius: 16px;
  --shadow-sm: 0 1px 3px 0 rgba(60,64,67,0.3), 0 1px 2px 0 rgba(60,64,67,0.15);
  --shadow: 0 4px 6px -1px rgba(60,64,67,0.15), 0 2px 4px -1px rgba(60,64,67,0.1);
}

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

html {
  overflow-x: hidden;
}

body {
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  background-color: var(--background);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* セーフエリア対応（iPhone ホームバー分） */
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  overflow-x: hidden;
  min-height: 100dvh;
}

/* Header */
header {
  background-color: var(--surface);
  padding: 1rem;
  /* ノッチ対応 */
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  /* 長いタイトルが折り返さないよう省略 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 0.5rem;
}

.header-icon {
  font-size: 1.25rem;
  color: var(--text-main);
  cursor: pointer;
  min-width: 40px;
  text-align: right;
}

/* Main Container */
main {
  padding: 1rem;
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
  max-width: 600px;
  margin: 0 auto;
  min-height: calc(100dvh - 140px);
  overflow-x: hidden;
  width: 100%;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--surface);
  display: flex;
  justify-content: space-around;
  /* セーフエリア（iPhoneホームバー）対応 */
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom)) 0;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--secondary);
  font-size: 0.7rem;
  font-weight: 500;
  transition: color 0.2s;
  flex: 1;
  padding: 0.5rem 0;
}

.nav-item i {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

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

/* Cards */
.card {
  background-color: var(--surface);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.02);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Welcome Banner */
.welcome-banner {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.welcome-banner h2 { font-size: 1.1rem; font-weight: 700; color: #166534; margin-bottom: 0.25rem; }
.welcome-banner p { font-size: 0.85rem; color: #15803d; }
.welcome-icon { font-size: 2.5rem; color: #22c55e; }

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-outline { background: transparent; border: 1px solid currentColor; }
.badge-pill { background: currentColor; color: white; }

.badge.primary { color: var(--primary); background-color: #e8f0fe; }
.badge.success { color: var(--success); background-color: #e6f4ea; }
.badge.warning { color: var(--warning); background-color: #fef7e0; }
.badge.danger { color: var(--danger); background-color: #fce8e6; }
.badge.neutral { color: var(--text-muted); background-color: #f1f3f4; }

/* FAB (Floating Action Button) */
.fab {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  right: max(20px, env(safe-area-inset-right));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(26,115,232,0.4);
  cursor: pointer;
  z-index: 50;
  border: none;
  transition: transform 0.2s;
}
.fab:hover { transform: scale(1.05); }
.fab:active { transform: scale(0.95); }

/* Tabs */
.tabs-container { margin-bottom: 1rem; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
.tabs-container::-webkit-scrollbar { display: none; }

.pill-tab {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background-color: transparent;
  border: none;
  cursor: pointer;
  margin-right: 0.5rem;
}
.pill-tab.active { background-color: var(--primary); color: white; }

.line-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.line-tab {
  flex: 1;
  text-align: center;
  padding: 0.75rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.line-tab.active { color: var(--primary); border-bottom: 2px solid var(--primary); }

/* Search Bar */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.search-input-wrapper {
  flex: 1;
  position: relative;
}
.search-input-wrapper i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: #f1f3f4;
  font-size: 16px;
}
.filter-btn {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--text-main);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

/* Forms & Inputs */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-main); }
input[type="text"], input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  /* iOSでフォーカス時の自動ズーム防止（16px以上必須） */
  font-size: 16px;
  background-color: var(--surface);
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Utils */
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.gap-2 { gap: 0.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.font-bold { font-weight: 700; }

/* Schedule List Items (Home & Schedule view) */
.schedule-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f3f4;
}
.schedule-item:last-child { border-bottom: none; }
.schedule-time { width: 50px; font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.schedule-border { width: 3px; height: 30px; border-radius: 2px; margin-right: 0.75rem; }
.schedule-border.blue { background-color: var(--primary); }
.schedule-border.red { background-color: var(--danger); }
.schedule-border.green { background-color: var(--success); }
.schedule-content { flex: 1; }
.schedule-content strong { font-size: 0.9rem; color: var(--text-main); display: block; }
.schedule-content small { font-size: 0.75rem; color: var(--text-muted); }

/* Checkbox (TODO) */
.todo-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f3f4;
}
.todo-item:last-child { border-bottom: none; }
.todo-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  margin-right: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: transparent;
}
.todo-item.completed .todo-checkbox {
  background-color: var(--primary);
  border-color: var(--primary);
  color: white;
}
.todo-content { flex: 1; font-size: 0.9rem; }
.todo-item.completed .todo-content { text-decoration: line-through; color: var(--text-muted); }
.todo-date { font-size: 0.75rem; color: var(--text-muted); }

/* Summary Cards (Home) */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  width: 100%;
}
.summary-card {
  border-radius: 8px;
  padding: 0.6rem 0.25rem;
  text-align: center;
  overflow: hidden;
}
.summary-card.bg-blue { background-color: #e8f0fe; }
.summary-card.bg-yellow { background-color: #fef7e0; }
.summary-card.bg-green { background-color: #e6f4ea; }
.summary-card.bg-gray { background-color: #f1f3f4; }
.summary-label { font-size: 0.6rem; font-weight: 600; margin-bottom: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }
.summary-card.bg-blue .summary-label { color: #1967d2; }
.summary-card.bg-yellow .summary-label { color: #b06000; }
.summary-card.bg-green .summary-label { color: #137333; }
.summary-card.bg-gray .summary-label { color: #5f6368; }
.summary-value { font-size: 1.1rem; font-weight: 700; color: var(--text-main); }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0,0,0,0.5);
  display: flex; justify-content: center; align-items: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
  background-color: var(--surface);
  width: 90%; max-width: 500px;
  border-radius: var(--border-radius);
  padding: 1.5rem;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(20px); transition: transform 0.3s;
}
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--secondary); }

/* Loader */
.loader { border: 3px solid #f3f3f3; border-top: 3px solid var(--primary); border-radius: 50%; width: 24px; height: 24px; animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loading-container { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 200px; color: var(--secondary); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--secondary); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.75rem 1.5rem; border-radius: 8px; font-weight: 600; font-size: 1rem;
  cursor: pointer; border: none; transition: all 0.2s; width: 100%;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-danger { background-color: var(--danger); color: white; }

/* Section Header (Home) */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.section-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text-main); }
.section-header a { font-size: 0.8rem; color: var(--primary); text-decoration: none; font-weight: 500; cursor: pointer;}
