:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #23201c;
  --muted: #6f675d;
  --line: #e3ddd2;
  --accent: #3d6b52;
  --accent-soft: #eaf1ec;
  --warn: #a8442a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(35, 32, 28, 0.06), 0 4px 16px rgba(35, 32, 28, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 8px 14px;
  color: var(--ink);
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.55; cursor: progress; }
button.ghost { background: transparent; }

input[type="url"], input[type="text"], input[type="date"], textarea {
  font: inherit;
  color: var(--ink);
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
textarea { resize: vertical; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.brand h1 { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.week-picker { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.week-picker input { width: auto; }

/* ---------- child + week tabs ---------- */

.children, .weeks {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
}
.weeks { padding: 10px 28px; background: #fbf9f6; gap: 6px; }
.weeks:empty { display: none; }
.weeks-label { color: var(--muted); font-size: 12.5px; margin-right: 4px; }
.week-tab {
  border-radius: 8px;
  padding: 5px 13px;
  font-size: 13px;
  background: var(--surface);
}
.week-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.week-tab .wcount { opacity: 0.65; font-size: 11px; margin-left: 6px; font-weight: 400; }
.week-tab .wdate { display: block; font-size: 10.5px; opacity: 0.6; font-weight: 400; margin-top: 1px; }
.week-tab { line-height: 1.25; }

.generate-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
  font-size: 14px;
}
.generate-panel button { flex: none; }
.child-tab {
  border-radius: 999px;
  padding: 7px 16px;
  background: transparent;
}
.child-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.child-tab .count { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 6px; }
.child-tab.active .count { color: var(--accent); }
.add-child { border-style: dashed; color: var(--muted); border-radius: 999px; padding: 7px 14px; }

/* ---------- main ---------- */

main { padding: 26px 28px 60px; }

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.chart-head h2 { margin: 0; font-size: 18px; }
.chart-meta { color: var(--muted); font-size: 13px; }
.chart-meta button { padding: 4px 10px; font-size: 12px; margin-left: 8px; }

.progress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.bar { width: 120px; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table { border-collapse: collapse; width: 100%; min-width: 720px; }

th, td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: top;
  text-align: left;
}
th:last-child, td:last-child { border-right: none; }
tr:last-child td { border-bottom: none; }

thead th {
  background: var(--accent-soft);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  position: sticky;
  top: 0;
}
thead th { position: relative; }
thead th > span:first-child { display: block; }
.col-name { cursor: text; border-radius: 3px; }
.col-name:hover { background: rgba(0, 0, 0, 0.05); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05); }
.col-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.col-rename {
  width: 100%;
  font: inherit;
  text-transform: none;
  letter-spacing: normal;
  padding: 3px 6px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}

.col-move {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s;
}
thead th:hover .col-move, .col-move:focus-within { opacity: 1; }
.col-move button {
  border: none;
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 4px;
}
.col-move button:hover:not(:disabled) { background: var(--accent); color: #fff; }
.col-move button:disabled { opacity: 0.3; cursor: default; }

tbody th {
  background: #fbf9f6;
  font-size: 14px;
  white-space: nowrap;
  width: 1%;
}
tr.all-week th, tr.all-week td { background: #fdfbf7; }

.task { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; font-size: 13.5px; }
.task:last-child { margin-bottom: 0; }
.task input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.task label { cursor: pointer; }
.task.done label { text-decoration: line-through; color: var(--muted); }
/* Daily work leads each cell, set quieter than the lesson beneath it. */
.task.daily { color: var(--muted); }
.task.daily label { font-size: 12.5px; }
.task.daily + .task:not(.daily) { margin-top: 8px; }

td.empty { background: repeating-linear-gradient(135deg, transparent, transparent 7px, #f4f1ea 7px, #f4f1ea 8px); }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 46px 32px;
  text-align: center;
  color: var(--muted);
}
.empty-state h2 { margin: 0 0 6px; color: var(--ink); font-size: 17px; }
.empty-state p { margin: 0 auto 18px; max-width: 46ch; }

/* ---------- document chips ---------- */

.doc-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: -4px 0 14px;
}
.doc-list-label { color: var(--muted); font-size: 12.5px; margin-right: 2px; }
.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 12.5px;
  max-width: 320px;
}
.doc-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-remove {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
}
.doc-remove:hover { color: var(--warn); background: var(--accent-soft); }
.doc-add {
  border-style: dashed;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- dialog ---------- */

dialog {
  border: none;
  border-radius: 14px;
  padding: 26px;
  width: min(620px, 92vw);
  box-shadow: 0 20px 60px rgba(35, 32, 28, 0.25);
  color: var(--ink);
  background: var(--surface);
}
dialog::backdrop { background: rgba(35, 32, 28, 0.4); }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
.dialog-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.dialog-close { position: absolute; top: 12px; right: 14px; }
.dialog-close button { border: none; background: none; font-size: 22px; color: var(--muted); padding: 2px 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { border: none; background: none; padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.panel { display: none; }
.panel > input[type="text"] { margin-bottom: 10px; }
.panel.active { display: block; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }

.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 20px; }
.status { color: var(--muted); font-size: 13px; margin-right: auto; }
.status.error { color: var(--warn); }

/* ---------- print ---------- */

@media print {
  .topbar, .children, .weeks, .doc-list, .generate-panel, .col-move, dialog, .progress { display: none !important; }
  .col-name:hover { background: none; box-shadow: none; }
  thead th > span:first-child { padding-right: 0; }
  body { background: #fff; }
  main { padding: 0; }
  .table-wrap { border: none; box-shadow: none; overflow: visible; }
  table { min-width: 0; font-size: 11pt; }
  thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .task input { -webkit-appearance: none; appearance: none; border: 1.2px solid #555; border-radius: 3px; }
  .task.done label { text-decoration: none; color: inherit; }
  @page { margin: 12mm; size: landscape; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191714;
    --surface: #221f1b;
    --ink: #ece6dc;
    --muted: #a49a8c;
    --line: #383430;
    --accent: #8fc0a3;
    --accent-soft: #2a332c;
    --warn: #e08c72;
  }
  tbody th, tr.all-week th, tr.all-week td, .weeks { background: #262320; }
  td.empty { background: repeating-linear-gradient(135deg, transparent, transparent 7px, #2a2724 7px, #2a2724 8px); }
}

/* ---------- sign-in ---------- */

/* Author styles beat the browser's [hidden] rule, so say it explicitly. */
[hidden] { display: none !important; }


body.signed-out .topbar, body.signed-out .children, body.signed-out .weeks, body.signed-out main {
  display: none;
}

.signin {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}
.signin-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 44px 40px 32px;
  max-width: 430px;
  text-align: center;
}
.signin-card h2 { margin: 0 0 10px; font-size: 24px; letter-spacing: -0.01em; }
.signin-card p { color: var(--muted); font-size: 14.5px; line-height: 1.6; margin: 0 0 26px; }

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(35, 32, 28, 0.08);
}
.google-btn:hover { border-color: var(--muted); }

.signin-note { margin: 20px 0 0; font-size: 13px; color: var(--warn); }
.signin-note:empty { display: none; }
.signin-legal { margin: 24px 0 0; font-size: 12.5px; }
.signin-legal a { color: var(--muted); }

.account { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.account img { width: 26px; height: 26px; border-radius: 50%; }
.account button { padding: 4px 10px; font-size: 12px; }
.account .quota { font-variant-numeric: tabular-nums; }

/* ---------- Drive picker ---------- */

.pick-btn {
  width: 100%;
  padding: 15px;
  border-style: dashed;
  border-radius: 10px;
  font-size: 14.5px;
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.pick-btn:hover { filter: brightness(0.97); }
.pick-btn:disabled { opacity: 0.6; cursor: progress; }

.picked { list-style: none; margin: 14px 0 0; padding: 0; }
.picked:empty { display: none; }
.picked li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 6px;
}
.picked li::before { content: "\1F4C4"; }
.picked button {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 15px;
  padding: 2px 6px;
}
.picked button:hover { color: var(--warn); }

/* ---------- printables ---------- */

.printables-group { margin-bottom: 22px; }
.printables-group:last-child { margin-bottom: 0; }
.printables-group h3 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.printables-group ul { list-style: none; margin: 0; padding: 0; }
.printables-group li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.printables-group li:last-child { border-bottom: none; }
.printables-group .where {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.printables-empty { color: var(--muted); font-size: 14px; line-height: 1.6; }
#printables-dialog { max-height: 82vh; overflow-y: auto; }

.printables-group details { margin-top: 10px; }
.printables-group summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  padding: 4px 0;
}
.printables-group summary:hover { color: var(--ink); }
.printables-group details li { color: var(--muted); }

.have-it {
  flex: none;
  padding: 3px 10px;
  font-size: 11.5px;
  border-radius: 999px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s;
}
.printables-group li:hover .have-it, .have-it:focus-visible { opacity: 1; }
.have-it:hover { color: var(--accent); border-color: var(--accent); }
.printables-group li { align-items: center; }

.scope-toggle {
  display: block;
  margin: 0 0 20px auto;
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 999px;
  color: var(--muted);
}
.scope-toggle:hover { color: var(--accent); border-color: var(--accent); }

.printable-link { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.printable-link:hover { border-bottom-color: var(--accent); }

.refresh-links {
  display: block;
  margin: 24px auto 0;
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 999px;
  color: var(--muted);
}
.refresh-links:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }

.printables-group .where.located { font-style: italic; color: var(--accent); opacity: 0.85; }

.mark-all {
  margin-left: auto;
  text-transform: none;
  letter-spacing: normal;
  font-size: 11.5px;
  font-weight: 400;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--muted);
}
.mark-all:hover { color: var(--accent); border-color: var(--accent); }

.printables-group .where.anchor {
  border: none;
  background: none;
  padding: 2px 0;
  font-size: 12px;
  color: var(--accent);
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.printables-group .where.anchor:hover { text-decoration: underline; }

.refresh-note {
  margin: 8px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- task detail ---------- */

#detail-dialog { max-width: min(680px, 92vw); max-height: 82vh; overflow-y: auto; }
#detail-title { font-size: 17px; line-height: 1.35; }
.detail-passage {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.65;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  max-height: 46vh;
  overflow-y: auto;
}
.detail-passage mark { background: var(--accent-soft); color: inherit; padding: 1px 2px; border-radius: 3px; }
.detail-missing { color: var(--muted); font-size: 14px; line-height: 1.6; }
.task label { cursor: pointer; }
.task .more {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 11px;
  padding: 0 4px;
  opacity: 0;
  cursor: pointer;
}
.task:hover .more, .more:focus-visible { opacity: 1; }
.task .more { align-self: flex-start; margin-top: 2px; }
.more:hover { color: var(--accent); }
@media print { .task .more { display: none !important; } }

.open-doc {
  display: inline-block;
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 5px 14px;
}
.open-doc:hover { background: var(--accent-soft); }

.task .go {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  padding: 0 3px;
  cursor: pointer;
  flex: none;
}
.task .go:hover { text-decoration: none; transform: translateY(-1px); }
@media print { .task .go { display: none !important; } }

.detail-sheets { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.detail-sheets a { color: var(--accent); }
.detail-sheets .owned-note { color: var(--muted); font-style: italic; }

.passage-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.passage-link::after { content: " ↗"; font-size: 0.85em; text-decoration: none; }

.task .sheet {
  border: none;
  background: none;
  font-size: 11px;
  padding: 0 2px;
  cursor: pointer;
  text-decoration: none;
  flex: none;
  filter: grayscale(0.2);
}
.task .sheet.owned { opacity: 0.45; }
@media print { .task .sheet { display: none !important; } }


.generate-panel.stale { background: var(--surface); border-color: var(--line); }
.generate-panel.stale button.ghost { color: var(--muted); }

.day-note {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.4;
}
td.noted { background: #fbfaf7; }
@media (prefers-color-scheme: dark) { td.noted { background: #232019; } }

.col-open {
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  opacity: 0.55;
}
.col-open:hover { opacity: 1; }
thead th > span:first-child { padding-left: 16px; }
@media print { .col-open { display: none !important; } thead th > span:first-child { padding-left: 0; } }

/* ---------- parent's own additions ---------- */

.field { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.field input, .field select { margin-top: 5px; font-size: 14px; color: var(--ink); }
.field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
}
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.repeat { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 4px; }
.repeat legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.repeat label { display: block; font-size: 14px; padding: 3px 0; cursor: pointer; }

.task.mine label { color: var(--ink); }
.task.mine::before {
  content: "";
  width: 3px;
  align-self: stretch;
  background: var(--accent);
  opacity: 0.4;
  border-radius: 2px;
  margin-right: 2px;
  flex: none;
}
.task .drop {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  padding: 0 3px;
  opacity: 0;
  cursor: pointer;
  flex: none;
}
.task:hover .drop { opacity: 1; }
.task .drop:hover { color: var(--warn); }

.add-own {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 4px;
  opacity: 0;
  cursor: pointer;
}
td:hover .add-own { opacity: 1; }
.add-own:hover { color: var(--accent); }
@media print { .add-own, .task .drop { display: none !important; } }


.col-move .drop-col { color: var(--muted); }
.col-move .drop-col:hover:not(:disabled) { background: var(--warn); color: #fff; }


@media print {
}

.days-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px; margin-bottom: 4px; }
.days-list label { font-size: 14px; padding: 5px 2px; cursor: pointer; }

tbody th { position: relative; }
.day-hide {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  padding: 0 4px;
  margin-left: 6px;
  opacity: 0;
  cursor: pointer;
}
tbody th:hover .day-hide { opacity: 1; }
.day-hide:hover { color: var(--warn); }
.days-list .all-week-option {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 10px;
}
@media print { .day-hide { display: none !important; } }
