* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --ink: #2a3b2e;
  --muted: #8a938b;
  --accent: #6b8e6e;
  --accent-soft: #e8efe8;
  --warn: #c47a5c;
  --border: #e5e0d5;
  --pending: #b68f38;
  --pending-soft: #f6eed6;
  --private: #8a6ba8;
  --private-soft: #eee5f5;
  --done-soft: #ece9e0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  min-height: 100vh;
  padding: 24px 16px 80px;
  line-height: 1.5;
}

.wrap { max-width: 640px; margin: 0 auto; }

header { padding: 24px 0 16px; text-align: center; }
header h1 { font-size: 22px; font-weight: 600; letter-spacing: 0.02em; }
header p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.date-group { margin-top: 28px; }
.date-title {
  font-size: 14px; font-weight: 600; color: var(--accent);
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  display: flex; align-items: baseline; gap: 8px;
}
.date-title .weekday { color: var(--muted); font-weight: 400; font-size: 12px; }
.date-title .tag {
  margin-left: auto;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.class {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.class.cancelled { opacity: 0.55; background: #f5f3ee; }

.class .time {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  min-width: 54px;
}
.type {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  flex-shrink: 0;
}
.type.group { color: var(--accent); background: var(--accent-soft); }
.type.private { color: var(--private); background: var(--private-soft); }
.teacher,
.room {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

.badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
  flex-shrink: 0;
  margin-left: auto;
}
.badge.pending { color: var(--pending); background: var(--pending-soft); }
.badge.open { color: var(--accent); background: var(--accent-soft); }
.badge.done { color: var(--muted); background: var(--done-soft); }
.badge.cancelled { color: var(--warn); background: #f1e8dd; }

.view-toggle {
  display: inline-flex;
  margin: 4px auto 0;
  padding: 3px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  gap: 2px;
}
.wrap > .view-toggle { display: flex; width: fit-content; }
.view-toggle button {
  font: inherit;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 6px 18px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.view-toggle button.active {
  color: #fff;
  background: var(--accent);
}

.calendar {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.cal-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.cal-header {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  z-index: 2;
}
.cal-hcorner {
  flex: 0 0 44px;
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 3;
  border-right: 1px solid var(--border);
}
.cal-hdays {
  display: flex;
  flex: 1;
}
.cal-dhead {
  flex: 0 0 33.333%;
  min-width: 120px;
  padding: 10px 8px;
  text-align: center;
  border-left: 1px solid var(--border);
}
.cal-dhead:first-child { border-left: 0; }
.cal-dhead-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.cal-dhead.is-today .cal-dhead-date { color: var(--accent); }
.cal-dhead-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}
.cal-dhead .tag {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
}

.cal-body {
  display: flex;
  position: relative;
}
.cal-hours {
  flex: 0 0 44px;
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--card);
  border-right: 1px solid var(--border);
}
.cal-hour {
  position: absolute;
  right: 6px;
  font-size: 10px;
  color: var(--muted);
  transform: translateY(-50%);
  background: var(--card);
  padding: 0 2px;
}
.cal-days {
  display: flex;
  flex: 1;
}
.cal-dcol {
  flex: 0 0 33.333%;
  min-width: 120px;
  position: relative;
  border-left: 1px solid var(--border);
}
.cal-dcol:first-child { border-left: 0; }
.cal-dcol.is-today { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }

.cal-gridline {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
  opacity: 0.5;
}
.cal-now {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--warn);
  z-index: 5;
}
.cal-now::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
}

.cal-slot {
  position: absolute;
  left: 3px;
  right: 3px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 1px;
  z-index: 4;
}
.cal-slot.private {
  background: var(--private-soft);
  color: var(--private);
  border-left-color: var(--private);
}
.cal-slot.pending {
  background: var(--pending-soft);
  color: var(--pending);
  border-left-color: var(--pending);
}
.cal-slot.done {
  background: var(--done-soft);
  color: var(--muted);
  border-left-color: var(--muted);
}
.cal-slot.cancelled {
  opacity: 0.5;
  text-decoration: line-through;
}
.cal-slot-time {
  font-weight: 600;
  font-size: 11px;
}
.cal-slot-type {
  font-size: 10px;
  opacity: 0.85;
}
.cal-slot-status {
  font-size: 10px;
  opacity: 0.75;
  margin-top: auto;
}

.empty, .loading { color: var(--muted); padding: 40px 0; text-align: center; font-size: 14px; }

.refresh-note {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  margin-top: 32px;
}
