@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  font-family: "DM Sans", "Noto Sans TC", sans-serif;
  color: #283b35;
  background: #f6f5f1;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #283b35;
  --muted: #89928b;
  --green: #31765c;
  --green-dark: #245c47;
  --green-soft: #e9f2ec;
  --orange: #e69b59;
  --line: #ebeae4;
  --paper: #ffffff;
  --shadow: 0 14px 42px rgba(51, 68, 57, 0.055);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 8% 0%, rgba(223, 235, 223, 0.72), transparent 34rem),
    #f6f5f1;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.page-shell {
  width: min(1100px, calc(100% - 48px));
  margin: 0 auto;
  padding: 20px 0 max(30px, env(safe-area-inset-bottom));
}

.topbar, .brand, .section-heading, .calendar-controls, .dialog-heading, .day-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar { min-height: 44px; }
.brand {
  justify-content: flex-start;
  gap: 9px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}
.brand-mark { color: var(--green); font-size: 24px; }
.text-button, .button-quiet {
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 600;
}
.text-button { padding: 10px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(29px, 4vw, 42px); letter-spacing: -1.3px; line-height: 1.3; }
h2 { margin: 0; font-size: 19px; letter-spacing: -0.25px; }
.muted { color: var(--muted); line-height: 1.75; }
.eyebrow {
  margin: 0 0 8px;
  color: #88a08f;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.7px;
}

.panel {
  border: 1px solid rgba(232, 232, 224, 0.82);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.auth-layout {
  display: grid;
  grid-template-columns: 1.1fr minmax(320px, 390px);
  align-items: center;
  gap: clamp(45px, 9vw, 120px);
  min-height: min(720px, calc(100vh - 100px));
  padding: 45px 5%;
}
.welcome-copy { max-width: 510px; }
.welcome-copy h1 { font-size: clamp(35px, 5vw, 52px); }
.welcome-copy > .muted { max-width: 430px; margin-bottom: 30px; }
.feature-list { display: flex; flex-wrap: wrap; gap: 10px; }
.feature-list span {
  padding: 9px 12px;
  border: 1px solid #e8ebe4;
  border-radius: 24px;
  background: rgba(255,255,255,.68);
  color: #617368;
  font-size: 12px;
}
.auth-panel { padding: 27px; }
.auth-tabs { display: flex; gap: 20px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.auth-tab {
  position: relative;
  padding: 0 0 12px;
  border: 0;
  background: transparent;
  color: #9a9f99;
  font-size: 15px;
  font-weight: 600;
}
.auth-tab.active { color: var(--green); }
.auth-tab.active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--green);
  content: "";
}
.field-label { display: block; margin: 16px 0 7px; color: #5d6c62; font-size: 12px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid #e5e8e2;
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #78a78d; box-shadow: 0 0 0 3px rgba(87, 151, 113, .12); }
input::placeholder, textarea::placeholder { color: #b1b7b1; }
.button {
  display: inline-flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, transform .15s;
}
.button:active, .icon-button:active { transform: scale(.98); }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { border-color: #d8e6db; background: var(--green-soft); color: var(--green-dark); }
.button-secondary:hover { background: #deede2; }
.button-full { width: 100%; }
#auth-submit { margin-top: 22px; }
.fine-print { margin: 17px 0 0; color: #a0a59f; font-size: 11px; line-height: 1.65; }
.status-message { min-height: 18px; margin: 10px 0 0; color: #b6574e; font-size: 12px; line-height: 1.5; }
.status-message:empty { display: none; }
.status-message.success { color: var(--green); }
.status-message.notice { color: #708078; }

.setup-layout { max-width: 780px; margin: 105px auto 0; }
.setup-heading { margin-bottom: 28px; text-align: center; }
.setup-heading .muted { margin-bottom: 0; }
.setup-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.setup-card { padding: 24px; }
.setup-card h2 { margin-bottom: 8px; }
.setup-card > .muted { min-height: 46px; margin-bottom: 16px; font-size: 13px; }
.setup-card .button { margin-top: 18px; }
.card-icon { display: block; margin-bottom: 15px; color: var(--green); font-size: 23px; }
#household-status { text-align: center; }

.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 43px 0 24px; }
.dashboard-heading h1 { font-size: 32px; }
.dashboard-heading .muted { margin: 0; font-size: 13px; }
.invite-box {
  display: grid;
  min-width: 190px;
  justify-items: center;
  padding: 12px 18px;
  border: 1px dashed #c8d9ce;
  border-radius: 12px;
  background: rgba(255,255,255,.66);
}
.invite-label { color: var(--muted); font-size: 10px; }
.invite-code { margin: 2px 0; border: 0; background: transparent; color: var(--green); font-size: 15px; font-weight: 700; letter-spacing: 2px; }
.invite-hint { color: #a0a79f; font-size: 10px; }
.app-tabs {
  display: flex;
  gap: 6px;
  margin: 24px 0 18px;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid #e9ebe5;
  border-radius: 12px;
  background: rgba(255, 255, 255, .74);
}
.app-tab {
  min-height: 40px;
  flex: 1 0 auto;
  padding: 9px 18px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #78867c;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.app-tab.active { background: var(--green); color: #fff; box-shadow: 0 3px 9px rgba(49, 118, 92, .15); }
.app-tab:focus-visible { outline: 3px solid rgba(87, 151, 113, .28); outline-offset: 2px; }
.targets-panel { padding: 24px; }
.targets-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.targets-heading h2 { margin-bottom: 7px; }
.targets-heading .muted { margin-bottom: 0; font-size: 12px; }
.targets-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.target-card { min-width: 0; padding: 15px; border: 1px solid #e9eee8; border-radius: 13px; background: #fcfdfa; }
.target-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.target-card-heading { min-width: 0; }
.target-subject { margin: 0 0 3px; color: #40584a; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.target-learner-name { margin: 0; color: #91a097; font-size: 10px; }
.target-date { flex: 0 0 auto; padding: 5px 8px; border-radius: 20px; background: #f0f5ef; color: #63796a; font-size: 10px; white-space: nowrap; }
.target-pages { margin: 12px 0 0; color: var(--green); font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.target-note { margin: 7px 0 0; color: #758278; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; white-space: pre-wrap; }
.target-actions { display: flex; gap: 14px; margin-top: 12px; padding-top: 9px; border-top: 1px solid #edf0eb; }
.target-actions button { padding: 2px 0; border: 0; background: transparent; color: #76917e; font-size: 10px; }
.target-actions button.delete-action { color: #b8756d; }
.empty-targets { grid-column: 1 / -1; padding: 35px 14px; color: #9ba59d; font-size: 12px; line-height: 1.8; text-align: center; }
.empty-targets strong { display: block; margin-bottom: 3px; color: #718076; font-size: 13px; }
.scoreboard-panel { margin-bottom: 18px; padding: 22px 24px; }
.scoreboard-panel .section-heading { margin-bottom: 18px; }
.month-chip { padding: 6px 10px; border-radius: 20px; background: #f4f5f0; color: #7c8b80; font-size: 11px; }
.scoreboard-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.score-card {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  background: #f8f9f6;
}
.score-card:first-child { background: #f1f7f1; }
.avatar {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: #e8efe9;
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}
.score-card:first-child .avatar { background: #dbeadf; }
.score-info { min-width: 0; flex: 1; }
.score-name { overflow: hidden; margin-bottom: 2px; color: #4f6155; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.score-subtitle { color: #a1a79f; font-size: 10px; }
.score-value { flex: 0 0 auto; color: var(--green); font-size: 17px; font-weight: 700; white-space: nowrap; }
.empty-score { grid-column: 1 / -1; padding: 12px; color: #a0a79f; font-size: 12px; text-align: center; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(310px, .82fr); align-items: start; gap: 18px; }
.calendar-panel, .day-panel { min-width: 0; padding: 22px 23px; }
.section-heading { gap: 12px; }
.section-heading .eyebrow { margin-bottom: 6px; }
.calendar-heading { margin-bottom: 22px; }
.calendar-controls { flex: 0 0 auto; gap: 12px; }
.calendar-month { min-width: 92px; color: #56675b; font-size: 13px; font-weight: 600; text-align: center; }
.icon-button {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #e9ece6;
  border-radius: 9px;
  background: #fff;
  color: #65766b;
  font-size: 23px;
  line-height: 1;
}
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { margin-bottom: 7px; }
.calendar-weekdays span { padding: 6px 0; color: #9ba49c; font-size: 11px; text-align: center; }
.calendar-day {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 58px;
  align-content: start;
  justify-items: center;
  gap: 5px;
  padding: 8px 2px 4px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: #647168;
  font-size: 12px;
}
.calendar-day:hover { background: #f6f8f5; }
.calendar-day.outside-month { color: #c7cbc5; }
.calendar-day.today .day-number { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: #edf3ed; color: var(--green); font-weight: 700; }
.calendar-day.selected { border-color: #bcd6c4; background: #f0f6f0; color: var(--green-dark); }
.calendar-day.selected .day-number { font-weight: 700; }
.day-indicator { display: grid; min-height: 11px; justify-items: center; gap: 2px; }
.record-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--orange); }
.calendar-points { color: var(--green); font-size: 8px; line-height: 1; }
.calendar-legend { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: #a0a79f; font-size: 10px; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }
.day-panel { min-height: 380px; }
.day-heading { align-items: flex-start; }
.button-quiet { padding: 7px 0; font-size: 12px; white-space: nowrap; }
.selected-date-label { margin: 13px 0 10px; color: #97a098; font-size: 11px; }
.day-records { display: grid; gap: 9px; }
.record-card { padding: 12px; border: 1px solid #edf0eb; border-radius: 11px; background: #fcfcfa; }
.record-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.record-title { margin: 0; color: #4c5e52; font-size: 12px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.record-points { flex: 0 0 auto; color: var(--green); font-size: 12px; font-weight: 700; white-space: nowrap; }
.record-meta { margin: 5px 0 0; color: #a0a79f; font-size: 10px; }
.record-note { margin: 7px 0 0; color: #758278; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.record-actions { display: flex; gap: 12px; margin-top: 8px; }
.record-actions button { padding: 2px 0; border: 0; background: transparent; color: #76917e; font-size: 10px; }
.record-actions button.delete-action { color: #b8756d; }
.empty-day { padding: 37px 14px; color: #a0a79f; font-size: 12px; line-height: 1.8; text-align: center; }
.empty-day strong { display: block; margin-bottom: 4px; color: #758278; font-size: 13px; }
.add-record-button { margin-top: 16px; }
.page-footer { margin-top: 28px; color: #a0a79f; font-size: 11px; text-align: center; }

.form-dialog {
  width: min(460px, calc(100% - 28px));
  max-height: min(90dvh, 800px);
  padding: 24px;
  overflow-y: auto;
  border: 1px solid #e8e9e2;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(35, 49, 40, .2);
}
.form-dialog::backdrop { background: rgba(36, 49, 41, .36); backdrop-filter: blur(2px); }
.dialog-heading { margin-bottom: 10px; }
.dialog-heading h2 { font-size: 20px; }
.points-input-wrap { display: flex; align-items: center; gap: 9px; }
.points-input-wrap input { max-width: 140px; }
.points-input-wrap span { color: #819087; font-size: 13px; }
.form-dialog .button { margin-top: 12px; }
.compact-dialog { width: min(390px, calc(100% - 28px)); }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 32px, 560px); padding-top: max(12px, env(safe-area-inset-top)); }
  .auth-layout { grid-template-columns: 1fr; gap: 25px; min-height: auto; padding: 52px 0 25px; }
  .welcome-copy { text-align: center; }
  .welcome-copy h1 { font-size: 36px; }
  .welcome-copy > .muted { margin-right: auto; margin-left: auto; font-size: 13px; }
  .feature-list { justify-content: center; }
  .auth-panel { padding: 22px; }
  .setup-layout { margin-top: 62px; }
  .dashboard-heading { align-items: flex-start; margin-top: 29px; }
  .dashboard-heading h1 { font-size: 27px; }
  .dashboard-heading .muted { max-width: 260px; font-size: 11px; }
  .invite-box { min-width: 145px; padding: 9px 10px; }
  .invite-code { font-size: 14px; letter-spacing: 1.5px; }
  .app-tabs { margin: 20px 0 14px; }
  .app-tab { min-height: 39px; padding: 9px 14px; font-size: 12px; }
  .targets-panel { padding: 18px; }
  .targets-heading { align-items: flex-start; gap: 10px; }
  .targets-heading h2 { font-size: 17px; }
  .targets-heading .muted { max-width: 230px; font-size: 11px; }
  .targets-heading > .button { min-height: 39px; padding: 8px 10px; font-size: 11px; white-space: nowrap; }
  .targets-grid { grid-template-columns: 1fr; }
  .invite-hint { max-width: 100px; line-height: 1.4; text-align: center; }
  .scoreboard-panel { padding: 18px; }
  .scoreboard-list { grid-template-columns: 1fr; gap: 8px; }
  .score-card { padding: 9px 11px; }
  .workspace-grid { grid-template-columns: 1fr; gap: 14px; }
  .calendar-panel, .day-panel { padding: 18px; }
  .calendar-day { min-height: 52px; }
  .day-panel { min-height: unset; }
  .empty-day { padding: 22px 12px; }
}

@media (max-width: 420px) {
  .page-shell { width: calc(100% - 24px); }
  .dashboard-heading { gap: 8px; }
  .dashboard-heading .muted { max-width: 205px; }
  .targets-heading { flex-direction: column; }
  .targets-heading > .button { width: 100%; }
  .calendar-panel, .day-panel { padding: 15px 12px; }
  .calendar-controls { gap: 5px; }
  .calendar-month { min-width: 79px; font-size: 12px; }
  .calendar-day { min-height: 49px; }
  .setup-cards { grid-template-columns: 1fr; }
  .setup-card > .muted { min-height: 0; }
}
