:root {
  --bg: #f4f6f5;
  --paper: #fff;
  --ink: #172c2a;
  --muted: #60716e;
  --line: #dce5e1;
  --accent: #176853;
  --soft: #eaf3ee;
  --dark: #183c35;
  --warn: #a15a1f;
}

* {
  box-sizing: border-box;
}

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

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 13px;
  min-height: 44px;
  max-width: 100%;
}

button:hover {
  border-color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

button.danger {
  color: #a33030;
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

input, select, textarea {
  border: 1px solid #cbd9d2;
  border-radius: 7px;
  padding: 9px;
  background: white;
  color: var(--ink);
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

input[type=checkbox] {
  width: auto;
  accent-color: var(--accent);
}

textarea {
  min-height: 95px;
  resize: vertical;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

label > input, label > select, label > textarea {
  display: block;
  margin-top: 4px;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: 25px;
  letter-spacing: -.5px;
}

h2 {
  font-size: 19px;
}

h3 {
  font-size: 16px;
}

small, .muted {
  color: var(--muted);
}

.shell {
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--dark);
  color: white;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  overflow-y: auto;
}

.brand {
  padding: 0 8px;
}

.brand b {
  font-size: 20px;
  line-height: 1.15;
  display: block;
}

.brand small {
  color: #b8d1c8;
}

.nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.nav button {
  text-align: left;
  background: transparent;
  color: #d6e8e2;
  border: 0;
  padding: 12px;
}

.nav button:focus-visible {
  outline-color: white;
  outline-offset: -2px;
}

.nav button.active {
  background: #ffffff20;
  color: white;
  font-weight: 700;
}

.sidebar footer {
  margin-top: auto;
  color: #bed3cc;
  font-size: 12px;
  padding: 8px;
}

.main {
  padding: 24px 32px 45px;
  max-width: 1360px;
  width: 100%;
  margin: auto;
  min-width: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  margin-bottom: 24px;
}

.timer {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 11px;
  flex-wrap: wrap;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 700;
}

.timer small {
  display: block;
  max-width: 145px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 17px;
  margin-bottom: 14px;
}

.panel .panel {
  margin-bottom: 0;
}

.hero {
  background: var(--dark);
  color: white;
  border-radius: 14px;
  padding: 23px;
  margin-bottom: 15px;
}

.hero small {
  color: #c4ded5;
}

.hero h2 {
  font-size: 29px;
  margin: 5px 0;
}

.stat strong {
  font-size: 27px;
  display: block;
  letter-spacing: -.8px;
}

.stat small {
  display: block;
}

.section {
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.spread {
  justify-content: space-between;
}

.row > * {
  min-width: 0;
  max-width: 100%;
}

.grow {
  flex: 1 1 140px;
  min-width: 0;
}

.tag {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--soft);
  color: var(--accent);
  display: inline-block;
}

.late {
  background: #fff0e4;
  color: var(--warn);
}

.item {
  border: 1px solid var(--line);
  padding: 13px;
  border-radius: 9px;
  background: white;
}

.item h3 {
  margin: 3px 0;
}

.empty {
  padding: 20px 10px;
  color: var(--muted);
  text-align: center;
}

.fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.fields.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.bar {
  appearance: none;
  display: block;
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 9px;
  background: #e4ebe7;
  overflow: hidden;
  margin-top: 8px;
}

.bar::-webkit-progress-bar { background: #e4ebe7; }
.bar::-webkit-progress-value { background: var(--accent); }
.bar::-moz-progress-bar { background: var(--accent); }

.check {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.check:last-child {
  border: 0;
}

.check label {
  font-size: 15px;
  color: var(--ink);
  font-weight: 400;
  flex: 1;
}

.check input {
  width: 17px;
  height: 17px;
  margin: 0;
}

.textdoc {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: inherit;
  line-height: 1.65;
}

.docbody {
  font-size: 15px;
}

.docbody h2, .docbody h3 {
  margin: 13px 0 7px;
}

.docbody p {
  margin: 6px 0;
}

.docbody ul {
  margin: 5px 0;
  padding-left: 22px;
}

.docbody li {
  margin: 3px 0;
}

.subtle {
  background: var(--soft);
  padding: 12px;
  border-radius: 8px;
}

.note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.tablewrap {
  max-width: 100%;
  overflow: auto;
}

.tablewrap:focus-visible {
  outline-offset: -2px;
}

table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  text-align: left;
}

th, td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 12px;
  color: var(--muted);
}

dialog {
  border: 1px solid var(--line);
  border-radius: 13px;
  width: min(740px, calc(100% - 24px));
  max-height: 90vh;
  max-height: 90dvh;
  padding: 22px;
  color: var(--ink);
  overflow: auto;
}

dialog::backdrop {
  background: #102c2780;
}

dialog form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  max-width: min(360px, calc(100% - 40px));
  background: var(--dark);
  color: white;
  padding: 12px 18px;
  border-radius: 9px;
  z-index: 99;
  box-shadow: 0 5px 20px #0002;
}

.toast[hidden] {
  display: none;
}

#printRoot {
  display: none;
}

.question {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 8px 0;
}

.choice {
  display: block;
  min-height: 44px;
  cursor: pointer;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 5px 0;
}

.choice input {
  display: inline-block;
  width: auto;
  vertical-align: middle;
  margin: 0 8px 0 0;
}

.feedback {
  margin-top: 8px;
  padding: 8px;
  background: var(--soft);
  border-radius: 6px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar input, .toolbar select {
  width: auto;
  max-width: 100%;
  flex: 1;
  min-width: 120px;
}

.warning {
  color: var(--warn);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    gap: 12px;
    overflow: visible;
  }
  .sidebar footer {
    display: none;
  }
  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .main {
    padding: 16px;
  }
  .top {
    flex-wrap: wrap;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid, .two, .fields, .fields.two {
    grid-template-columns: minmax(0, 1fr);
  }
  .main {
    padding: 12px;
  }
  .top {
    margin-bottom: 12px;
  }
  .timer {
    width: 100%;
  }
  dialog {
    padding: 16px;
  }
  .toast {
    bottom: 12px;
    right: 12px;
    max-width: calc(100% - 24px);
  }
  input, select, textarea {
    font-size: 16px;
  }
}

@page {
  size: A4;
  margin: 16mm 15mm;
}

@media print {
  body {
    background: white;
    color: black;
  }
  .shell, dialog, .toast, .loginGate {
    display: none !important;
  }
  #printRoot {
    display: block !important;
    font-family: Arial, sans-serif;
    font-size: 11pt;
    line-height: 1.45;
  }
  .printcard {
    break-after: page;
  }
  .printcard:last-child {
    break-after: auto;
  }
  .printhead {
    font-size: 10pt;
    border-bottom: 1px solid #555;
    padding-bottom: 6px;
    margin-bottom: 10px;
  }
  .printcard h1 {
    font-size: 16pt;
    margin: 8px 0;
  }
  .printcard h2 {
    font-size: 13pt;
    break-after: avoid;
  }
  .printcard h3 {
    font-size: 12pt;
    break-after: avoid;
  }
  .printcard p, .printcard li {
    orphans: 3;
    widows: 3;
  }
  .printfoot {
    margin-top: 16px;
    font-size: 10pt;
    border-top: 1px solid #999;
    padding-top: 6px;
  }
  .printcard .textdoc {
    font-size: 11pt;
  }
  .printcard .docbody {
    font-size: 11pt;
  }
}

.review-date {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  margin: 7px 0;
}

.review-date span {
  font-size: 12px;
  color: var(--muted);
}

.review-date b {
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.review-group > h3 {
  margin: 8px 0;
  font-size: 16px;
}

.review-group + .review-group {
  margin-top: 10px;
}

.urgent {
  border: 2px solid #b45309;
  background: #fff5e7;
}

.urgent h2 {
  color: #92400e;
}

.urgent .primary {
  background: #92400e;
  border-color: #92400e;
}

.plancheck {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
}

.plancheck input {
  width: 20px;
  height: 20px;
  flex: none;
}

.plancheck span {
  display: grid;
  min-width: 0;
}

.doneLesson {
  background: #eaf3ee;
}

.planday .grid {
  margin-top: 10px;
}

.planlesson {
  min-width: 0;
}

.reviewcheck {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.reviewcheck input {
  width: 18px;
  height: 18px;
}

.planlesson strong {
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

.loginGate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.loginGate form {
  width: min(100%, 410px);
  display: grid;
  gap: 15px;
  padding: 25px;
}

.syncbar {
  margin-top: -8px;
}

.syncbar [data-state="warning"] {
  color: #a15a1f;
}

@media (max-width: 600px) {
  .syncbar {
    align-items: flex-start;
  }
  .syncbar .row {
    width: 100%;
  }
  .syncbar button {
    flex: 1 1 115px;
    padding: 8px;
  }
  .loginGate form {
    padding: 20px;
  }
}

.mt-0 { margin-top: 0; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-15 { margin-top: 15px; }
.mb-6 { margin-bottom: 6px; }
.mb-12 { margin-bottom: 12px; }
.my-8 { margin-block: 8px; }
.my-10 { margin-block: 10px; }
.material-editor { min-height: 250px; }
.import-editor { min-height: 300px; }

.library-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.library-totals {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px 12px;
}

.library-totals dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.pdf-details {
  margin-top: 10px;
}

.pdf-details summary {
  min-height: 44px;
  padding: 10px 2px;
  color: var(--accent);
  cursor: pointer;
}

.pdf-details small {
  display: block;
}

.pdf-details dd {
  margin-inline-start: 16px;
}

.pdf-details pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pwa-notices p:first-child {
  margin-top: 0;
}

.pwa-steps {
  display: grid;
  gap: 12px;
  margin-block: 14px;
}

#pwaInstallButton,
#pwaCheckUpdate {
  margin-top: 8px;
}
