:root {
  --green: #227d4a;
  --bg: #f4f5f2;
  --card: #fff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --line: #e5e5ea;
  font-family: "SF Pro Text", "PingFang TC", "Noto Sans TC", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; min-height: 100%; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.top {
  padding: 20px 20px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 28px; }
.muted { color: var(--muted); font-size: 14px; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px 0;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
}
.tabs button.on {
  background: rgba(34, 125, 74, 0.12);
  color: var(--green);
}

.page { padding: 16px 20px 40px; flex: 1; }
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.stack { display: flex; flex-direction: column; gap: 8px; }

.primary, .ghost, .danger, .chip {
  border-radius: 12px;
  border: 0;
  padding: 10px 14px;
}
.primary {
  background: var(--green);
  color: #fff;
  font-weight: 700;
  width: 100%;
}
.primary:disabled, .action:disabled { opacity: 0.4; }
.ghost {
  background: #eee;
  color: var(--text);
}
.sheet-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 50%;
  background: #eee;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}
.danger { background: #fde8e8; color: #b42318; }
.lesson-row { align-items: flex-start; flex-wrap: wrap; }
.lesson-actions { display: flex; gap: 6px; flex-shrink: 0; }
.lesson-actions button { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
.add-lesson { margin: 8px 0 12px; padding: 12px; background: #fafafa; border-radius: 12px; }
.link {
  background: none;
  border: 0;
  color: var(--green);
  font-weight: 700;
  padding: 8px 0;
}
.action {
  width: 100%;
  background: rgba(34, 125, 74, 0.12);
  color: var(--green);
  font-weight: 700;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
}

.grid7 {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.day {
  min-height: 76px;
  border: 0;
  border-radius: 10px;
  background: #eee;
  padding: 6px 3px;
  overflow: hidden;
}
.day b { display: block; }
.day-summary, .day-more {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 1.35;
}
.day-summary { margin-top: 5px; color: var(--text); }
.day-more { color: var(--muted); }
.day.past { opacity: 0.45; }
.day.sel { outline: 2px solid var(--green); background: rgba(34,125,74,0.16); font-weight: 700; }
.day.locked { background: rgba(34,125,74,0.12); }
.weekhead { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; }

.input, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fafafa;
}
.time-pick {
  display: flex;
  align-items: center;
  gap: 6px;
}
.time-pick select {
  width: auto;
  min-width: 4.4rem;
  padding: 10px 8px;
}
.welcome {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 48px 24px 32px;
  background: var(--card);
}
.hero {
  height: 180px;
  border-radius: 28px;
  background: linear-gradient(160deg, #227d4a, #3aa066);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 64px;
  margin-bottom: 28px;
}
.welcome .chips { margin: 12px 0 16px; }
.welcome .input { margin-bottom: 10px; }
.error { color: #b42318; font-size: 14px; }
.cta { margin-top: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #eee; }
.chip.on { background: var(--green); color: #fff; }

.list-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}
.dialog-overlay { align-items: center; padding: 24px; z-index: 30; }
.dialog {
  background: var(--card);
  width: 100%;
  max-width: 400px;
  border-radius: 20px;
  padding: 20px;
}
.dialog p { margin: 0 0 16px; font-size: 17px; line-height: 1.5; }
.confirm-danger { width: 100%; }
.setup-hint { border-left: 4px solid var(--green); background: rgba(34,125,74,0.07); }
.setup-hint p { margin: 0; }
.schedule-scope { margin: 8px 2px 12px; }
.refill-action { text-align: left; }
.sheet {
  background: var(--card);
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  border-radius: 20px 20px 0 0;
  padding: 16px 20px 28px;
}
@media (min-width: 720px) {
  .overlay { align-items: center; }
  .sheet { max-width: 560px; margin: 0 auto; border-radius: 20px; }
}
