:root {
  --accent: #FF2D55;
  --accent-light: rgba(255, 45, 85, 0.12);
  --bg-page: #F6F7FB;
  --bg-card: #FFFFFF;
  --divider: #ECEEF3;
  --text-primary: #141414;
  --text-secondary: #626466;
  --text-tertiary: #8E9096;
  --row-height: 64px;
  --card-radius: 6px;
  --card-font-size: 11px;
  --time-col-w: 36px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
}

#bg-layer, #bg-mask {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

#bg-layer {
  background-size: cover;
  background-position: center;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: env(safe-area-inset-top, 0px);
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 6px 16px;
  flex-shrink: 0;
}

.header-left {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.chevron-icon {
  width: 18px;
  height: 18px;
  fill: var(--text-secondary);
}

.pill-btn {
  border: none;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 4px;
  cursor: pointer;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:active {
  background: rgba(0, 0, 0, 0.06);
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: var(--text-primary);
}

/* Weekday Header */
.weekday-header {
  display: flex;
  align-items: center;
  padding-right: 3px;
  padding-bottom: 6px;
  flex-shrink: 0;
}

.month-cell {
  width: var(--time-col-w);
  text-align: center;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

.day-header-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.day-short {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.day-header-cell.today .day-short {
  font-weight: 700;
  color: var(--text-primary);
}

.day-date-badge {
  font-size: 10.5px;
  color: var(--text-secondary);
  padding: 1px 5px;
  border-radius: 5px;
}

.day-header-cell.today .day-date-badge {
  background: #2C2C2E;
  color: #FFFFFF;
  font-weight: 700;
}

.day-header-cell.adjusted .day-date-badge {
  color: var(--accent);
  font-weight: 700;
}

/* Scrollable Grid */
.grid-viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.grid-container {
  display: flex;
  width: 100%;
  padding-right: 3px;
}

.time-col {
  width: var(--time-col-w);
  flex-shrink: 0;
}

.time-node-cell {
  height: var(--row-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.time-node-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.time-node-hm {
  font-size: 8px;
  line-height: 1.15;
  color: var(--text-tertiary);
}

.days-grid {
  flex: 1;
  display: flex;
  position: relative;
}

.day-col {
  flex: 1;
  position: relative;
  border-left: 0.5px solid rgba(229, 231, 238, 0.55);
}

.empty-slot {
  height: var(--row-height);
  border-bottom: 0.5px solid rgba(229, 231, 238, 0.55);
  cursor: pointer;
}

/* Course Bubble */
.course-card {
  position: absolute;
  left: 1.5px;
  right: 1.5px;
  border-radius: var(--card-radius);
  padding: 3.5px 3.5px;
  color: #FFFFFF;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  z-index: 2;
  transition: transform 0.1s ease;
}

.course-card:active {
  transform: scale(0.97);
}

.course-card.inactive {
  background: rgba(213, 215, 222, 0.75) !important;
  color: #777982;
}

.course-name {
  font-size: var(--card-font-size);
  line-height: 1.22;
  font-weight: 700;
  word-break: break-all;
}

.course-room {
  font-size: calc(var(--card-font-size) - 1px);
  line-height: 1.18;
  opacity: 0.94;
  margin-top: 2px;
  word-break: break-all;
}

.course-teacher {
  font-size: calc(var(--card-font-size) - 1px);
  line-height: 1.15;
  opacity: 0.9;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-tag {
  margin-top: 2px;
  text-align: center;
  font-size: 8.5px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 3px;
  padding: 1px 0;
}

/* Modals & Bottom Sheets */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.fullscreen {
  align-items: stretch;
  background: var(--bg-page);
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.full-page {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  padding-top: env(safe-area-inset-top, 0px);
}

.page-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--divider);
  flex-shrink: 0;
}

.page-bar-title {
  font-size: 17px;
  font-weight: 700;
}

.page-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-group {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 14px 16px;
}

.section-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 4px 0 4px 6px;
}

.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--divider);
  gap: 10px;
}

.row-item:last-child {
  border-bottom: none;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-outline {
  background: transparent;
  border: 1px solid #DCDDE2;
  color: var(--text-primary);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(255, 45, 85, 0.35);
  color: var(--accent);
}

.btn-text {
  background: transparent;
  color: var(--accent);
  border: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
}

.input {
  width: 100%;
  border: 1px solid #E0E1E6;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  background: #FFFFFF;
  color: var(--text-primary);
  user-select: text;
}

.input:focus {
  border-color: var(--accent);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.week-chip {
  height: 36px;
  border-radius: 8px;
  background: #F4F5F8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border: 1px solid transparent;
}

.week-chip.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
  border-color: var(--accent);
}

.week-chip.current {
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 700;
}

.color-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 14px;
}

.method-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 15px;
  display: flex;
  gap: 12px;
  cursor: pointer;
}

.method-card:active {
  opacity: 0.85;
}

.method-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 6px;
  border-radius: 5px;
  margin-left: 6px;
}

.switch {
  appearance: none;
  width: 44px;
  height: 26px;
  background: #D6D8DF;
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch:checked {
  background: var(--accent);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}

.switch:checked::after {
  transform: translateX(18px);
}

.slider {
  width: 100%;
  accent-color: var(--accent);
}

.toast {
  position: fixed;
  bottom: calc(36px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.86);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 200;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}
