/* lib/worklog2.css — Work Log 2 (goal-based) + its printed goal sheet. Shell
   classes (.app-banner, .app-content, .history-label, .empty-state) come from
   index.html; the official-sheet print styles (.pf-*) from lib/worklog.css. */

:root {
  --w2: #1d4ed8; --w2-dark: #1e3a8a; --w2-ink: #0f172a; --w2-soft: #eff6ff; --w2-line: #e2e8f0;
  --w2-muted: #64748b; --w2-track: #f1f5f9; --w2-met: #047857; --w2-met-soft: #ecfdf5; --w2-no: #b91c1c; --w2-no-soft: #fef2f2;
}

#view-work2 .app-banner { background: linear-gradient(135deg, #0b1736 0%, #1e3a8a 55%, #1d4ed8 100%); }

.w2-card { background: white; border-radius: 18px; padding: 18px 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(15,23,42,0.06), 0 8px 24px rgba(15,23,42,0.07); }
.w2-card h2 { font-size: 16px; color: var(--w2-ink); }
.w2-muted { color: var(--w2-muted); font-size: 13px; }
.w2-progress p { margin-top: 6px; }

/* ---------- sections ---------- */
.w2-sec + .w2-sec { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--w2-line); }
.w2-sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.w2-sec-head h3 { font-size: 17px; font-weight: 800; color: var(--w2-ink); letter-spacing: -0.2px; }
.w2-num { width: 26px; height: 26px; border-radius: 50%; background: var(--w2-dark); color: white; font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.w2-tag { margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; color: var(--w2); background: var(--w2-soft); padding: 4px 8px; border-radius: 999px; }
.w2-sub { font-size: 12px; font-weight: 800; color: #334155; text-transform: uppercase; letter-spacing: 0.6px; margin: 14px 0 7px; }
.w2-sub em { font-style: normal; font-weight: 600; text-transform: none; letter-spacing: 0; color: #94a3b8; }
.w2-sec-head + .w2-sub { margin-top: 0; }

/* ---------- inputs ---------- */
.w2-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.w2-span2 { grid-column: 1 / -1; }
.w2-field { min-width: 0; }
.w2-field span { display: block; font-size: 11px; font-weight: 800; color: var(--w2-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.w2-field input, .w2-field select, .w2-other, #w2-comments {
  width: 100%; min-width: 0; max-width: 100%; min-height: 46px; padding: 11px 12px; border: 1.5px solid var(--w2-line); border-radius: 12px;
  font-size: 16px; font-family: inherit; color: var(--w2-ink); background: #f8fafc; -webkit-appearance: none; appearance: none;
}
.w2-field input:focus, .w2-field select:focus, .w2-other:focus, #w2-comments:focus { outline: none; border-color: var(--w2); box-shadow: 0 0 0 3px rgba(29,78,216,0.15); background: white; }
.w2-other { margin-top: 8px; }
#w2-comments { resize: vertical; line-height: 1.4; }

/* ---------- segmented controls: equal columns, one tap ---------- */
.w2-seg { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--w2-track); border-radius: 14px; }
.w2-seg-btn {
  min-height: 46px; padding: 6px 4px; border: none; border-radius: 10px; background: transparent; color: #334155;
  font-family: inherit; font-size: clamp(13px, 3.8vw, 15px); font-weight: 650; line-height: 1.15; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}
.w2-seg-btn[aria-pressed="true"] { background: white; color: var(--w2-dark); font-weight: 800; box-shadow: 0 1px 3px rgba(15,23,42,0.15), inset 0 0 0 1.5px var(--w2); }
/* Answers that mean "independent" read green; "didn't" reads red. */
#w2-started [data-key="own"][aria-pressed="true"], #w2-finished [data-key="own"][aria-pressed="true"], #w2-ontask [data-key="yes"][aria-pressed="true"] { color: var(--w2-met); background: var(--w2-met-soft); box-shadow: inset 0 0 0 1.5px var(--w2-met); }
#w2-started [data-key="no"][aria-pressed="true"], #w2-finished [data-key="no"][aria-pressed="true"], #w2-ontask [data-key="no"][aria-pressed="true"] { color: var(--w2-no); background: var(--w2-no-soft); box-shadow: inset 0 0 0 1.5px var(--w2-no); }

/* ---------- multi-select tiles ---------- */
.w2-tiles { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 8px; }
.w2-tile {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 9px; text-align: left;
  border: 1.5px solid var(--w2-line); border-radius: 12px; background: white; color: #1e293b;
  font-family: inherit; font-size: clamp(13px, 3.7vw, 15px); font-weight: 600; line-height: 1.15; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.w2-check { flex: none; width: 18px; height: 18px; border-radius: 5px; border: 2px solid #cbd5e1; display: flex; align-items: center; justify-content: center; transition: background 0.12s, border-color 0.12s; }
/* An odd "Other…" at the end takes the full row so the grid stays square. */
.w2-tile[data-key="other"]:last-child:nth-child(odd) { grid-column: 1 / -1; }
.w2-tile[aria-pressed="true"] { border-color: var(--w2); background: var(--w2-soft); color: var(--w2-dark); }
.w2-tile[aria-pressed="true"] .w2-check { background: var(--w2); border-color: var(--w2); }
.w2-tile[aria-pressed="true"] .w2-check::after { content: ''; width: 5px; height: 9px; border: solid white; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }

/* ---------- most-help ladder ---------- */
.w2-ladder { display: grid; gap: 6px; }
.w2-rung {
  display: grid; grid-template-columns: 6px 1fr 22px; align-items: center; gap: 12px; min-height: 52px; padding: 7px 12px 7px 8px;
  border: 1.5px solid var(--w2-line); border-radius: 12px; background: white; text-align: left; font-family: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.w2-rung-bar { width: 6px; height: 34px; border-radius: 3px; background: var(--lvl); }
.w2-rung-text b { display: block; font-size: 15px; color: var(--w2-ink); }
.w2-rung-text small { display: block; font-size: 12.5px; color: var(--w2-muted); margin-top: 1px; }
.w2-radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #cbd5e1; }
.w2-rung[aria-pressed="true"] { border-color: var(--lvl); background: color-mix(in srgb, var(--lvl) 8%, white); }
.w2-rung[aria-pressed="true"] .w2-radio { border: 7px solid var(--lvl); }

/* ---------- prompt counter ---------- */
.w2-counter { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 12px; padding: 6px; background: var(--w2-track); border-radius: 16px; }
.w2-count-btn { height: 56px; border-radius: 12px; border: none; background: white; color: var(--w2-dark); font-size: 28px; font-weight: 700; font-family: inherit; cursor: pointer; box-shadow: 0 1px 3px rgba(15,23,42,0.12); -webkit-tap-highlight-color: transparent; }
.w2-count-btn:active { transform: scale(0.96); }
.w2-count-btn:disabled { opacity: 0.35; }
.w2-plus { background: var(--w2); color: white; }
#w2-count { text-align: center; font-size: 34px; font-weight: 800; color: var(--w2-ink); font-variant-numeric: tabular-nums; }

/* ---------- save bar ---------- */
.w2-savebar { position: sticky; bottom: 0; margin: 20px -16px -18px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,0.97); backdrop-filter: blur(8px); border-top: 1px solid var(--w2-line); border-radius: 0 0 18px 18px; }
.w2-goal-status { font-size: 13px; font-weight: 600; padding: 7px 10px; border-radius: 10px; margin-bottom: 8px; }
.w2-goal-status.pending, .w2-goal-status.skip { background: var(--w2-track); color: var(--w2-muted); }
.w2-goal-status.met { background: var(--w2-met-soft); color: var(--w2-met); }
.w2-goal-status.notmet { background: var(--w2-no-soft); color: var(--w2-no); }
.w2-err { color: var(--w2-no); font-size: 14px; font-weight: 600; }
.w2-err:not(:empty) { margin-bottom: 8px; }
.w2-savebtns { display: flex; gap: 10px; }
.w2-save { flex: 1; min-height: 52px; border: none; border-radius: 14px; background: linear-gradient(135deg, var(--w2), var(--w2-dark)); color: white; font-size: 17px; font-weight: 800; font-family: inherit; cursor: pointer; box-shadow: 0 4px 14px rgba(29,78,216,0.3); }
.w2-save:disabled { opacity: 0.6; }
.w2-delete { padding: 0 18px; border-radius: 14px; border: 1.5px solid #fecaca; background: white; color: var(--w2-no); font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer; }
.w2-delete[hidden], .w2-edit-banner[hidden] { display: none; }
.w2-edit-banner { display: flex; justify-content: space-between; align-items: center; background: #fef3c7; color: #92400e; border-radius: 10px; padding: 6px 12px; margin-bottom: 14px; font-size: 14px; font-weight: 700; }
.w2-edit-banner .w2-textbtn { color: #92400e; text-decoration: underline; padding: 4px 0; margin: 0; }
.w2-textbtn { display: block; background: none; border: none; color: var(--w2); font-size: 14px; font-weight: 700; padding: 10px 0 0; cursor: pointer; font-family: inherit; text-align: left; }
.w2-textbtn span { font-weight: 500; color: var(--w2-muted); }

/* ---------- progress card ---------- */
.w2-prog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.w2-goalset { font-size: 13px; font-weight: 600; color: var(--w2-muted); display: flex; align-items: center; gap: 6px; }
.w2-goalset select { font-size: 15px; font-family: inherit; padding: 4px 6px; border: 1.5px solid var(--w2-line); border-radius: 8px; background: white; color: var(--w2-ink); }
.w2-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.w2-stat { background: #f8fafc; border: 1px solid var(--w2-line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 3px; }
.w2-stat-num { font-size: 26px; font-weight: 800; color: var(--w2-ink); line-height: 1; font-variant-numeric: tabular-nums; }
.w2-stat-num small { font-size: 15px; font-weight: 700; color: var(--w2-muted); }
.w2-stat-label { font-size: 11.5px; font-weight: 600; color: var(--w2-muted); line-height: 1.25; }
.w2-verdict { font-size: 11.5px; font-weight: 800; margin-top: 2px; }
.w2-verdict.ok { color: var(--w2-met); }
.w2-verdict.no { color: var(--w2-no); }
.w2-verdict.wait { color: var(--w2-muted); font-weight: 600; }
.w2-charts { margin-top: 12px; }
.w2-charts summary { font-size: 13px; font-weight: 700; color: var(--w2); cursor: pointer; padding: 4px 0; }
.w2-charts figure { margin-top: 10px; }
.w2-charts figcaption { font-size: 12px; font-weight: 800; color: #334155; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.w2-chart { width: 100%; height: auto; display: block; overflow: visible; }
.w2-chart-empty { font-size: 13px; color: var(--w2-muted); }
.c-grid { stroke: #e2e8f0; stroke-width: 1; }
.c-axis { stroke: #94a3b8; stroke-width: 1; }
.c-label { font-size: 11px; font-weight: 500; fill: #64748b; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.c-line { fill: none; stroke: var(--w2-dark); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; opacity: 0.55; }
.c-dot-met { fill: var(--w2-dark); stroke: white; stroke-width: 2; }
.c-dot-notmet { fill: white; stroke: var(--w2-dark); stroke-width: 2; }
.c-dot-none { fill: white; stroke: #94a3b8; stroke-width: 1.5; }
.c-bar { fill: #3b82f6; }
.c-target { fill: transparent; }
.c-hit:hover .c-bar { fill: var(--w2-dark); }
.c-hit:hover .c-dot-met, .c-hit:hover .c-dot-notmet { stroke-width: 3; }
.w2-key { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--w2-muted); margin-top: 4px; padding-left: 4px; }
.w2-key span { display: inline-flex; align-items: center; gap: 5px; }
.w2-key i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.k-met { background: var(--w2-dark); }
.k-notmet { border: 2px solid var(--w2-dark); width: 8px !important; height: 8px !important; }
.k-none { border: 1.5px solid #94a3b8; width: 7px !important; height: 7px !important; }

/* ---------- print card + list ---------- */
.w2-print-card h2 { margin-bottom: 12px; }
.w2-ranges { margin-top: 12px; }
.w2-ranges .w2-seg-btn { min-height: 40px; font-size: 13px; }
.w2-p-count { margin: 10px 2px 0; }
.w2-printbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.w2-printbtn { min-height: 64px; border-radius: 14px; border: none; background: var(--w2-ink); color: white; font-family: inherit; font-size: 15px; font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; }
.w2-printbtn small { font-size: 11.5px; font-weight: 500; opacity: 0.75; }
.w2-printbtn.w2-secondary { background: white; color: var(--w2-ink); border: 1.5px solid #cbd5e1; }
.w2-printbtn:disabled { opacity: 0.35; }
.w2-entry { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; background: white; border: none; border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(15,23,42,0.06); font-family: inherit; cursor: pointer; }
.w2-entry.editing { outline: 2px solid #f59e0b; background: #fffbeb; }
.w2-entry-main { flex: 1; min-width: 0; }
.w2-entry-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--w2-ink); }
.w2-entry-top span { color: var(--w2-muted); font-size: 13px; white-space: nowrap; }
.w2-entry-sum { display: block; margin-top: 4px; font-size: 13px; color: #475569; line-height: 1.4; }
.w2-badge { flex: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.w2-badge.met { background: var(--w2-met-soft); color: var(--w2-met); }
.w2-badge.notmet { background: var(--w2-no-soft); color: var(--w2-no); }
.w2-badge.none { background: var(--w2-track); color: #94a3b8; }
.w2-more { text-align: center; margin: 4px 0 12px; }
.w2-toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--w2-ink); color: white; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50; }
.w2-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- printed goal sheet ---------- */
@media print {
  .g2-sheet { color: #000; font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif; font-size: 9pt; }
  .g2-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.3in; border-bottom: 2px solid #000; padding-bottom: 6pt; margin-bottom: 8pt; }
  .g2-head h1 { font-size: 15pt; font-weight: 800; }
  .g2-head p { font-size: 9.5pt; margin-top: 2pt; }
  .g2-def { text-align: right; font-size: 8.5pt !important; color: #333; max-width: 4.2in; }
  .g2-codes { font-size: 8pt; margin-bottom: 6pt; line-height: 1.5; }
  .g2-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8pt; margin-bottom: 8pt; }
  .g2-stats .w2-stat { border: 1px solid #000; border-radius: 6pt; padding: 6pt 8pt; display: flex; flex-direction: column; gap: 2pt; background: white; }
  .g2-stats .w2-stat-num { font-size: 18pt; font-weight: 800; line-height: 1; }
  .g2-stats .w2-stat-num small { font-size: 11pt; font-weight: 700; color: #444; }
  .g2-stats .w2-stat-label { font-size: 8.5pt; color: #333; }
  .g2-stats .w2-verdict { font-size: 8.5pt; font-weight: 800; }
  .g2-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14pt; margin-bottom: 10pt; break-inside: avoid; }
  .g2-charts figcaption { font-size: 8.5pt; font-weight: 800; text-transform: uppercase; letter-spacing: 0.4pt; margin-bottom: 2pt; }
  .g2-charts .w2-chart { width: 100%; height: auto; }
  .g2-charts .w2-key { font-size: 8pt; color: #333; display: flex; gap: 10pt; }
  .g2-charts .w2-key i { display: inline-block; width: 8pt; height: 8pt; border-radius: 50%; margin-right: 3pt; vertical-align: -1pt; }
  .g2-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 8.5pt; line-height: 1.25; }
  .g2-table thead { display: table-header-group; }
  .g2-table th { background: #eee; font-weight: 800; text-align: left; font-size: 8pt; }
  .g2-table th, .g2-table td { border: 1px solid #000; padding: 3pt 4pt; vertical-align: top; overflow-wrap: anywhere; }
  .g2-table tr { break-inside: avoid; page-break-inside: avoid; }
  .g2-table .g2-num { text-align: center; font-weight: 700; }
  .g2-table .g2-notes { font-size: 8pt; }
  .g2-sub { color: #444; font-size: 7.5pt; }
  .g2-blank td { height: 0.42in; }
}

/* ---------- dictation fill ---------- */
.w2-dictate { background: linear-gradient(180deg, #f8fafc, white); margin: -18px -16px 0; padding: 18px 16px 16px; border-radius: 18px 18px 0 0; border-bottom: 1px solid var(--w2-line); }
.w2-dictate + .w2-sec { border-top: none; }
.w2-mic { background: #fef3c7; font-size: 14px; }
#w2-dictation { width: 100%; min-height: 84px; padding: 12px; border: 1.5px solid var(--w2-line); border-radius: 12px; font-size: 16px; font-family: inherit; line-height: 1.4; resize: vertical; background: white; color: var(--w2-ink); }
#w2-dictation:focus, #w2-names:focus { outline: none; border-color: var(--w2); box-shadow: 0 0 0 3px rgba(29,78,216,0.15); }
.w2-names { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 8px; }
#w2-names { min-width: 0; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--w2-line); border-radius: 12px; font-size: 16px; font-family: inherit; background: #f8fafc; color: var(--w2-ink); }
.w2-fill { min-height: 46px; padding: 0 16px; border: none; border-radius: 12px; background: #b45309; color: white; font-size: 15px; font-weight: 800; font-family: inherit; cursor: pointer; white-space: nowrap; box-shadow: 0 3px 10px rgba(180,83,9,0.28); }
.w2-fill:disabled { opacity: 0.6; }
.w2-fine { font-size: 12px; color: var(--w2-muted); margin-top: 6px; line-height: 1.4; }
.w2-ai-key { display: inline-block; padding: 0 5px; border: 1.5px dashed #d97706; border-radius: 5px; color: #92400e; font-weight: 700; }
.w2-fill-status { font-size: 13.5px; font-weight: 600; color: var(--w2-muted); }
.w2-fill-status:not(:empty) { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--w2-track); }
.w2-fill-status.ok { background: #fffbeb; color: #92400e; }
.w2-fill-status.err { background: var(--w2-no-soft); color: var(--w2-no); }
/* A suggestion stays dashed amber until the teacher taps that box. */
.w2-ai .w2-seg-btn[aria-pressed="true"], .w2-ai .w2-rung[aria-pressed="true"], .w2-tile.w2-ai[aria-pressed="true"] {
  outline: 2px dashed #d97706; outline-offset: 2px;
}
.w2-tile.w2-ai[aria-pressed="true"] { background: #fffbeb; }
.w2-counter.w2-ai { outline: 2px dashed #d97706; outline-offset: 2px; }
#w2-comments.w2-ai { border: 2px dashed #d97706; background: #fffbeb; }
