:root {
  --bg: #000000;
  --card: #111111;
  --card2: #1a1a1a;
  --border: #2a2a2a;
  --accent: #ffffff;
  --accent2: #e0e0e0;
  --text: #f0f0f0;
  --text2: #999999;
  --text3: #666666;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --gcal: #60a5fa;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
}
input, select, textarea, button { font-family: inherit; }

.app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.header {
  padding: calc(var(--safe-top) + 10px) 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.header h1 { font-size: 20px; font-weight: 700; color: #fff; }
.header .date { font-size: 12px; color: var(--text3); }
.header-right { display: flex; align-items: center; gap: 8px; }

.main {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(70px + var(--safe-bottom));
}

/* Google sync button */
.gcal-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card2); color: var(--text2); font-size: 11px;
  cursor: pointer; white-space: nowrap;
}
.gcal-btn.connected { border-color: var(--gcal); color: var(--gcal); }
.gcal-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.sync-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.sync-dot.off { background: var(--text3); }
.sync-dot.on { background: var(--green); }
.sync-dot.syncing { background: var(--yellow); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Toast */
.toast {
  position: fixed; top: calc(var(--safe-top) + 60px); left: 50%; transform: translateX(-50%);
  background: var(--card2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 20px; border-radius: 10px; font-size: 13px; z-index: 300;
  animation: fadeInOut 2.5s ease-in-out forwards;
  pointer-events: none;
}
@keyframes fadeInOut { 0%{opacity:0;transform:translateX(-50%) translateY(-10px)} 10%{opacity:1;transform:translateX(-50%) translateY(0)} 80%{opacity:1} 100%{opacity:0} }

/* gcal badge on events */
.gcal-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; color: var(--gcal); background: rgba(66,133,244,0.15);
  padding: 1px 6px; border-radius: 8px;
}

/* Bottom nav */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; padding: 6px 0 calc(6px + var(--safe-bottom)); z-index: 100;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 0;
  background: none; border: none; color: var(--text3);
  font-size: 10px; cursor: pointer; transition: color 0.2s;
}
.nav-item.active { color: #fff; }
.nav-item svg { width: 22px; height: 22px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.stat-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }

.pills { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
.pill { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text2); font-size: 13px; white-space: nowrap; cursor: pointer; transition: all 0.2s; }
.pill.active { background: #fff; border-color: #fff; color: #000; }

.task-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 8px; }
.task-title { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.task-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; display: inline-block; }

.client-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.client-name { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.client-company { font-size: 13px; color: var(--accent2); margin-bottom: 6px; }
.client-info { font-size: 12px; color: var(--text3); margin-bottom: 4px; }
.client-revenue { font-size: 18px; font-weight: 700; color: var(--green); }

.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-nav { background: none; border: none; color: var(--text2); font-size: 20px; padding: 8px; cursor: pointer; }
.cal-month { font-size: 16px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text3); padding: 4px 0; }
.cal-day { min-height: 48px; padding: 4px; border-radius: 8px; font-size: 12px; cursor: pointer; position: relative; }
.cal-day.today { background: var(--card2); border: 1px solid var(--accent); }
.cal-day .day-num { font-weight: 500; margin-bottom: 2px; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; margin-right: 1px; }
.event-item { background: var(--card2); border-radius: 10px; padding: 10px 14px; margin-bottom: 6px; display: flex; align-items: center; gap: 10px; }
.event-bar { width: 3px; height: 32px; border-radius: 2px; flex-shrink: 0; }
.event-title { font-size: 14px; font-weight: 500; }
.event-time { font-size: 12px; color: var(--text3); }

/* Calendar view switcher */
.cal-views { display: flex; gap: 4px; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
.cal-view-btn {
  flex: 1; padding: 7px 0; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  background: transparent; color: var(--text3); transition: all 0.2s;
  text-align: center;
}
.cal-view-btn.active { background: var(--accent); color: #fff; }

/* Day view */
.cal-day-header { text-align: center; padding: 12px 0; margin-bottom: 12px; }
.cal-day-num { font-size: 36px; font-weight: 700; }
.cal-day-label { font-size: 14px; color: var(--text3); margin-top: 2px; }
.cal-day-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-hour-grid { position: relative; }
.cal-hour-row { display: flex; min-height: 52px; border-top: 1px solid var(--border); }
.cal-hour-label { width: 42px; font-size: 11px; color: var(--text3); text-align: right; padding-right: 8px; padding-top: 2px; flex-shrink: 0; }
.cal-hour-content { flex: 1; padding: 2px 0; position: relative; }
.cal-hour-event {
  background: var(--card2); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; padding: 6px 10px; margin-bottom: 2px;
  font-size: 13px; cursor: pointer;
}
.cal-hour-event .ev-title { font-weight: 500; }
.cal-hour-event .ev-time { font-size: 11px; color: var(--text3); }
.cal-allday {
  background: var(--card2); border-radius: 10px; padding: 8px 12px;
  margin-bottom: 8px; font-size: 13px; border-left: 3px solid var(--yellow);
}

/* Week view */
.cal-week-grid { display: grid; grid-template-columns: 42px repeat(7, 1fr); gap: 1px; }
.cal-week-header-cell { text-align: center; padding: 6px 2px; font-size: 11px; color: var(--text3); }
.cal-week-header-cell.today-col { color: var(--accent); font-weight: 600; }
.cal-week-day-num { font-size: 16px; font-weight: 600; color: var(--text); display: block; margin-top: 1px; }
.cal-week-header-cell.today-col .cal-week-day-num {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 28px; height: 28px; line-height: 28px; margin: 2px auto 0;
  display: block; text-align: center;
}
.cal-week-hour-label { font-size: 10px; color: var(--text3); text-align: right; padding-right: 4px; height: 40px; line-height: 40px; }
.cal-week-cell { min-height: 40px; border-top: 1px solid var(--border); padding: 1px; position: relative; cursor: pointer; }
.cal-week-event {
  background: rgba(99,102,241,0.2); border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0; padding: 2px 4px; margin-bottom: 1px;
  font-size: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer;
}

.finance-summary { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.finance-summary-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 10px; text-align: center; }
.finance-summary-item .finance-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.finance-summary-item .finance-amount { font-size: 18px; font-weight: 700; display: block; }
.finance-summary-item.income .finance-amount { color: var(--green); }
.finance-summary-item.expense .finance-amount { color: var(--red); }
.finance-summary-item.balance .finance-amount.positive { color: var(--green); }
.finance-summary-item.balance .finance-amount.negative { color: var(--red); }
.finance-list { display: flex; flex-direction: column; gap: 6px; }
.finance-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.finance-item:active { opacity: 0.8; }
.finance-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; }
.finance-icon.income { background: rgba(52,199,89,0.15); color: var(--green); }
.finance-icon.expense { background: rgba(255,71,87,0.15); color: var(--red); }
.finance-info { flex: 1; min-width: 0; }
.finance-desc { font-size: 14px; font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finance-meta { font-size: 11px; color: var(--text3); display: block; margin-top: 2px; }
.finance-item .finance-amount { font-size: 15px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.finance-item .finance-amount.income { color: var(--green); }
.finance-item .finance-amount.expense { color: var(--red); }
.filter-bar { display: flex; gap: 6px; margin-bottom: 14px; }
.filter-btn { padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border); background: var(--card); color: var(--text2); font-size: 13px; cursor: pointer; }
.filter-btn.active { background: #fff; color: #000; border-color: #fff; }

.fab {
  position: fixed; bottom: calc(80px + var(--safe-bottom)); right: 16px;
  width: 52px; height: 52px; border-radius: 50%;
  background: #fff; border: none; color: #000;
  font-size: 28px; cursor: pointer; z-index: 90;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(255,255,255,0.15); transition: transform 0.2s;
}
.fab:active { transform: scale(0.92); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; display: flex; align-items: flex-end; justify-content: center; }
.modal {
  background: var(--card); border-radius: 20px 20px 0 0; width: 100%; max-width: 500px;
  max-height: 85vh; overflow-y: auto; padding: 20px 16px calc(20px + var(--safe-bottom));
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-handle { width: 36px; height: 4px; background: var(--text3); border-radius: 2px; margin: 0 auto 16px; }
.modal h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

.form-group { margin-bottom: 14px; }
.form-label { font-size: 13px; color: var(--text2); margin-bottom: 4px; display: block; }
.form-input { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 15px; }
.form-input:focus { outline: none; border-color: var(--accent); }
.form-textarea { resize: vertical; min-height: 60px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { width: 100%; padding: 14px; border-radius: 12px; border: none; font-size: 15px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn:active { opacity: 0.8; transform: scale(0.98); }
.btn-primary { background: #fff; color: #000; font-weight: 700; }
.btn-secondary { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger-sm { background: transparent; color: var(--red); border: 1px solid var(--red); border-radius: 8px; padding: 6px 14px; font-size: 13px; cursor: pointer; font-weight: 500; }
.btn-danger-sm:active { background: var(--red); color: #fff; }

.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap input { padding-left: 36px; }
.search-icon { position: absolute; left: 12px; top: 11px; color: var(--text3); }

.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.delete-action { background: none; border: none; color: var(--red); padding: 8px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.empty { text-align: center; padding: 40px 20px; color: var(--text3); font-size: 14px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-title { font-size: 20px; font-weight: 700; }

.pills::-webkit-scrollbar { display: none; }
.main::-webkit-scrollbar { display: none; }
@media (prefers-reduced-motion: no-preference) { .main { scroll-behavior: smooth; } }

/* Google Calendar setup card */
.gcal-setup { background: var(--card2); border: 1px solid var(--gcal); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.gcal-setup h4 { color: var(--gcal); font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.gcal-setup p { color: var(--text2); font-size: 13px; line-height: 1.5; margin-bottom: 10px; }
.gcal-setup .btn { font-size: 14px; padding: 10px; }

/* Sync toggle on event form */
.gcal-toggle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--card2); border-radius: 10px; margin-bottom: 14px;
}
.gcal-toggle label { font-size: 13px; color: var(--text2); display: flex; align-items: center; gap: 6px; }
.toggle-switch {
  position: relative; width: 44px; height: 24px; border-radius: 12px;
  background: var(--border); cursor: pointer; transition: background 0.2s;
}
.toggle-switch.on { background: var(--green); }
.toggle-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: #fff;
  transition: transform 0.2s;
}
.toggle-switch.on::after { transform: translateX(20px); }

/* ===== Timeboxing Card System ===== */
.tb-period { margin-bottom: 20px; }
.tb-period-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; padding: 0 2px; }
.tb-period-icon {
  width: 32px; height: 32px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.tb-period-icon.morning { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.tb-period-icon.afternoon { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.tb-period-icon.evening { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.tb-period-label { font-size: 15px; font-weight: 600; }
.tb-period-count { font-size: 11px; color: var(--text3); background: var(--card2); padding: 1px 7px; border-radius: 8px; margin-left: auto; }
.tb-period-progress { width: 40px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.tb-period-progress-bar { height: 100%; border-radius: 2px; transition: width 0.3s; background: var(--green); }
.tb-drop-zone { min-height: 20px; border-radius: 12px; transition: background 0.2s, border-color 0.2s; border: 2px dashed transparent; }
.tb-drop-zone.drag-over { background: rgba(99,102,241,0.08); border-color: var(--accent); }

/* Card */
.tb-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 8px;
  transition: all 0.15s; touch-action: none; position: relative;
  user-select: none; -webkit-user-select: none;
}
.tb-card.dragging { opacity: 0.5; border-color: var(--accent); transform: scale(0.97); }
.tb-card.drag-ghost {
  position: fixed; z-index: 500; pointer-events: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  border-color: var(--accent); transform: scale(1.03) rotate(1deg);
  width: calc(100vw - 64px); max-width: 436px;
}
.tb-card.done-card { opacity: 0.5; border-style: dashed; }
.tb-card-top { display: flex; align-items: center; gap: 10px; }
.tb-card-check {
  width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid var(--border); background: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s; color: transparent;
}
.tb-card-check.checked { background: var(--green); border-color: var(--green); color: #fff; }
.tb-card-check svg { width: 14px; height: 14px; }
.tb-card-title { flex: 1; font-size: 15px; font-weight: 500; }
.tb-card-title.done { text-decoration: line-through; color: var(--text3); }
.tb-card-grip { padding: 6px 2px; cursor: grab; color: var(--text3); display: flex; flex-direction: column; gap: 2px; align-items: center; }
.tb-card-grip span { display: block; width: 14px; height: 2px; background: var(--text3); border-radius: 1px; }
.tb-card-bottom { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.tb-card-dur { font-size: 12px; color: var(--text3); background: var(--card2); padding: 2px 8px; border-radius: 8px; display: flex; align-items: center; gap: 3px; }
.tb-card-dur svg { width: 12px; height: 12px; }
.tb-card-period-badge { font-size: 11px; padding: 2px 8px; border-radius: 8px; }
.tb-card-period-badge.morning { color: #fbbf24; background: rgba(251,191,36,0.15); }
.tb-card-period-badge.afternoon { color: #60a5fa; background: rgba(96,165,250,0.15); }
.tb-card-period-badge.evening { color: #a78bfa; background: rgba(167,139,250,0.15); }
.tb-card-delete { margin-left: auto; background: none; border: none; color: var(--text3); padding: 4px; cursor: pointer; opacity: 0.4; transition: all 0.2s; }
.tb-card-delete:active { opacity: 1; color: var(--red); }

/* Add form */
.tb-add-expanded {
  background: var(--card); border: 1px solid var(--accent);
  border-radius: 14px; padding: 14px; margin-bottom: 16px;
}
.tb-add-expanded input[type="text"] {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 15px; margin-bottom: 10px;
}
.tb-add-expanded input[type="text"]:focus { outline: none; border-color: var(--accent); }
.tb-add-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.tb-add-row select {
  flex: 1; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 14px; appearance: none; -webkit-appearance: none;
}
.tb-add-row select:focus { outline: none; border-color: var(--accent); }
.tb-add-btn {
  padding: 10px 20px; border-radius: 10px; border: none;
  background: #fff; color: #000; font-size: 14px;
  font-weight: 600; cursor: pointer; width: 100%;
}
.tb-add-btn:active { opacity: 0.8; }

/* Summary bar */
.tb-summary { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tb-summary::-webkit-scrollbar { display: none; }
.tb-summary-chip {
  flex-shrink: 0; padding: 8px 14px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
  text-align: center; min-width: 90px;
}
.tb-summary-val { font-size: 18px; font-weight: 700; }
.tb-summary-label { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* Empty period */
.tb-empty-period {
  text-align: center; padding: 16px; color: var(--text3);
  font-size: 13px; border: 1px dashed var(--border);
  border-radius: 12px; margin-bottom: 8px;
}

/* Auto-imported cards */
.tb-card.tb-card-auto { border-style: dashed; background: var(--card); }
.tb-card-source { font-size: 10px; padding: 1px 6px; border-radius: 6px; margin-left: 4px; }
.tb-card-source.from-task { color: var(--yellow); background: rgba(245,158,11,0.12); }
.tb-card-source.from-event { color: var(--gcal); background: rgba(66,133,244,0.12); }
.tb-card-source.from-overdue { color: var(--red); background: rgba(239,68,68,0.12); }
.tb-card-source.from-routine { color: #a78bfa; background: rgba(167,139,250,0.12); }

.today-section { margin-bottom: 18px; }
.today-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.today-section-title { font-size: 13px; font-weight: 600; color: var(--text2); display: flex; align-items: center; gap: 5px; }
.today-count { font-size: 11px; color: var(--text3); background: var(--card2); padding: 1px 7px; border-radius: 8px; }
.task-from-main { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card2); border-radius: 10px; margin-bottom: 6px; }
.overdue-tag { font-size: 10px; color: var(--red); background: rgba(239,68,68,0.15); padding: 1px 6px; border-radius: 6px; }

/* Routine management */
.routine-list { margin-top: 12px; }
.routine-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--card2); border-radius: 12px; margin-bottom: 8px;
}
.routine-toggle {
  position: relative; width: 40px; height: 22px; border-radius: 11px;
  background: var(--border); cursor: pointer; transition: background 0.2s;
  flex-shrink: 0; border: none;
}
.routine-toggle.on { background: var(--green); }
.routine-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.2s;
}
.routine-toggle.on::after { transform: translateX(18px); }
.routine-info { flex: 1; }
.routine-name { font-size: 14px; font-weight: 500; }
.routine-meta { font-size: 11px; color: var(--text3); margin-top: 2px; display: flex; gap: 8px; }
.routine-header-btn {
  background: none; border: 1px solid var(--border); color: var(--text2);
  padding: 5px 8px; border-radius: 8px; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; gap: 4px;
}

/* ===== app.js で使用するクラス（ナビ・モーダル・ダッシュボード等） ===== */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--border);
  display: flex; padding: 6px 0 calc(6px + var(--safe-bottom)); z-index: 100;
}
.nav .nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; background: none; border: none; color: var(--text3);
  font-size: 10px; cursor: pointer; transition: color 0.2s;
}
.nav .nav-item.active { color: #fff; }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 10px; }

.modal-sheet {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%) translateY(100%);
  background: var(--card); border-radius: 20px 20px 0 0; width: 100%; max-width: 500px;
  max-height: 85vh; overflow-y: auto; padding: 0 16px calc(20px + var(--safe-bottom));
  z-index: 201; transition: transform 0.25s ease-out;
}
.modal-sheet.active { transform: translateX(-50%) translateY(0); }
.modal-overlay { opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-header { padding: 20px 0 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 18px; font-weight: 600; margin: 0; }
.modal-body { padding: 16px 0; }
.modal-body label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; }
.modal-body input[type="text"], .modal-body input[type="email"], .modal-body input[type="number"], .modal-body input[type="date"], .modal-body input[type="time"], .modal-body select { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 15px; margin-top: 4px; }
.modal-footer { padding: 16px 0 20px; display: flex; gap: 10px; }
.modal-footer .btn-primary { flex: 2; }
.modal-footer .btn-secondary { flex: 1; }

.summary-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.summary-card { flex: 1; min-width: 80px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; text-align: center; }
.summary-num { font-size: 22px; font-weight: 700; display: block; }
.summary-label { font-size: 11px; color: var(--text3); margin-top: 4px; }

.project-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.project-card:active { background: var(--card2); }

/* Kanban Board */
.kanban-proj-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
.kanban-proj-tabs::-webkit-scrollbar { display: none; }
.kanban-proj-tab { white-space: nowrap; padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: var(--card); color: var(--text3); font-size: 12px; font-weight: 600; cursor: pointer; }
.kanban-proj-tab.active { background: var(--card2); }

.kanban-board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 8px; -webkit-overflow-scrolling: touch; min-height: 300px; }
.kanban-board::-webkit-scrollbar { display: none; }
.kanban-column { flex: 0 0 260px; min-width: 260px; background: var(--card2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.kanban-column-header { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px 10px; font-size: 13px; font-weight: 600; color: var(--text2); }
.kanban-count { background: var(--border); color: var(--text3); border-radius: 10px; padding: 1px 8px; font-size: 11px; }
.kanban-cards { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.kanban-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.kanban-card:active { background: var(--bg); }
.kanban-card-title { font-size: 13px; color: var(--text1); line-height: 1.4; margin-bottom: 6px; }
.kanban-card-actions { display: flex; gap: 6px; justify-content: flex-end; }
.kanban-card-actions button { background: var(--card2); border: 1px solid var(--border); border-radius: 6px; color: var(--text3); padding: 3px 10px; font-size: 11px; cursor: pointer; }
.kanban-card-actions button:active { background: var(--border); }
.kanban-add-btn { width: 100%; padding: 8px; border: 1.5px dashed var(--border); border-radius: 8px; background: none; color: var(--text3); font-size: 12px; cursor: pointer; margin-top: 4px; }
.kanban-add-btn:active { background: var(--card); }
.kanban-progress { margin-top: 16px; padding: 12px; background: var(--card); border-radius: 10px; border: 1px solid var(--border); }

@media (max-width: 768px) {
  .kanban-column { flex: 0 0 220px; min-width: 220px; }
}

.period-section { margin-bottom: 20px; }
.period-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.period-title { font-size: 15px; font-weight: 600; }
.period-time { font-size: 11px; color: var(--text3); }
.period-stats { font-size: 11px; color: var(--text3); margin-left: auto; }
.period-progress { width: 40px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.period-progress-bar { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.3s; }
.period-cards { min-height: 20px; }

.todo-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 10px; transition: all 0.15s;
}
.todo-card.done { opacity: 0.7; }
.todo-card.dragging { opacity: 0.5; }
.todo-card-left { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.todo-card-content { flex: 1; min-width: 0; }
.todo-card-text { font-size: 15px; font-weight: 500; display: block; }
.todo-card-meta { font-size: 12px; color: var(--text3); margin-top: 2px; }
.todo-card-actions { display: flex; gap: 4px; }
.todo-card-check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--border); background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.todo-card-handle { cursor: grab; color: var(--text3); padding: 4px; }
.todo-card.auto-card { border-style: dashed; }
.todo-card.event-card { border-left: 3px solid var(--gcal); }
.badge-task { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(245,158,11,0.2); color: var(--yellow); }
.badge-overdue { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(239,68,68,0.2); color: var(--red); }
.badge-event { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(66,133,244,0.2); color: var(--gcal); }
.badge-routine { font-size: 10px; padding: 2px 6px; border-radius: 6px; background: rgba(167,139,250,0.2); color: #a78bfa; }

.filter-bar { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-btn { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: transparent; color: var(--text2); font-size: 13px; cursor: pointer; transition: all 0.2s; }
.filter-btn.active { background: #fff; border-color: #fff; color: #000; }

.task-list { }
.task-item.done { opacity: 0.6; }
.task-item.done .task-text { text-decoration: line-through; }
.task-check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--border); background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.task-content { flex: 1; min-width: 0; }
.task-text { font-size: 15px; font-weight: 500; display: block; }
.priority-high { color: var(--red); }
.priority-medium { color: var(--yellow); }
.priority-low { color: var(--green); }

.search-bar { margin-bottom: 14px; }
.search-bar input { width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 15px; }

.client-list { }
.client-avatar { width: 40px; height: 40px; border-radius: 50%; background: #333; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; flex-shrink: 0; }
.client-detail { font-size: 12px; color: var(--text3); margin-top: 2px; display: block; }
.client-status { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.status-active { background: rgba(34,197,94,0.2); color: var(--green); }
.status-inactive { background: rgba(107,114,128,0.2); color: var(--text3); }

/* Calendar view switcher */
.cal-view-switcher {
  display: flex; gap: 2px; background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px; margin-bottom: 16px;
}
.cal-view-switcher .cal-view-btn {
  flex: 1; padding: 8px 0; border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--text3); transition: all 0.2s; text-align: center;
}
.cal-view-switcher .cal-view-btn.active { background: #fff; color: #000; }

/* Calendar navigation */
.cal-nav-btn {
  background: none; border: 1px solid var(--border); color: var(--text);
  font-size: 18px; padding: 6px 12px; cursor: pointer; border-radius: 8px;
  transition: background 0.2s;
}
.cal-nav-btn:active { background: var(--card2); }
.cal-day-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.cal-day-title { font-size: 18px; font-weight: 700; }

/* Day view - all day events */
.cal-allday { margin-bottom: 12px; padding: 10px; background: var(--card); border-radius: 12px; border: 1px solid var(--border); }
.cal-allday-label { font-size: 11px; color: var(--text3); margin-bottom: 6px; display: block; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.cal-allday-event {
  background: var(--card2); border-radius: 8px; padding: 8px 12px;
  margin-bottom: 4px; font-size: 13px; cursor: pointer;
  border-left: 3px solid var(--yellow); transition: background 0.15s;
}
.cal-allday-event:active { background: var(--border); }
.cal-allday-event.gcal-event { border-left-color: var(--gcal); }

/* Day view - hour grid */
.cal-day-grid { background: var(--card); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.cal-hour-row { display: flex; min-height: 56px; border-top: 1px solid var(--border); }
.cal-hour-row:first-child { border-top: none; }
.cal-hour-label {
  width: 48px; font-size: 11px; color: var(--text3); text-align: right;
  padding: 8px 8px 0 0; flex-shrink: 0; font-weight: 500;
}
.cal-hour-content { flex: 1; padding: 4px 8px; position: relative; }
.cal-hour-event {
  background: var(--card2); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0; padding: 8px 12px; margin-bottom: 3px;
  font-size: 13px; cursor: pointer; transition: background 0.15s;
}
.cal-hour-event:active { background: var(--border); }
.cal-hour-event .ev-title { font-weight: 500; }
.cal-hour-event .ev-time { font-size: 11px; color: var(--text3); }
.cal-hour-event .cal-event-dur { font-size: 11px; color: var(--text3); font-weight: normal; }
.cal-hour-event.gcal-event { border-left-color: var(--gcal); }

/* Week view */
.cal-week-grid { display: flex; flex-direction: column; background: var(--card); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.cal-week-header { display: flex; border-bottom: 2px solid var(--border); }
.cal-week-time-col { width: 42px; flex-shrink: 0; font-size: 10px; color: var(--text3); padding: 4px 2px; text-align: right; }
.cal-week-day-col {
  flex: 1; text-align: center; padding: 8px 2px; cursor: pointer;
  border-left: 1px solid var(--border); transition: background 0.15s;
}
.cal-week-day-col:active { background: var(--card2); }
.cal-week-day-col.today { background: rgba(255,255,255,0.06); }
.cal-week-day-name { display: block; font-size: 10px; color: var(--text3); font-weight: 600; text-transform: uppercase; }
.cal-week-day-num {
  display: block; font-size: 16px; font-weight: 700; margin-top: 2px; color: var(--text);
}
.cal-week-day-col.today .cal-week-day-num {
  background: #fff; color: #000; border-radius: 50%;
  width: 28px; height: 28px; line-height: 28px; margin: 4px auto 0;
}
.cal-week-row { display: flex; min-height: 44px; border-bottom: 1px solid var(--border); }
.cal-week-row:last-child { border-bottom: none; }
.cal-week-row .cal-week-time-col { padding: 4px 2px; text-align: right; line-height: 44px; }
.cal-week-row .cal-week-day-col { padding: 2px; border-left: 1px solid var(--border); }
.cal-week-cell { min-height: 44px; padding: 1px; position: relative; cursor: pointer; }
.cal-week-event {
  background: rgba(255,255,255,0.08); border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0; padding: 2px 4px; margin-bottom: 1px;
  font-size: 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  cursor: pointer; transition: background 0.15s;
}
.cal-week-event:active { background: rgba(255,255,255,0.15); }
.cal-week-event.gcal-event { border-left-color: var(--gcal); }

/* Month view */
.cal-month-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.cal-month-title { font-size: 18px; font-weight: 700; }
.cal-grid { display: flex; flex-direction: column; gap: 8px; }
.cal-row {
  display: flex; background: var(--card); border-radius: 10px;
  border: 1px solid var(--border); overflow: hidden;
}
.cal-header-row { background: transparent; border: none; margin-bottom: -4px; }
.cal-cell {
  flex: 1; min-height: 50px; padding: 6px 4px; text-align: center;
  cursor: pointer; border-right: 1px solid var(--border);
  font-size: 13px; transition: background 0.15s;
}
.cal-cell:last-child { border-right: none; }
.cal-header-row .cal-cell { border-right: none; }
.cal-cell:active { background: var(--card2); }
.cal-cell.empty { background: var(--bg); cursor: default; opacity: 0.3; }
.cal-cell.today {
  background: rgba(255,255,255,0.08);
}
.cal-cell.today .cal-day-num {
  background: #fff; color: #000; border-radius: 50%;
  width: 28px; height: 28px; line-height: 28px; display: inline-block;
  font-weight: 700;
}
.cal-day-num { font-weight: 500; display: inline-block; }
.cal-dot { display: block; margin-top: 2px; font-size: 6px; color: var(--gcal); letter-spacing: 2px; }
.cal-day-header-cell { font-size: 11px; color: var(--text3); font-weight: 600; min-height: auto !important; padding: 8px 4px !important; text-transform: uppercase; letter-spacing: 0.5px; }

.event-item { display: flex; align-items: center; gap: 12px; }
.event-date-badge { flex-shrink: 0; width: 44px; text-align: center; }
.event-month { font-size: 11px; color: var(--text3); }
.event-info { flex: 1; min-width: 0; }
.event-info .event-title { display: block; font-weight: 500; }
.event-info .event-time { font-size: 12px; color: var(--text3); }
.event-item.gcal-event .event-title::before { content: ''; }

.icon-btn-sm { background: none; border: none; padding: 4px; cursor: pointer; font-size: 16px; opacity: 0.8; }
.icon-btn-sm:hover { opacity: 1; }
.drag-over { outline: 2px dashed #fff; outline-offset: 2px; border-radius: 12px; }
.touch-ghost { pointer-events: none; }
.gcal-note { margin-top: 8px; font-size: 12px; color: var(--text3); line-height: 1.5; display: flex; align-items: center; gap: 4px; }
.gcal-note code { background: var(--card2); padding: 1px 4px; border-radius: 4px; font-size: 11px; }

/* SVG icons in nav/sidebar */
.nav-icon { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; }
.nav-icon svg { width: 22px; height: 22px; }
.sidebar-icon { display: flex; align-items: center; justify-content: center; }
.sidebar-icon svg { width: 20px; height: 20px; }
.section-title { display: flex; align-items: center; gap: 6px; }
.section-title svg { flex-shrink: 0; }
.header-right svg { flex-shrink: 0; }

/* Wake-up button */
.wake-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 36px; border-radius: 14px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid var(--border); color: var(--text);
  font-size: 16px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.wake-btn svg { color: var(--yellow); }
.wake-btn:active { transform: scale(0.96); border-color: var(--yellow); }

/* Wake-up recorded state */
.wake-recorded {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 14px; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  animation: wakeIn 0.4s ease-out;
}
.wake-icon-done { display: flex; color: var(--yellow); }
.wake-time-display { font-size: 22px; font-weight: 700; color: #fff; letter-spacing: 1px; }
.wake-label-done { font-size: 12px; color: var(--text3); }
@keyframes wakeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Sync indicator in header */
.sync-indicator {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text3); cursor: default;
  padding: 4px 8px; border-radius: 6px;
}
.sync-indicator.done { cursor: pointer; }
.sync-indicator.done:active { background: var(--card2); }
.sync-indicator.syncing { color: var(--yellow); }
.sync-indicator.syncing svg { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Modal h2 with icon */
.modal-header h2 { display: flex; align-items: center; gap: 8px; }
.modal-header h2 svg { flex-shrink: 0; }

/* ===== Sidebar (hidden on mobile, shown on PC) ===== */
.sidebar { display: none; }
.app-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ===== Desktop Layout (768px+) ===== */
@media (min-width: 768px) {
  .app { flex-direction: row; }

  .sidebar {
    display: flex; flex-direction: column;
    width: 220px; min-width: 220px;
    background: var(--card); border-right: 1px solid var(--border);
    height: 100vh; height: 100dvh; position: sticky; top: 0;
    z-index: 50;
  }
  .sidebar-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-brand h1 {
    font-size: 18px; font-weight: 700; color: #fff;
    margin: 0;
  }
  .sidebar-sync {
    display: block; font-size: 11px; color: var(--green);
    margin-top: 4px;
  }
  .sidebar-nav {
    flex: 1; padding: 12px 8px; display: flex;
    flex-direction: column; gap: 2px; overflow-y: auto;
  }
  .sidebar-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: 10px;
    background: none; border: none; color: var(--text3);
    font-size: 14px; cursor: pointer; transition: all 0.15s;
    text-align: left; width: 100%;
  }
  .sidebar-item:hover { background: var(--card2); color: var(--text); }
  .sidebar-item.active { background: rgba(255,255,255,0.1); color: #fff; font-weight: 600; }
  .sidebar-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
  .sidebar-label { font-size: 14px; }
  .sidebar-bottom {
    padding: 8px; border-top: 1px solid var(--border);
  }

  /* Hide mobile bottom nav on desktop */
  .mobile-nav { display: none !important; }

  /* Adjust main content - no bottom padding needed */
  .main {
    padding: 24px 32px;
  }

  /* Reposition FAB for desktop */
  .fab {
    bottom: 32px; right: 32px;
  }

  /* Wider modal on desktop */
  .modal-sheet {
    max-width: 560px;
    border-radius: 20px;
    bottom: auto; top: 50%; left: 50%;
    transform: translate(-50%, -50%) translateY(20px);
    max-height: 80vh;
  }
  .modal-sheet.active {
    transform: translate(-50%, -50%) translateY(0);
  }

  /* Header adjustments */
  .header {
    padding: 14px 32px;
    position: sticky; top: 0;
  }

  /* Calendar grid cells bigger on desktop */
  .cal-cell { min-height: 70px; padding: 8px; }
  .cal-hour-row { min-height: 64px; }

  /* Stats grid can be wider */
  .stats { grid-template-columns: repeat(3, 1fr); }
  .finance-summary { grid-template-columns: repeat(3, 1fr); }

  /* Wider cards */
  .card, .task-item, .client-card, .todo-card, .tb-card, .routine-item, .finance-item {
    max-width: 100%;
  }
}
