:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e1ec;
  --text: #182233;
  --muted: #68758a;
  --primary: #1476d4;
  --primary-soft: #e8f2ff;
  --warn: #a85d00;
  --warn-bg: #fff4df;
  --danger: #b42318;
  --danger-bg: #fff0ed;
  --shadow: 0 10px 30px rgba(27, 39, 63, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
}

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status {
  min-width: 68px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.status.loading {
  color: var(--primary);
}

button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: var(--primary);
}

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

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.summary {
  display: grid;
  grid-template-columns: 150px 150px 150px 150px 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  line-height: 1.2;
}

.metric.wide strong {
  font-size: 18px;
  word-break: break-word;
}

.metric.danger-metric {
  border-color: #f0b5af;
  background: var(--danger-bg);
}

.metric.danger-metric strong {
  color: var(--danger);
}

.metric.warn-metric {
  border-color: #f1cf94;
  background: var(--warn-bg);
}

.metric.warn-metric strong {
  color: var(--warn);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e9eef6;
  border-radius: 8px;
  margin-bottom: 18px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 22px;
}

.tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(27, 39, 63, .08);
}

.hidden {
  display: none !important;
}

.error {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f0b5af;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
}

.section-head {
  margin-bottom: 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
}

.section-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: grid;
  gap: 12px;
}

.item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.item.homework.expired {
  border-color: #f0b5af;
  background: #fffafa;
}

.item.homework.urgent {
  border-color: #f1cf94;
  background: #fffdf7;
}

.item-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
}

.index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.item h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
}

.item p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  justify-self: end;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 4px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.meta-line {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0 40px;
}

.meta-strip span,
.detail-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #eef3f9;
  color: var(--muted);
  padding: 2px 9px;
  font-size: 12px;
}

.preview {
  margin: 12px 0 0 40px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.preview.muted {
  color: var(--muted);
}

.item-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.content-block {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 3px solid var(--primary);
  background: #f8fbff;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.content-block.muted {
  color: var(--muted);
  border-left-color: var(--line);
  background: #fafbfe;
}

.content-block.comment {
  border-left-color: #7a5cff;
}

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.detail-card h2 {
  margin: 0;
  font-size: 23px;
  line-height: 1.35;
}

.detail-course {
  margin: 4px 0 0;
  color: var(--muted);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.submit-panel {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.submit-form {
  display: grid;
  gap: 14px;
}

.submit-form.locked {
  pointer-events: none;
  opacity: .52;
}

.drop-zone {
  display: grid;
  gap: 6px;
  min-height: 130px;
  align-content: center;
  justify-items: center;
  border: 2px dashed #abc5e3;
  border-radius: 8px;
  background: #f8fbff;
  color: var(--primary);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s ease, background .15s ease;
}

.drop-zone.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone input {
  display: none;
}

.drop-zone span {
  color: var(--muted);
  font-size: 13px;
}

.note-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.note-field textarea {
  min-height: 100px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
}

.submit-result,
.submit-locked {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #f0b5af;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
}

.submit-result.ok {
  border-color: #a7d8b4;
  background: #eefaf1;
  color: #16713b;
}

a {
  color: var(--primary);
  overflow-wrap: anywhere;
}

.empty {
  padding: 38px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--text);
  font-size: 16px;
}

.empty p {
  margin: 6px 0 0;
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }

  .page {
    padding: 16px;
  }

  .summary {
    grid-template-columns: 1fr 1fr;
  }

  .metric.wide {
    grid-column: 1 / -1;
  }

  .item-top {
    grid-template-columns: auto 1fr;
  }

  .badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .meta-strip,
  .preview {
    margin-left: 0;
  }

  .detail-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
