/* Shared workbook presentation and sizing. */
:root {
  font-family:'Aptos Narrow','Arial Narrow',Aptos,Calibri,Arial,sans-serif;
  color:#111;background:#fff;
  --green:#196b24;--muted:#555;--line:#b7b7b7;
  --border:#888;--grid:#d0d0d0;--surface:#e8e8e8;
  --space-1:4px;--space-2:8px;--space-3:12px;--space-4:16px;--space-6:24px;
  --font-body:13px;--font-small:12px;--font-heading:16px;--font-title:24px;
  --control-height:32px;--page-padding:16px;--panel-padding:12px;--section-gap:12px;
  --fixed:403px;
}
[hidden]{display:none!important}
html,body{width:100%;height:100%;margin:0;overflow:hidden;background:#fff}
body,button,input,select,textarea{font-family:inherit;font-size:var(--font-body);line-height:1.4}
h1,h2,h3,.metric-value{font-family:inherit;letter-spacing:0;color:#111}
h1{font-size:var(--font-title);font-weight:700;line-height:1.2}
h2{font-size:var(--font-heading);font-weight:700;line-height:1.25}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible{outline:2px solid #555;outline-offset:2px}
.page{margin:0;width:100%;height:100dvh;min-width:0}
main{max-width:none;margin:0;height:100%;min-width:0;padding:var(--page-padding);display:flex;flex-direction:column;gap:var(--section-gap)}
main>.compact-header,main>.metrics,main>.subject-section,main>.migration-banner,main>.page-footer{flex-shrink:0;margin:0}
.compact-header{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:var(--space-2) var(--space-4);min-height:var(--control-height)}
.compact-header h1{white-space:nowrap}
.header-actions{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space-2)}
.save-state,.header-actions .save-state{font-size:var(--font-small);color:var(--muted);margin:0}
.button,.button.small,.button.primary,.header-actions .button{height:var(--control-height);min-height:var(--control-height);padding:0 var(--space-3);display:inline-flex;align-items:center;justify-content:center;gap:var(--space-2);border:1px solid var(--border);border-radius:2px;background:#fff;color:#111;font-size:var(--font-body);line-height:1;font-weight:400;white-space:nowrap}
.button:hover,.button.small:hover{background:var(--surface)}
.button.primary{background:var(--surface);font-weight:700}
.button.primary:hover{background:#d9d9d9}
.button.danger{color:#c00000;background:#fff;border-color:transparent}
.button.primary>span{font-size:20px;line-height:1}
.icon-button{width:var(--control-height);height:var(--control-height);padding:0;display:inline-grid;place-items:center;border:0;border-radius:2px;background:transparent;color:#333;font-size:24px;line-height:1}
.icon-button:hover{background:var(--surface)}
.text-button,.page-footer button{height:24px;padding:0;display:inline-flex;align-items:center;gap:var(--space-2);border:0;background:none;font-size:var(--font-small);line-height:1.4;color:#333;text-decoration:underline}
.text-button>span{margin:0}
.text-button:hover{color:var(--green)}
button:disabled{cursor:wait;opacity:.6}

/* Overview panels share the same insets and text hierarchy. */
.metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:0;padding:0;border:1px solid var(--border);border-radius:0;background:#fff}
.metric{display:grid;grid-template-rows:auto auto auto;padding:0;border-right:1px solid var(--border)}
.metric:last-child{border-right:0}
.metric-label{display:flex;align-items:center;min-height:32px;margin:0;padding:var(--space-1) var(--panel-padding);background:var(--surface);border-bottom:1px solid var(--border);font-size:var(--font-body);font-weight:700;color:#111}
.metric-label>span{display:none}
.metric-value{padding:var(--space-2) var(--panel-padding) 0;font-size:24px;font-weight:400;line-height:1.2;text-align:right}
.metric-value small{font-family:inherit;font-size:var(--font-small);font-weight:400;color:#333;letter-spacing:0;margin-left:var(--space-1)}
.metric-note{margin:0;padding:var(--space-1) var(--panel-padding) var(--space-2);font-size:var(--font-small);line-height:1.4;text-align:right;color:var(--muted)}
.metric-note.good{color:var(--green)}.metric-note.warning{color:#c00000}
.section-title{display:flex;align-items:center;justify-content:space-between;gap:var(--space-2);margin-bottom:var(--space-2);min-height:24px}
.section-title h2{font-size:var(--font-heading)}
.section-title h2 span{font-family:inherit;font-size:var(--font-small);font-weight:400;color:var(--muted);margin-left:var(--space-2)}
.subject-cards{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0;margin:0;border:1px solid var(--border)}
.subject-card{position:relative;min-width:0;padding:0;text-align:left;border:0;border-right:1px solid var(--border);border-radius:0;background:#fff;color:#111;box-shadow:none;transition:none}
.subject-card:last-child{border-right:0}
.subject-card:hover{transform:none;background:#fafafa;border-color:var(--border);box-shadow:none}
.subject-card:hover::after,.subject-card.selected::after{content:'';position:absolute;inset:0;border:2px solid #555;z-index:2;pointer-events:none}
.subject-card.selected{background:#f4f4f4;border-color:var(--border);box-shadow:none}
.subject-card.selected .subject-card-top{background:#d9d9d9}
.subject-card-top{display:flex;align-items:center;min-height:32px;padding:var(--space-1) var(--panel-padding);gap:0;background:var(--surface);border-bottom:1px solid var(--border);font-size:14px;font-weight:700;line-height:1.25;color:#111}
.subject-card .subject-icon,.subject-card-top .arrow{display:none}
.subject-card .exam-label{margin:var(--space-2) var(--panel-padding);font-size:var(--font-small);line-height:1.4;color:#c00000}
.progress-line{display:flex;align-items:center;justify-content:space-between;gap:var(--space-1);margin:0 var(--panel-padding) var(--space-2);font-size:var(--font-small);color:#333}
.progress-line strong{font-weight:400;color:#111}
.progress{height:4px;margin:0 var(--panel-padding);border-radius:0;background:var(--surface);overflow:hidden}
.progress i{display:block;height:100%;border-radius:0;background:#75a67c}
.subject-card .subject-card-bottom{display:flex;justify-content:space-between;gap:var(--space-2);margin:var(--space-2) var(--panel-padding);font-size:var(--font-small);line-height:1.4;color:var(--muted)}
.subject-card-bottom strong{font-weight:400;color:#111;white-space:nowrap}

/* The chart fills the remaining viewport; controls use one shared height. */
.planner{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0;border:1px solid var(--border);border-radius:0;background:#fff;overflow:hidden}
.planner-heading{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;flex-shrink:0;padding:var(--panel-padding);gap:var(--space-2) var(--space-4)}
.planner-heading>div:first-child{flex:1 1 420px;min-width:0}
.planner-heading h2{font-size:var(--font-heading)}
.planner-heading p{margin-top:var(--space-1);font-size:var(--font-small);line-height:1.4;color:var(--muted)}
.planner-heading .projected-finish-summary{font-size:inherit;color:inherit;white-space:nowrap}
.planner-heading .toolbar{display:flex;align-items:center;flex:0 1 auto;min-width:0;margin-left:auto;padding:0;gap:var(--space-2)}
.planner-heading .filter-controls{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;width:auto;gap:var(--space-2)}
#expandChart{width:var(--control-height);min-width:var(--control-height);padding:0;flex:0 0 var(--control-height);aspect-ratio:1}
#expandChart svg{display:block;width:18px;height:18px}
#expandChart .minimize-icon,#expandChart[aria-pressed="true"] .maximize-icon{display:none}
#expandChart[aria-pressed="true"] .minimize-icon{display:block}
.search,.planner-heading .toolbar .search{display:flex;align-items:center;flex:0 1 180px;width:180px;min-width:120px;height:var(--control-height);min-height:var(--control-height);padding:0 var(--space-2);gap:var(--space-2);border:1px solid var(--border);border-radius:2px;background:#fff}
.search-icon{display:block;width:16px;height:16px;flex-shrink:0;color:var(--muted)}
.search input,.toolbar .search input{width:100%;min-width:0;margin:0;padding:0;border:0;outline:none!important;background:transparent;font-size:var(--font-body);line-height:1.4;color:#111}
.search:focus-within{outline:2px solid #555;outline-offset:2px}
.toolbar select{width:120px;max-width:none;height:var(--control-height);padding:0 var(--space-2);border:1px solid var(--border);border-radius:2px;background:#fff;font-size:var(--font-body);line-height:1.4;color:#111}
.incomplete-filter{position:relative;display:flex;align-items:center;gap:var(--space-2);height:var(--control-height);min-height:var(--control-height);margin:0;padding:0;flex-basis:auto;white-space:nowrap;font-size:var(--font-body);line-height:1.4;color:#111;cursor:pointer}
.incomplete-filter input{position:absolute;width:1px;height:1px;opacity:0}
.switch-track{display:block;position:relative;width:30px;height:18px;flex-shrink:0;border:1px solid var(--border);border-radius:10px;background:#ddd}
.switch-track::after{content:'';position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #0003}
.incomplete-filter input:checked+.switch-track{background:var(--green);border-color:var(--green)}
.incomplete-filter input:checked+.switch-track::after{transform:translateX(12px)}
.incomplete-filter input:focus-visible+.switch-track{outline:2px solid #555;outline-offset:2px}
.chart-scroll{flex:1;min-height:0;max-height:none;overflow:auto;border-top:1px solid #000;scrollbar-color:#bbb #f3f3f3;scrollbar-width:thin}
.chart{position:relative;width:max-content;min-width:100%;font-size:14px;--header-height:76px}
.chart-row{display:flex;position:relative;height:24px;border-bottom:1px solid var(--grid)}
.fixed{display:flex;align-items:center;position:sticky;left:0;z-index:4;width:var(--fixed);flex-shrink:0;background:#fff;border-right:1px solid #000}
.task-col{display:flex;align-items:center;gap:var(--space-2);width:199px;min-width:0;height:100%;padding-left:var(--panel-padding);flex-shrink:0;border-right:1px solid #999;font-size:14px}
.number-col{display:flex;align-items:center;justify-content:flex-end;width:60px;height:100%;padding-right:var(--space-2);flex-shrink:0;border-right:1px solid #999;font-size:14px;line-height:1.2;color:#111}
.complete-col{display:flex;align-items:center;width:84px;height:100%;padding-left:var(--space-2);flex-shrink:0;font-size:14px;line-height:1.2;color:#111}
.task-name{min-width:0;padding:0;border:0;background:none;font-size:14px;line-height:1.2;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#111}
.task-completed .task-name{color:#111}.task-name:hover{color:var(--green);text-decoration:underline}
.check{display:grid;place-items:center;width:15px;height:15px;flex-shrink:0;margin:0;padding:0;border:1px solid #777;border-radius:0;background:#fff;color:transparent;font-size:11px;line-height:1}
.check.done{background:#75a67c;border-color:#397d40;color:#134f1a}
.complete-date{background:#dcebdc;color:#134f1a}
.chart-row:hover .task-fixed{background:#f5f5f5}
.chart-header{position:sticky;top:0;z-index:10;height:var(--header-height);border-bottom:1px solid #000;background:var(--surface)}
.chart-header .fixed{z-index:11;background:var(--surface)}
.chart-header .task-col,.chart-header .number-col,.chart-header .complete-col{font-size:var(--font-body);font-weight:700;letter-spacing:0;color:#111}
.chart-header .number-col,.chart-header .complete-col{justify-content:center;padding:0}
.date-grid{display:flex;position:relative;isolation:isolate}
.day{position:relative;width:var(--day);flex-shrink:0;border-right:1px solid var(--grid);background:#fff}
.day.weekend{background:#f1f1f1!important}
.date-head{display:flex;flex-direction:column;justify-content:center;text-align:center;padding:24px 0 0;gap:var(--space-1);background:var(--surface)!important;border-right:1px dashed #999;color:#111}
.date-head small{font-size:10px;line-height:12px;color:inherit}
.date-head b,.date-head.is-today b{align-self:auto;padding:0;border-radius:0;background:none;font-size:13px;font-weight:400;line-height:18px;color:inherit}
.date-head.weekend,.date-head.is-today.weekend{background:#d9d9d9!important;color:#111}
.date-head.is-today{background:var(--surface)!important}
.date-head.is-today small,.date-head.is-today b{font-weight:700}
.chart .date-head.date-highlight,.chart .date-head.exam-day.date-highlight{background:#ccc!important;box-shadow:none;color:#111}
.month-band{position:absolute;top:0;left:0;right:0;display:flex;height:23px;z-index:2;border-bottom:1px solid #000;pointer-events:none}
.month-band span{display:block;flex-shrink:0;padding:var(--space-1) var(--space-2);border-right:1px solid #000;background:var(--surface);font-size:var(--font-body);font-weight:700;line-height:14px;text-align:left;white-space:nowrap;overflow:hidden;color:#111}
.month-band span:last-child,.date-grid>.day:last-of-type{border-right:0}
.day.is-today::after,.exam-day::before{display:none}
.subject-group{position:relative}
.subject-row{position:sticky;top:var(--header-height);z-index:8;height:28px;border-top:1px solid #000;border-bottom:1px solid #000;background:var(--surface)}
.subject-row .fixed,.subject-row .day{background:var(--surface)}
.subject-row .day.weekend{background:#dedede!important}
.group-toggle{display:flex;align-items:center;gap:var(--space-2);width:100%;min-height:24px;padding:0 var(--panel-padding);border:0;background:transparent;font-size:14px;font-weight:700;line-height:1.2;text-align:left;color:#111}
.group-toggle small{margin-left:auto;padding:0;font-size:var(--font-small);font-weight:400;white-space:nowrap;color:#333}
.course-chevron{width:16px;height:16px;flex-shrink:0;transform:rotate(90deg)}
.group-toggle[aria-expanded="false"] .course-chevron{transform:rotate(0)}
.chart .day.task-incomplete{background:#ff0000!important}
.cell-button{position:relative;z-index:2;display:block;width:100%;height:100%;margin:0;padding:0;border:0;background:transparent}
.chart .day .cell-button:hover{background:#d9d9d9;z-index:5}
.completion-mark{position:absolute;inset:0;display:grid;place-items:center;z-index:4;background:#75a67c;border-radius:0;color:#134f1a;pointer-events:none}
.plan-bar{position:absolute;top:0;height:100%;z-index:6;display:flex;align-items:center;padding:0 var(--space-2);border:1px solid #888;border-radius:0;background:#e3e3e3;font-size:var(--font-small);line-height:1.2;white-space:nowrap;overflow:hidden;text-align:left;color:#333}
.plan-bar.done{background:#dcebdc;border-color:#397d40;color:#134f1a}
.chart .plan-bar:hover{background:#d9d9d9;border-color:#999;color:#111}
.plan-label{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.chart .day.exam-day:not(.task-incomplete){background:#fff3d0!important}
.chart .date-head.exam-day{color:#111}
.exam-tag{position:absolute;inset:0;z-index:2;display:flex;align-items:center;justify-content:center;writing-mode:horizontal-tb;background:#fff3d0;border-radius:0;font-size:var(--font-small);font-weight:700;line-height:1;white-space:nowrap;overflow:hidden;color:#ff0000}
.chart-footer{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;gap:var(--space-3);padding:var(--space-2) var(--panel-padding);border-top:1px solid var(--border);font-size:var(--font-small);line-height:1.4;color:var(--muted)}
.legend{display:flex;flex-wrap:wrap;gap:var(--space-2) var(--space-4)}
.legend span{display:flex;align-items:center;gap:var(--space-1)}
.legend i{display:block;width:10px;height:10px;flex-shrink:0;border:1px solid #999;border-radius:0}
.legend .legend-incomplete{background:#ff0000;border-color:#c00000}.legend .legend-planned{background:#e3e3e3}.legend .legend-completed{background:#75a67c}.legend .legend-exam{background:#fff3d0}
.legend .legend-finish{width:0;border:0;border-left:2px solid #333}
.page-footer{display:flex;align-items:center;justify-content:space-between;gap:var(--space-2) var(--space-4);padding:0;font-size:var(--font-small);line-height:1.4;color:var(--muted)}
.page-footer>span{max-width:none;font-size:inherit;line-height:inherit}
.footer-actions{display:flex;gap:var(--space-4);flex-shrink:0}
main.chart-expanded>:is(.compact-header,.metrics,.subject-section,.migration-banner){display:none}

/* One overlay keeps the projected finish continuous and above the grid. */
.projected-finish-line{position:absolute;top:var(--header-height);bottom:0;width:2px;transform:translateX(-50%);background:#333;z-index:9;pointer-events:none}
.date-head.projected-finish::after{content:'';display:block;position:absolute;bottom:0;top:auto;height:8px;left:50%;right:auto;width:2px;transform:translateX(-50%);background:#333;opacity:1;z-index:7;pointer-events:none}
.projected-finish-flag{position:absolute;left:50%;top:25px;width:7px;height:7px;background:#333;transform:translateX(-50%) rotate(45deg);z-index:8;pointer-events:none}
.finish-marker{position:absolute;top:0;bottom:0;left:50%;width:12px;transform:translateX(-50%);z-index:8;cursor:default}
.date-head .finish-marker{top:23px}
.date-head.projected-finish b{font-weight:700}

/* Forms and dialogs use the same control heights, gaps, and type sizes. */
dialog{width:520px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);padding:var(--space-6);border:1px solid var(--border);border-radius:2px;background:#fff;color:#111;box-shadow:0 12px 50px #0003;overflow:auto}
dialog::backdrop{background:#0004;backdrop-filter:none}
.dialog-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--space-3);margin-bottom:var(--space-4)}
.dialog-heading h2{font-size:20px}
.dialog-heading .icon-button{line-height:1}
.eyebrow,.dialog-heading .eyebrow{margin-bottom:var(--space-1);font-size:var(--font-small);font-weight:400;letter-spacing:.6px;color:var(--muted)}
dialog label,.auth-panel label{display:flex;flex-direction:column;gap:var(--space-1);margin-bottom:var(--space-3);font-size:var(--font-body);line-height:1.4;color:#333}
dialog input,dialog select,dialog textarea,.auth-panel input{width:100%;height:var(--control-height);margin:0;padding:0 var(--space-2);border:1px solid var(--border);border-radius:2px;background:#fff;font-size:var(--font-body);line-height:1.4;color:#111}
dialog textarea{height:auto;min-height:80px;padding:var(--space-2);resize:vertical}
input[readonly]{background:#f3f3f3;color:var(--muted)}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:0 var(--space-3)}
.field-note,#estimateNote{margin:0 0 var(--space-3);font-size:var(--font-small);line-height:1.4;color:var(--muted)}
.form-error{font-size:var(--font-body);line-height:1.4;color:#c00000}
.dialog-actions{display:flex;align-items:center;justify-content:flex-end;gap:var(--space-2);margin-top:var(--space-4)}
.dialog-actions>span{flex:1}
.auth-screen{height:100dvh;min-height:0;display:grid;align-items:safe center;justify-items:center;padding:var(--space-6);background:#f5f5f5;overflow:auto}
.auth-panel{width:min(420px,100%);padding:var(--space-6);border:1px solid var(--border);background:#fff}
.auth-panel h1{margin-bottom:var(--space-4)}
.auth-panel h2{margin-bottom:var(--space-2);font-size:var(--font-heading)}
.auth-panel p{margin-bottom:var(--space-4);font-size:var(--font-body);line-height:1.4;color:var(--muted)}
.auth-panel .button{margin:var(--space-2) var(--space-2) 0 0}
.auth-panel .form-error{color:#c00000}
.migration-banner{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space-2);padding:var(--panel-padding);border:1px solid #c9b977;background:#fff3d0;font-size:var(--font-body)}
.saving .dialog-actions button,.saving [data-toggle],.saving [data-task],.saving #signOut{pointer-events:none;opacity:.6}
.toast{position:fixed;bottom:var(--space-6);left:50%;transform:translateX(-50%);z-index:50;padding:var(--space-2) var(--space-3);border:1px solid var(--border);border-radius:2px;background:var(--surface);font-size:var(--font-body);line-height:1.4;color:#111;box-shadow:0 3px 15px #0002;opacity:0;pointer-events:none}
.toast.visible{opacity:1}
.empty-state{padding:var(--space-6);color:var(--muted)}
.empty-state strong{display:block;margin-bottom:var(--space-2);color:#111}

/* Compact layouts keep controls uniform rather than scaling individual elements. */
@media(max-width:850px){
  .header-actions .save-state{display:none}
  .chart-footer>span{display:none}
}
@media(max-width:600px){
  :root{--font-body:12px;--font-small:11px;--font-heading:14px;--font-title:20px;--page-padding:8px;--panel-padding:8px;--section-gap:8px;--fixed:309px}
  .header-actions{margin-left:auto}
  .metrics{grid-template-columns:repeat(2,minmax(0,1fr))}
  .metric:nth-child(2){border-right:0}
  .metric:nth-child(-n+2){border-bottom:1px solid var(--border)}
  .subject-card-top{min-height:40px;font-size:var(--font-body)}
  .subject-card .subject-card-bottom{flex-wrap:wrap;gap:var(--space-1)}
  .planner-heading>div:first-child{flex-basis:100%}
  .planner-heading .toolbar{flex:1 1 100%;width:100%}
  .planner-heading .filter-controls{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));width:100%;gap:var(--space-2)}
  .planner-heading .toolbar .search{width:100%;min-width:0;flex:none}
  .toolbar select{width:100%;justify-self:end}
  .incomplete-filter,#expandChart{justify-self:end}
  .task-col{width:155px;font-size:12px}
  .task-name,.number-col,.complete-col{font-size:12px}
  .number-col{width:45px;padding-right:var(--space-1)}
  .complete-col{width:64px;padding-left:var(--space-1)}
  .chart-header .task-col,.chart-header .number-col,.chart-header .complete-col{font-size:11px}
  .group-toggle{font-size:12px}
  .group-toggle small{display:none}
  .legend{gap:var(--space-1) var(--space-2)}
  .page-footer{flex-wrap:wrap}
  .footer-actions{margin-left:auto}
  dialog{padding:var(--space-4);max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px)}
}
@media(max-height:800px){.metrics{display:none}}
@media(max-height:500px){
  :root{--page-padding:8px;--panel-padding:8px;--section-gap:8px}
  .subject-card .progress-line,.subject-card .subject-card-bottom{display:none}
  .subject-card-top{min-height:28px}
  .subject-card .exam-label{margin-top:var(--space-1);margin-bottom:var(--space-1)}
  .subject-card .progress{margin-bottom:var(--space-1)}
  .planner-heading p{display:none}
}
@media(max-width:600px) and (max-height:700px){
  :root{--panel-padding:4px;--section-gap:4px}
  .section-title{margin-bottom:var(--space-1)}
  .subject-card .exam-label,.subject-card .progress-line,.subject-card .subject-card-bottom{display:none}
  .subject-card .progress{margin-top:var(--space-1);margin-bottom:var(--space-1)}
  .planner-heading{gap:var(--space-1)}
}
