:root {
  color-scheme: light;
  --bg: #F7FAFF;
  --bg-deep: #0066FF;
  --surface: #FFFFFF;
  --surface-solid: #FFFFFF;
  --surface-dark: #EAF2FF;
  --text: #0F172A;
  --text-muted: #64748B;
  --border: #D7E4F5;
  --primary: #0066FF;
  --primary-strong: #0052CC;
  --accent: #00A3FF;
  --accent-2: #EAF2FF;
  --success: #0F8F5F;
  --warning: #B7791F;
  --danger: #D92D20;
  --focus: #0066FF;
  --radius-sm: 8px;
  --radius-md: 8px;
  --radius-lg: 8px;
  --shadow-sm: none;
  --shadow-md: none;
  --c-nuclear: #0066FF;
  --c-stamping: #0EA5E9;
  --c-material: #2563EB;
  --c-heat: #4F46E5;
  --c-plastic: #0891B2;
  --c-default: #0066FF;
  font-family: "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  box-shadow: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(92px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(0, 166, 251, 0.35);
  outline-offset: 3px;
}

.orb {
  display: none;
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: var(--radius-lg);
  filter: blur(2px);
  opacity: 0.55;
}

.orb-one {
  width: 380px;
  height: 380px;
  left: -180px;
  top: 120px;
  background: transparent;
}

.orb-two {
  width: 440px;
  height: 440px;
  right: -220px;
  top: 40px;
  background: transparent;
}

.offline-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 80;
  padding: 10px 16px;
  color: #fff;
  text-align: center;
  background: var(--primary-strong);
  font-size: 13px;
}

.offline-bar.show {
  display: block;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  min-height: 190px;
  padding: clamp(22px, 4vw, 44px);
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.brand-block {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  max-width: 720px;
}

.brand-mark {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: var(--radius-md);
  background: var(--primary);
  box-shadow: none;
}

.brand-mark span {
  position: absolute;
  left: 14px;
  right: 14px;
  height: 5px;
  border-radius: var(--radius-sm);
  background: #fff;
}

.brand-mark span:nth-child(1) { top: 16px; }
.brand-mark span:nth-child(2) { top: 27px; background: #fff; }
.brand-mark span:nth-child(3) { top: 38px; width: 18px; right: auto; background: #fff; }

.eyebrow,
.section-kicker {
  display: block;
  margin: 0 0 8px;
  color: currentColor;
  opacity: 0.72;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hero h1 {
  margin-bottom: 12px;
  font-size: clamp(42px, 8vw, 82px);
  line-height: 0.92;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.65;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #B8D3FF;
  border-radius: var(--radius-md);
  background: #F0F6FF;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 800;
  backdrop-filter: none;
}

.status-pill.muted {
  color: var(--text-muted);
}

.control-deck {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 14px;
  width: min(760px, calc(100% - 20px));
  margin: -28px auto 22px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: var(--shadow-sm);
  backdrop-filter: none;
}

.round-button,
.ghost-button,
.text-button,
.icon-button {
  border: 0;
}

.round-button {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  color: #fff;
  background: var(--primary);
  font-size: 22px;
  transition: transform 160ms ease, background 160ms ease;
}

.round-button:active {
  transform: scale(0.94);
}

.week-center {
  min-width: 0;
  text-align: center;
}

.week-center .section-kicker {
  margin-bottom: 2px;
  color: var(--text-muted);
  opacity: 1;
}

.week-center strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: clamp(16px, 2vw, 22px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-banner {
  display: none;
  margin: 0 0 18px;
  padding: 14px 18px;
  color: #fff;
  border-radius: var(--radius-md);
  background: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
}

.live-banner.show {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.insight-rail {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 18px;
}

.focus-card,
.stat-card,
.ai-today-card,
.schedule-stage,
.modal {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: none;
}

.focus-card {
  padding: 24px;
  border-radius: var(--radius-lg);
}

.focus-card h2 {
  margin-bottom: 12px;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: 0;
}

.focus-card p {
  margin-bottom: 0;
  color: var(--text-muted);
  line-height: 1.7;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-card {
  min-height: 118px;
  padding: 18px;
  border-radius: var(--radius-md);
}

.stat-card.wide {
  grid-column: 1 / -1;
}

.stat-card span {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 750;
}

.stat-card strong {
  display: block;
  margin-top: 14px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.ai-today-card {
  display: none;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.ai-today-card.show {
  display: block;
}

.ai-today-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 12px;
}

.ai-today-header strong {
  display: block;
  font-size: 18px;
}

.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  color: var(--primary-strong);
  background: #EAF2FF;
  font-weight: 850;
}

.ai-today-body {
  padding: 4px 12px 14px;
}

.ai-plan-item,
.ai-today-item {
  display: grid;
  grid-template-columns: minmax(74px, 92px) minmax(0, 1fr);
  gap: 12px;
  padding: 13px 10px;
  border-top: 1px solid var(--border);
}

.ai-time {
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.ai-task {
  color: var(--text);
  font-weight: 800;
}

.ai-desc,
.ai-duration,
.ai-today-empty,
.ai-today-loading {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.ai-generate-btn {
  margin-top: 12px;
}

.ai-today-feedback {
  grid-column: 2;
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.ai-today-feedback button {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  color: var(--text);
  min-height: 32px;
  padding: 0 10px;
}

.ai-today-item.completed .ai-task {
  text-decoration: line-through;
  opacity: 0.55;
}

.schedule-stage {
  min-width: 0;
  padding: clamp(16px, 3vw, 24px);
  border-radius: var(--radius-lg);
}

.stage-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.stage-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.stage-header h2 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0;
}

.text-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  color: var(--primary-strong);
  background: #EAF2FF;
  font-weight: 850;
  white-space: nowrap;
}

.day-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 14px;
  transition: opacity 180ms ease, transform 180ms ease;
}

.day-list.slide-left {
  animation: slideLeft 240ms ease;
}

.day-list.slide-right {
  animation: slideRight 240ms ease;
}

@keyframes slideLeft {
  from { opacity: 0.45; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideRight {
  from { opacity: 0.45; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}

.day-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: none;
}

.day-card.today {
  border-color: var(--primary);
  box-shadow: none;
}

.day-card.no-course {
  background: #FAFCFF;
}

.day-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.day-name {
  display: block;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: 0;
}

.day-date {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 750;
}

.today-badge,
.course-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.today-badge + .course-count {
  margin-top: 6px;
}

.course-stack {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.course-item {
  position: relative;
  display: grid;
  grid-template-columns: 6px minmax(0, 1fr);
  min-height: 58px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  text-align: left;
  appearance: none;
  transition: transform 160ms ease, border-color 160ms ease;
}

.course-item:hover {
  transform: translateY(-2px);
  box-shadow: none;
}

.course-item:active {
  transform: translateY(0);
}

.course-item.live {
  border-color: var(--primary);
  box-shadow: none;
}

.color-bar {
  width: 6px;
  height: 100%;
}

.course-info {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
}

.course-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.period-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}

.course-name {
  display: block;
  min-width: 0;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-room {
  display: block;
  max-width: 96px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.course-note {
  display: block;
  max-width: 120px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.no-course-text,
.empty-week {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 160px;
  padding: 16px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.65;
}

.add-day-btn {
  min-height: 40px;
  border: 1px dashed #9EC2FF;
  border-radius: var(--radius-md);
  background: #F8FBFF;
  color: var(--primary-strong);
  font-weight: 850;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 70;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(420px, calc(100% - 28px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  box-shadow: none;
  transform: translateX(-50%);
  backdrop-filter: none;
}

.tab {
  min-height: 58px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 850;
}

.tab .icon {
  position: relative;
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
  font-weight: 950;
}

.tab.active {
  color: #fff;
  background: var(--primary);
}

.ai-badge {
  display: none;
  position: absolute;
  top: -5px;
  right: calc(50% - 24px);
  width: 9px;
  height: 9px;
  border-radius: 8px;
  background: var(--primary);
}

.ai-badge.show {
  display: block;
}

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 120;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  font-size: 14px;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.36);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  width: min(620px, 100%);
  max-height: min(86svh, 820px);
  overflow: auto;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  animation: sheetIn 220ms ease;
}

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(28px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-grip {
  width: 52px;
  height: 5px;
  margin: 0 auto 18px;
  border-radius: var(--radius-sm);
  background: #B8D3FF;
}

.modal h2 {
  margin-bottom: 20px;
  font-size: 28px;
  letter-spacing: 0;
}

.modal-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn-row button,
.full {
  min-height: 50px;
  border: 0;
  border-radius: var(--radius-md);
  padding: 0 16px;
  font-weight: 900;
}

.btn-row button {
  flex: 1;
}

.btn-save {
  background: var(--primary);
  color: #fff;
}

.btn-cancel {
  background: #EEF4FF;
  color: var(--text);
}

.btn-delete {
  background: #FFF1F0;
  color: var(--danger);
}

.btn-delete[style*="display:none"] {
  display: none !important;
}

.import-modal {
  width: min(760px, 100%);
}

.import-textarea {
  min-height: 180px;
  line-height: 1.65;
}

.import-preview,
.course-action-preview {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #F7FAFF;
  color: var(--text-muted);
  line-height: 1.6;
}

.preview-summary {
  display: grid;
  gap: 3px;
  color: var(--text);
}

.preview-summary strong {
  font-size: 16px;
}

.preview-summary span {
  color: var(--text-muted);
  font-size: 13px;
}

.preview-week {
  display: grid;
  gap: 8px;
}

.preview-week-title {
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 900;
}

.preview-course {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) minmax(74px, auto);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid #DDEAFF;
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text);
}

.preview-course span,
.preview-course em {
  color: var(--text-muted);
  font-size: 13px;
  font-style: normal;
}

.preview-course strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-warnings,
.preview-empty {
  display: grid;
  gap: 6px;
  color: var(--warning);
  font-size: 13px;
}

.preview-empty strong {
  color: var(--text);
  font-size: 16px;
}

.course-action-card {
  width: min(92%, 620px);
}

.course-action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.course-action-buttons button {
  flex: 1;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius-md);
  font-weight: 900;
}

.ai-modal {
  width: min(760px, 100%);
}

.ai-chat {
  display: flex;
  flex-direction: column;
  height: min(62svh, 620px);
  min-height: 0;
}

.ai-memory-dock {
  display: grid;
  gap: 10px;
  flex: 0 0 auto;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #F7FAFF;
}

.ai-memory-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ai-memory-head h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.ai-memory-head h3 span {
  display: inline-flex;
  min-width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.memory-status {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: #EAF2FF;
  color: var(--primary-strong);
  font-size: 12px;
  font-weight: 900;
}

.ai-memory-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.ai-memory-list {
  max-height: 104px;
  overflow-y: auto;
  padding-right: 2px;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 8px 2px 14px;
}

.chat-bubble {
  max-width: min(86%, 560px);
  padding: 13px 16px;
  border-radius: var(--radius-md);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: fadeIn 180ms ease;
}

.chat-bubble.ai {
  align-self: flex-start;
  background: #F0F6FF;
  border-bottom-left-radius: var(--radius-sm);
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-typing {
  align-self: flex-start;
  gap: 5px;
  padding: 10px 14px;
}

.chat-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 8px;
  background: var(--text-muted);
  animation: typingBounce 1.1s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 120ms; }
.chat-typing span:nth-child(3) { animation-delay: 240ms; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-7px); opacity: 1; }
}

.ai-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.ai-input-row button {
  min-width: 82px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 950;
}

.settings-section {
  display: grid;
  gap: 18px;
}

.settings-default,
.settings-complete {
  text-align: center;
}

.profile-orbit {
  position: relative;
  width: 86px;
  height: 86px;
  margin: 6px auto 18px;
  border-radius: var(--radius-lg);
  background: #EAF2FF;
}

.profile-orbit span {
  position: absolute;
  inset: 13px;
  border-radius: var(--radius-md);
  background: var(--surface-solid);
}

.profile-orbit.done::after {
  content: "";
  position: absolute;
  inset: 30px 25px 24px 32px;
  border-right: 5px solid var(--success);
  border-bottom: 5px solid var(--success);
  transform: rotate(42deg);
}

.settings-section h3 {
  margin-bottom: 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.memory-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #F7FAFF;
}

.memory-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.memory-panel h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.memory-hint,
.memory-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.memory-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.memory-form input {
  margin: 0;
}

.push-settings-panel {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #FFFFFF;
}

.push-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.push-panel-header h3 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.push-status-pill {
  flex: 0 0 auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F7FAFF;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
}

.push-rule-form {
  display: grid;
  gap: 12px;
}

.push-rule-form input,
.push-rule-form textarea {
  margin-top: 7px;
}

.push-rule-form textarea {
  min-height: 82px;
  resize: vertical;
}

.push-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 900;
}

.push-toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.push-history-list {
  display: grid;
  gap: 10px;
}

.push-history-empty {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

.push-history-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #F7FAFF;
}

.push-history-item.failed {
  border-color: #F6B7B7;
  background: #FFF7F7;
}

.push-history-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.push-history-main strong {
  font-size: 14px;
}

.push-history-main span,
.push-history-item small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.push-history-item p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.memory-form button {
  min-width: 84px;
  border: 0;
  border-radius: var(--radius-md);
  font-weight: 900;
}

.memory-list {
  display: grid;
  gap: 8px;
}

.memory-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #FFFFFF;
}

.memory-item span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.feature-desc {
  max-width: 520px;
  margin: 0 auto 18px;
  color: var(--text-muted);
  line-height: 1.7;
}

.pwa-install-banner {
  display: none;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #B8D3FF;
  border-radius: var(--radius-lg);
  background: #F0F6FF;
  text-align: left;
}

.pwa-install-banner.show {
  display: flex;
}

.pwa-text {
  flex: 1;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}

.pwa-install-banner button:not(.icon-button) {
  min-height: 38px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  padding: 0 14px;
  font-weight: 900;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: #EEF4FF;
  color: var(--text);
  font-size: 22px;
}

.q-header {
  font-size: 24px;
  font-weight: 950;
  letter-spacing: 0;
}

.q-progress {
  margin: 4px 0 22px;
  color: var(--text-muted);
  font-size: 13px;
}

.q-item {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.q-title {
  margin-bottom: 10px;
  font-weight: 900;
  line-height: 1.5;
}

.q-title small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-weight: 700;
}

.q-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.q-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  font-size: 13px;
}

.q-option:has(input:checked) {
  border-color: var(--primary);
  background: #EAF2FF;
}

.q-option input {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

.q-textarea {
  min-height: 110px;
}

.settings-actions {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1040px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .insight-rail {
    position: static;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 0.75fr);
  }

  .focus-card {
    grid-row: span 2;
  }

  .day-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-card {
    min-height: 0;
  }
}

@media (max-width: 720px) {
  body {
    padding-bottom: calc(90px + env(safe-area-inset-bottom));
  }

  .app-shell {
    width: min(calc(100% - 20px), 620px);
    padding-top: 12px;
  }

  .hero {
    flex-direction: column;
    min-height: 0;
    padding: 24px;
    border-radius: var(--radius-lg);
  }

  .brand-block {
    flex-direction: column;
  }

  .hero h1 {
    font-size: 48px;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .control-deck {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 8px;
    width: calc(100% - 10px);
    margin-top: -18px;
    padding: 8px;
  }

  .round-button {
    width: 48px;
    height: 48px;
  }

  .insight-rail {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-card {
    min-height: 96px;
    padding: 14px;
  }

  .stat-card.wide {
    grid-column: auto;
  }

  .stat-card strong {
    font-size: 20px;
  }

  .stage-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .stage-actions {
    width: 100%;
    justify-content: stretch;
  }

  .stage-actions .text-button {
    flex: 1;
    min-width: 0;
  }

  .day-list {
    grid-template-columns: 1fr;
  }

  .day-card {
    min-height: 0;
  }

  .course-stack {
    padding: 10px;
  }

  .course-line {
    grid-template-columns: auto minmax(0, 1fr) minmax(64px, auto);
    gap: 8px;
  }

  .period-tag {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .course-room {
    max-width: 82px;
  }

  .course-note {
    display: none;
  }

  .form-grid,
  .q-options {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 10px;
  }

  .modal {
    border-radius: var(--radius-lg);
    padding: 18px;
  }

  .import-modal {
    width: 100%;
    max-height: calc(100svh - 20px);
  }

  .import-textarea {
    min-height: 150px;
  }

  .preview-course {
    grid-template-columns: 1fr;
    gap: 3px;
    align-items: start;
  }

  .course-action-card {
    width: 92%;
  }

  .course-action-buttons {
    flex-direction: column;
  }

  .ai-modal {
    width: 100%;
    max-height: calc(100svh - 20px);
    display: flex;
    flex-direction: column;
  }

  .ai-modal .modal-title-row {
    flex: 0 0 auto;
    margin-bottom: 12px;
  }

  .ai-chat {
    flex: 1 1 auto;
    height: auto;
    max-height: calc(100svh - 160px);
    min-height: 0;
  }

  .ai-memory-dock {
    gap: 8px;
    margin-bottom: 8px;
    padding: 10px;
    border-radius: var(--radius-lg);
  }

  .ai-memory-head {
    align-items: center;
  }

  .ai-memory-head h3 {
    font-size: 16px;
  }

  .memory-status {
    padding: 5px 9px;
    font-size: 11px;
  }

  .ai-memory-form {
    grid-template-columns: minmax(0, 1fr) 72px;
    gap: 8px;
  }

  .ai-memory-form input {
    min-height: 44px;
  }

  .ai-memory-form .btn-save {
    min-height: 44px;
    padding: 0 10px;
    border-radius: var(--radius-md);
  }

  .ai-memory-list {
    max-height: 58px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .ai-memory-list .memory-item {
    min-height: 48px;
    padding: 9px 10px;
  }

  .chat-messages {
    flex: 1 1 auto;
    min-height: 32svh;
    padding: 6px 2px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .chat-bubble {
    max-width: 92%;
    padding: 11px 13px;
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.6;
  }

  .ai-input-row {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 8px;
    padding-top: 8px;
  }

  .ai-input-row input {
    min-height: 52px;
  }

  .ai-input-row button {
    min-width: 0;
    min-height: 52px;
    border-radius: var(--radius-md);
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(calc(100% - 14px), 620px);
  }

  .hero {
    padding: 20px;
  }

  .hero h1 {
    font-size: 42px;
  }

  .hero-copy {
    font-size: 15px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card.wide {
    grid-column: 1;
  }

  .bottom-nav {
    width: calc(100% - 18px);
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .tab {
    min-height: 54px;
  }

  .memory-form {
    grid-template-columns: 1fr;
  }

  .ai-input-row {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .ai-memory-form {
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  .ai-memory-dock {
    padding: 10px;
  }

  .ai-memory-head {
    flex-direction: row;
    align-items: center;
  }

  .course-line {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .course-room {
    display: none;
  }

  .ai-input-row button {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

html.app-webview,
html.app-webview body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  padding-bottom: 0;
  scroll-behavior: auto;
  overscroll-behavior-y: none;
  touch-action: pan-y;
}

html.app-webview * {
  animation: none !important;
  transition: none !important;
}

html.app-webview .insight-rail {
  position: static;
}

html.app-webview .app-root:not(.locked) {
  display: flex;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

html.app-webview .hero,
html.app-webview .insight-rail {
  display: none !important;
}

html.app-webview .app-shell {
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 8px 8px 0;
  flex-direction: column;
  overflow: hidden;
}

html.app-webview .control-deck {
  flex: 0 0 auto;
  width: 100%;
  margin: 0 0 8px;
  padding: 8px;
  border-radius: var(--radius-md);
}

html.app-webview .live-banner {
  flex: 0 0 auto;
  margin-bottom: 8px;
}

html.app-webview .dashboard-grid {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

html.app-webview .schedule-stage {
  display: flex;
  height: 100%;
  min-height: 0;
  padding: 8px;
  flex-direction: column;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
}

html.app-webview .stage-header {
  flex: 0 0 auto;
  margin-bottom: 8px;
  gap: 8px;
}

html.app-webview .stage-header h2,
html.app-webview .stage-header .section-kicker {
  display: none;
}

html.app-webview .day-list {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  padding-bottom: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  transition: none;
}

html.app-webview .day-card {
  margin-bottom: 10px;
  contain: layout paint style;
  content-visibility: auto;
  contain-intrinsic-size: 172px;
}

html.app-webview .course-item,
html.app-webview .stat-card,
html.app-webview .focus-card,
html.app-webview .schedule-stage {
  contain: layout paint;
}

html.app-webview .day-list.slide-left,
html.app-webview .day-list.slide-right {
  animation: none;
}

html.app-webview .course-item:hover,
html.app-webview .course-item:active,
html.app-webview .round-button:active {
  transform: none;
}

html.app-webview .course-item:hover {
  transform: none;
}

html.app-webview .bottom-nav {
  transform: translate3d(-50%, 0, 0);
  will-change: auto;
}

html.app-webview .bottom-nav {
  position: static;
  flex: 0 0 auto;
  width: 100%;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  transform: none;
}

html.app-webview .tab {
  min-height: 46px;
}

@media print {
  body {
    background: #fff;
    padding: 0;
  }

  .hero,
  .control-deck,
  .insight-rail,
  .bottom-nav,
  .modal-overlay,
  .toast,
  .offline-bar,
  .orb {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .dashboard-grid,
  .day-list {
    display: block;
  }

  .schedule-stage,
  .day-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

.app-root.locked {
  display: none;
}

.lock-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.lock-screen.unlocked {
  display: none;
}

.lock-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-solid);
  box-shadow: var(--shadow-md);
}

.lock-panel h1 {
  margin-bottom: 18px;
  font-size: 34px;
  letter-spacing: 0;
}

.lock-panel label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
}

.lock-panel input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 14px;
  background: #fff;
  color: var(--text);
}

.lock-mark {
  margin-bottom: 16px;
}

.lock-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 14px;
}
