:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --background: #f1f5f9;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #dbe3ee;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    "Yu Gothic",
    "Meiryo",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* 読み込み画面 */
.loading-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  background: #f8fafc;
}

.loading-box {
  text-align: center;
  color: var(--muted);
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  border: 4px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 認証画面 */
.auth-screen {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
  background: linear-gradient(135deg, #dbeafe, #f8fafc 48%, #dcfce7);
}

.auth-card {
  width: 100%;
  max-width: 480px;
  padding: 32px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.auth-header {
  margin-bottom: 24px;
  text-align: center;
}

.auth-header h1 {
  margin: 0 0 10px;
  font-size: 1.7rem;
}

.auth-header p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 24px;
  padding: 4px;
  background: #eef2f7;
  border-radius: 10px;
}

.auth-tab {
  padding: 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.auth-tab.active {
  color: var(--primary-dark);
  font-weight: 700;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.auth-form {
  display: grid;
  gap: 9px;
}

.auth-form label,
.field label {
  margin-top: 7px;
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-form input,
.field input,
.field select {
  width: 100%;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.auth-form input:focus,
.field input:focus,
.field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-message {
  min-height: 1.5em;
  margin: 16px 0 0;
  text-align: center;
  color: var(--danger);
  font-size: 0.9rem;
}

.form-message.success {
  color: var(--success);
}

/* 共通ボタン */
.primary-button,
.secondary-button,
.cancel-button,
.delete-button,
.icon-button,
.filter-button {
  transition: 0.2s ease;
}

.primary-button {
  padding: 11px 16px;
  color: white;
  font-weight: 700;
  background: var(--primary);
  border: 0;
  border-radius: 8px;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  padding: 10px 14px;
  color: var(--primary-dark);
  font-weight: 700;
  background: white;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
}

.secondary-button:hover {
  background: #eff6ff;
}

.cancel-button {
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 700;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.cancel-button:hover {
  background: #e2e8f0;
}

.delete-button {
  padding: 7px 10px;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--danger-light);
  border: 0;
  border-radius: 7px;
}

.delete-button:hover {
  background: #fecaca;
}

.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--primary-dark);
  font-size: 1.2rem;
  background: #eff6ff;
  border: 0;
  border-radius: 8px;
  place-items: center;
}

.icon-button:hover {
  background: #dbeafe;
}

/* アプリ画面 */
.app-header {
  color: white;
  background: linear-gradient(120deg, #1d4ed8, #2563eb);
  box-shadow: 0 2px 10px rgba(30, 64, 175, 0.25);
}

.header-inner {
  display: flex;
  max-width: 1440px;
  min-height: 76px;
  margin: 0 auto;
  padding: 14px 24px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-inner h1 {
  margin: 0;
  font-size: 1.35rem;
}

.current-user-email {
  margin: 5px 0 0;
  font-size: 0.85rem;
}

.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(500px, 1.4fr);
  gap: 24px;
  align-items: start;
}

.panel {
  padding: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  margin-bottom: 20px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-header h2 {
  margin: 0 0 5px;
  font-size: 1.25rem;
}

.panel-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.add-form {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.field {
  flex: 1;
  min-width: 0;
}

.field-wide {
  flex: 2;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.todo-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-button {
  padding: 7px 12px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  background: #f1f5f9;
  border: 0;
  border-radius: 999px;
}

.filter-button:hover {
  background: #e2e8f0;
}

.filter-button.active {
  color: white;
  background: var(--primary);
}

.summary-text {
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.todo-list,
.schedule-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.todo-item,
.schedule-item {
  display: flex;
  padding: 13px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.todo-item.completed {
  background: #f8fafc;
}

.todo-item.completed .todo-title {
  color: var(--muted);
  text-decoration: line-through;
}

.todo-main {
  display: flex;
  min-width: 0;
  gap: 10px;
  align-items: flex-start;
}

.todo-checkbox {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--success);
  cursor: pointer;
}

.todo-content,
.schedule-content {
  min-width: 0;
}

.todo-title,
.schedule-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.todo-meta,
.schedule-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.8rem;
}

.todo-description,
.schedule-description {
  margin: 7px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 0.85rem;
  line-height: 1.5;
}

.priority-badge,
.date-badge,
.time-badge {
  display: inline-flex;
  padding: 3px 7px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
}

.priority-high {
  color: #b91c1c;
  background: #fee2e2;
}

.priority-medium {
  color: #b45309;
  background: #fef3c7;
}

.priority-low {
  color: #166534;
  background: #dcfce7;
}

.date-badge {
  color: #1d4ed8;
  background: #dbeafe;
}

.time-badge {
  color: #6d28d9;
  background: #ede9fe;
}

.todo-actions,
.schedule-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.edit-button {
  padding: 7px 10px;
  color: #1d4ed8;
  font-size: 0.85rem;
  font-weight: 700;
  background: #dbeafe;
  border: 0;
  border-radius: 7px;
}

.edit-button:hover {
  background: #bfdbfe;
}

.empty-message {
  margin: 16px 0 0;
  padding: 18px;
  color: var(--muted);
  text-align: center;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  font-size: 0.9rem;
}

/* カレンダー */
.calendar-title-row {
  align-items: center;
}

.calendar-navigation {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-navigation strong {
  min-width: 110px;
  text-align: center;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  overflow: hidden;
}

.calendar-weekdays div {
  padding: 10px 2px;
  color: var(--muted);
  text-align: center;
  background: #f8fafc;
  border-right: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 700;
}

.calendar-weekdays div:last-child {
  border-right: 0;
}

.calendar-weekdays .sunday {
  color: #dc2626;
}

.calendar-weekdays .saturday {
  color: #2563eb;
}

.calendar-grid {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
}

.calendar-day {
  position: relative;
  display: flex;
  min-height: 84px;
  padding: 7px;
  background: white;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day:nth-last-child(-n + 7) {
  border-bottom: 0;
}

.calendar-day:hover:not(.other-month) {
  background: #eff6ff;
}

.calendar-day.other-month {
  color: #cbd5e1;
  background: #f8fafc;
  cursor: default;
}

.calendar-day.selected {
  background: #dbeafe;
  box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar-day.today .day-number {
  display: grid;
  width: 25px;
  height: 25px;
  color: white;
  background: var(--primary);
  border-radius: 50%;
  place-items: center;
}

.day-number {
  font-size: 0.85rem;
  font-weight: 700;
}

.calendar-day.sunday .day-number {
  color: #dc2626;
}

.calendar-day.saturday .day-number {
  color: #2563eb;
}

.calendar-day.today .day-number {
  color: white;
}

.calendar-indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}

.calendar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.calendar-dot.schedule {
  background: #7c3aed;
}

.calendar-dot.todo {
  background: #f59e0b;
}

.calendar-count {
  color: var(--muted);
  font-size: 0.7rem;
}

.selected-date-area {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.selected-date-area > h3,
.schedule-list-header h3 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.schedule-form {
  margin-bottom: 18px;
}

/* トースト */
.toast {
  position: fixed;
  z-index: 200;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 16px;
  color: white;
  background: #1e293b;
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1000px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .auth-screen {
    padding: 16px;
  }

  .auth-card {
    padding: 24px 18px;
  }

  .header-inner {
    padding: 14px 16px;
  }

  .app-main {
    padding: 16px;
  }

  .panel {
    padding: 16px;
  }

  .header-inner h1 {
    font-size: 1.1rem;
  }

  .current-user-email {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .form-row {
    flex-direction: column;
  }

  .calendar-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-day {
    min-height: 65px;
    padding: 5px;
  }

  .calendar-count {
    font-size: 0.62rem;
  }

  .todo-item,
  .schedule-item {
    flex-direction: column;
  }

  .todo-actions,
  .schedule-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
/* クマのキャラクター */
.mascot-logo {
  display: grid;
  width: 78px;
  height: 78px;
  margin: 0 auto 12px;
  font-size: 3.5rem;
  background: #fef3c7;
  border: 3px solid #f59e0b;
  border-radius: 50%;
  box-shadow: 0 6px 14px rgba(217, 119, 6, 0.18);
  place-items: center;
  animation: mascot-float 2.6s ease-in-out infinite;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-mascot {
  display: grid;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  font-size: 1.9rem;
  background: #fef3c7;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  place-items: center;
}

@keyframes mascot-float {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }

  50% {
    transform: translateY(-6px) rotate(3deg);
  }
}

@media (max-width: 640px) {
  .header-mascot {
    width: 38px;
    height: 38px;
    font-size: 1.5rem;
  }
}