:root {
  --sky: #dff5ff;
  --sky-dark: #a9ddf3;
  --blue: #4f9fc5;
  --navy: #31576d;
  --yellow: #fff2a5;
  --pink: #ffdbe9;
  --mint: #d9f7ea;
  --white: #ffffff;
  --line: #d6e8f1;
  --text: #334d5c;
  --danger: #df5e6f;
  --shadow: 0 8px 24px rgba(72, 135, 165, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--sky);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* 認証画面 */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 10% 20%, #ffffffa8 0 55px, transparent 56px),
    radial-gradient(circle at 90% 80%, #ffdbe9b6 0 70px, transparent 71px),
    var(--sky);
}

.auth-card {
  width: min(100%, 430px);
  padding: 34px;
  text-align: center;
  border: 3px solid #fff;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-card .logo {
  font-size: 58px;
}

.auth-card h1 {
  margin: 4px 0 8px;
  color: var(--blue);
}

.auth-card p {
  line-height: 1.7;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0 18px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: #edf8fc;
}

.auth-tab.active {
  color: white;
  background: var(--blue);
}

.auth-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.auth-form label,
.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: bold;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: white;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px #cceefa;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  padding: 11px 16px;
  border: 0;
  border-radius: 11px;
  font-weight: bold;
}

.primary-btn {
  color: white;
  background: var(--blue);
}

.secondary-btn {
  color: var(--navy);
  background: #e8f7fc;
}

.danger-btn {
  color: white;
  background: var(--danger);
}

.message {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

/* アプリ共通 */
.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px 24px;
  border-bottom: 2px solid #fff;
  background: rgba(223, 245, 255, 0.95);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  margin: 0;
  color: var(--blue);
  font-size: 22px;
}

.topbar p {
  margin: 4px 0 0;
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn,
.logout-btn {
  border: 0;
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 8px #8fc1d444;
}

.icon-btn {
  width: 42px;
  height: 42px;
  font-size: 24px;
}

.logout-btn {
  padding: 10px 13px;
  color: var(--text);
}

.layout {
  display: flex;
  min-height: calc(100vh - 72px);
}

.sidebar {
  position: sticky;
  top: 72px;
  width: 210px;
  height: calc(100vh - 72px);
  padding: 15px;
  border-right: 2px solid white;
  background: #effaff;
}

.nav-btn {
  width: 100%;
  margin-bottom: 5px;
  padding: 11px;
  text-align: left;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
}

.nav-btn:hover,
.nav-btn.active {
  color: var(--navy);
  background: white;
  box-shadow: 0 3px 10px #a8d1e440;
}

.content {
  width: 100%;
  max-width: 1400px;
  padding: 24px;
  margin: 0 auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.page-title h2 {
  margin: 0;
  color: var(--navy);
}

.page-title p {
  margin: 4px 0 0;
  font-size: 14px;
}

.card {
  padding: 18px;
  margin-bottom: 16px;
  border: 2px solid white;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 12px;
  color: var(--navy);
}

.grid-2,
.grid-3,
.stat-grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  padding: 16px;
  border-radius: 15px;
  background: #f2fbff;
}

.stat-card .number {
  margin-top: 7px;
  color: var(--blue);
  font-size: 25px;
  font-weight: bold;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  padding: 8px 13px;
  border: 0;
  border-radius: 99px;
  color: var(--text);
  background: #e9f7fc;
}

.tab-btn.active {
  color: white;
  background: var(--blue);
}

.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
}

.calendar-title {
  color: var(--navy);
  font-size: 18px;
  font-weight: bold;
}

.month-btn {
  padding: 6px 11px;
  border: 0;
  border-radius: 8px;
  background: #e9f7fc;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(80px, 1fr));
  overflow-x: auto;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.calendar-weekday,
.calendar-day {
  min-height: 105px;
  padding: 7px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: white;
}

.calendar-weekday {
  min-height: auto;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  background: #edfaff;
}

.calendar-day.empty {
  background: #f7fbfd;
}

.calendar-day.today {
  background: var(--yellow);
}

.day-number {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 4px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: bold;
}

.event-chip {
  overflow: hidden;
  padding: 3px 5px;
  margin: 2px 0;
  border-left: 4px solid;
  border-radius: 5px;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 11px;
  cursor: pointer;
}

.todo-marker {
  padding: 2px 4px;
  margin-top: 3px;
  border-radius: 4px;
  background: #d7f4ff;
  font-size: 10px;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
}

.list-table th,
.list-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.list-table th {
  color: var(--navy);
  background: #effaff;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 12px;
  background: var(--pink);
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px dashed var(--line);
}

.todo-item:last-child {
  border-bottom: 0;
}

.todo-item.done .todo-title {
  color: #9aaeb9;
  text-decoration: line-through;
}

.todo-main {
  flex: 1;
}

.todo-sub {
  margin-top: 3px;
  color: #78909d;
  font-size: 12px;
}

.delete-mini {
  padding: 5px 8px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: #e98591;
}

.timetable {
  width: 100%;
  min-width: 750px;
  border-collapse: collapse;
}

.timetable th,
.timetable td {
  padding: 9px;
  border: 1px solid var(--line);
  text-align: center;
}

.timetable th {
  background: #effaff;
}

.timetable td {
  height: 85px;
  background: white;
  cursor: pointer;
}

.class-box {
  padding: 7px;
  border-radius: 9px;
   background: #dff5ff;
  border-left: 5px solid var(--blue);
  text-align: left;
  font-size: 12px;
}

.class-box strong {
  display: block;
  margin-bottom: 4px;
  color: var(--navy);
}

.add-cell {
  color: #8eb7ca;
  font-size: 22px;
}

.work-shift {
  padding: 12px;
  margin: 8px 0;
  border-left: 5px solid #ff9ab8;
  border-radius: 10px;
  background: #fff3f7;
}

.note-card,
.dream-card,
.diary-card {
  padding: 14px;
  border-radius: 14px;
  background: #f5fcff;
}

.note-card h4,
.dream-card h4,
.diary-card h4 {
  margin: 0 0 8px;
  color: var(--navy);
}

.note-card p,
.dream-card p,
.diary-card p {
  white-space: pre-wrap;
  line-height: 1.7;
}

.dream-image,
.diary-image {
  width: 100%;
  max-height: 190px;
  margin-bottom: 10px;
  border-radius: 12px;
  object-fit: cover;
  background: #eaf8fc;
}

.bear-stage {
  padding: 25px;
  text-align: center;
  border-radius: 22px;
  background:
    radial-gradient(circle at 20% 15%, #ffffff 0 14px, transparent 15px),
    #fff6dc;
}

.bear {
  font-size: 130px;
  line-height: 1;
}

.bear-stage h3 {
  margin: 10px 0 5px;
  color: #896938;
}

.reward-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reward-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff6dc;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 15px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 73, 91, 0.35);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 620px);
  max-height: 90vh;
  padding: 25px;
  overflow-y: auto;
  border-radius: 20px;
  background: white;
  box-shadow: 0 15px 45px rgba(25, 69, 88, 0.3);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 13px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  background: #edf8fc;
}

.modal-card h3 {
  margin-top: 0;
  color: var(--navy);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  z-index: 30;
  right: 20px;
  bottom: 20px;
  max-width: 330px;
  padding: 13px 16px;
  border-radius: 12px;
  color: var(--navy);
  background: white;
  box-shadow: var(--shadow);
}

.mobile-nav {
  display: none;
}

.empty-state {
  padding: 20px;
  text-align: center;
  color: #75909e;
}

.small {
  color: #78909d;
  font-size: 12px;
}

@media (max-width: 800px) {
  .topbar {
    padding: 10px 14px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar p,
  .logout-btn {
    display: none;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 15px 12px 85px;
  }

  .grid-2,
  .grid-3,
  .stat-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .full {
    grid-column: auto;
  }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(62px, 1fr));
  }

  .calendar-day {
    min-height: 84px;
    padding: 4px;
  }

  .mobile-nav {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    justify-content: space-around;
    padding: 7px 3px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
  }

  .mobile-nav .nav-btn {
    display: grid;
    gap: 2px;
    width: auto;
    margin: 0;
    padding: 5px 8px;
    text-align: center;
    font-size: 19px;
  }

  .mobile-nav .nav-btn span {
    font-size: 9px;
  }

  .list-table {
    min-width: 620px;
  }

  .card {
    padding: 14px;
  }
}