/* Check Sparrow — clean, readable, calm. */

:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #64748b;
  --border: #dfe5eb;
  --accent: #0f766e;
  --accent-hover: #0d655e;
  --accent-soft: #e6f2f1;
  --danger: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 45, 0.08);

  --c-spelling: #FCA5A5;
  --c-tense: #FDBA74;
  --c-punctuation: #93C5FD;
  --c-capitalization: #D8B4FE;
  --c-teacher_note: #86EFAC;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

/* ---------------------------------------------------------------- layout */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  font-weight: 700; font-size: 1.15rem; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.brand-img { width: 32px; height: 32px; }
.hero-img { width: 92px; height: 92px; margin-bottom: 6px; }
.nav { display: flex; align-items: center; gap: 4px; }
.navlink {
  color: var(--ink); text-decoration: none; padding: 6px 12px;
  border-radius: 8px; font-weight: 500;
}
.navlink:hover { background: var(--accent-soft); color: var(--accent); }
.inline-form { display: inline; margin-left: 4px; }

.container { max-width: 860px; margin: 0 auto; padding: 24px 20px 64px; }
.container.wide { max-width: 1160px; }

h1 { font-size: 1.55rem; margin: 0 0 6px; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1.05rem; margin: 0 0 4px; }
h3 a { color: var(--ink); text-decoration: none; }
h3 a:hover { color: var(--accent); }
p { margin: 0 0 10px; }
.page-head { margin: 4px 0 16px; }
.crumbs { margin: 0 0 12px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.center { text-align: center; }
.pre-wrap { white-space: pre-wrap; }
code {
  background: #eef1f4; padding: 1px 6px; border-radius: 5px;
  font-size: 0.9em; word-break: break-all;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card.narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card.empty { color: var(--muted); text-align: center; padding: 34px; }
.card-head-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.card-head-row h2 { margin: 0; }

/* --------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.3;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: #f4f7f9; border-color: #c9d2da; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: #fdf0f0; border-color: #f3caca; }
.btn-sm { padding: 5px 11px; font-size: 0.85rem; }
.btn-lg { padding: 12px 26px; font-size: 1.05rem; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

input, textarea, select {
  font: inherit; color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; background: #fff; width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
}
textarea { resize: vertical; }

.flash {
  border-radius: 8px; padding: 11px 16px; margin-bottom: 16px;
  border: 1px solid; font-weight: 500;
}
.flash-ok { background: #ecfdf3; border-color: #b7e4c7; color: #14532d; }
.flash-error { background: #fdf0f0; border-color: #f3caca; color: var(--danger); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 0.8rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
  padding: 8px 10px; border-bottom: 2px solid var(--border);
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700;
}
.badge-latest { background: #dcfce7; color: #14532d; }
.badge-older { background: #f1f5f9; color: var(--muted); }
.badge.st-open { background: #dcfce7; color: #14532d; }
.badge.st-paused { background: #fef3c7; color: #92400e; }
.badge.st-stopped { background: #fee2e2; color: #991b1b; }

.chip {
  display: inline-block; min-width: 26px; text-align: center;
  padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
  background: #f1f5f9; color: var(--muted);
}
.chip-on { background: var(--accent-soft); color: var(--accent); }
.nowrap { white-space: nowrap; }

.status-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
}
.status-buttons { display: flex; gap: 6px; }

.email-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border);
}
.email-addr { font-weight: 600; font-size: 0.9rem; }
.input-sm { width: auto; padding: 5px 9px; font-size: 0.88rem; }
.email-msg { flex: 1; min-width: 180px; }

.jack-row {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border);
}
.jack-img { width: 52px; height: 52px; flex: none; }
.jack-quote { font-style: italic; color: #475569; margin: 0; font-size: 0.95rem; }
.jack-sig { font-style: normal; font-size: 0.82rem; color: var(--muted); font-weight: 600; }

.row .grow { flex: 1; }
.push-right { margin-left: auto; }
.grade-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.grade-input { width: 160px; }
.sent-tag { color: #14532d; font-size: 0.75rem; font-weight: 700; }

.summary-block {
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border);
}
.summary-line { display: flex; gap: 10px; align-items: flex-start; margin-top: 6px; }
.summary-line textarea { flex: 1; }
.summary-side { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; flex: none; }

input[type="checkbox"] { width: auto; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; font-size: 0.95rem;
}
.toggle-row { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }

.badge-class { background: #e0f2fe; color: #075985; }
.missing-card { border-left: 4px solid #f59e0b; }
.missing-list { display: flex; gap: 8px; flex-wrap: wrap; }
.missing-chip {
  background: #fef3c7; color: #92400e; font-weight: 600; font-size: 0.88rem;
  border-radius: 999px; padding: 4px 12px;
}

/* ----------------------------------------------------------- assignments */
.assignment-row { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.assignment-info { min-width: 0; flex: 1; }
.assignment-actions { display: flex; align-items: flex-start; }
.share-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.share-label { font-size: 0.85rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.share-input {
  flex: 1; min-width: 220px; font-size: 0.9rem;
  padding: 7px 10px; background: #f8fafc; color: #334155;
}
.export-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- landing */
.hero { text-align: center; padding: 56px 30px; margin-top: 26px; }
.hero-bird { font-size: 3.2rem; margin-bottom: 8px; }
.hero h1 { font-size: 2rem; }
.hero-actions { margin: 22px 0 10px; }
.hero-note { margin-top: 18px; }

/* ---------------------------------------------------------------- student */
.assignment-head h1 { margin-bottom: 8px; }
.writebar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.editor-card { padding: 14px; }
#editor {
  width: 100%; min-height: 56vh; border: none; padding: 12px 10px;
  font-size: 1.1rem; line-height: 1.8;
  font-family: Georgia, "Times New Roman", serif;
}
#editor:focus { outline: none; }
.editor-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 10px 2px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.restored-note { background: #fefce8; border-radius: 6px; padding: 8px 12px; color: #854d0e; }
.paste-note { background: #fee2e2; border-radius: 6px; padding: 8px 12px; color: #991b1b; font-weight: 600; }
.done-mark { font-size: 3rem; margin-bottom: 6px; }
#done-step { padding: 44px 30px; }
#again-btn { margin-top: 10px; }

/* ---------------------------------------------------------------- grading */
.grading-head { padding-bottom: 14px; }
.grading-head-row {
  display: flex; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; align-items: flex-start;
}
.check-area { text-align: right; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.status { font-size: 0.9rem; font-weight: 600; min-height: 1.2em; }
.status.working { color: #92400e; }
.status.working::before {
  content: ""; display: inline-block; width: 0.85em; height: 0.85em;
  margin-right: 6px; vertical-align: -0.1em;
  border: 2px solid #92400e; border-top-color: transparent; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status.ok { color: #14532d; }
.status.error { color: var(--danger); }

.grading-tools-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.legend { display: flex; gap: 8px; flex-wrap: wrap; }
.legend-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.8rem; font-weight: 600; color: #334155;
  padding: 3px 10px; border-radius: 999px; background: #f6f8fa;
  border: 1px solid var(--border);
}
.legend-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

.grading-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.essay-panel { padding: 24px 28px; }
.essay-hint { margin-bottom: 14px; }
#essay {
  white-space: pre-wrap; overflow-wrap: break-word;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.1rem; line-height: 2.0;
}
.hl { border-radius: 3px; padding: 0 1px; cursor: pointer; }
.hl:hover { filter: brightness(0.93); }
.cat-spelling { background: var(--c-spelling); }
.cat-tense { background: var(--c-tense); }
.cat-punctuation { background: var(--c-punctuation); }
.cat-capitalization { background: var(--c-capitalization); }
.cat-teacher_note { background: var(--c-teacher_note); }
.hl[data-nums]::after {
  content: attr(data-nums);
  font-size: 0.62em; font-weight: 700; color: #475569;
  vertical-align: super; margin-left: 2px;
}
.hl.flash-hl { outline: 2px solid var(--accent); }

.comments-panel { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.empty-side { color: var(--muted); font-size: 0.92rem; }
.comment-item {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 10px; background: #fcfdfe;
}
.comment-item.flash-item { outline: 2px solid var(--accent); }
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment-num {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 800; color: #1e293b;
}
.comment-cat { font-size: 0.85rem; font-weight: 700; }
.comment-src {
  margin-left: auto; font-size: 0.7rem; font-weight: 700;
  color: var(--muted); background: #f1f5f9;
  border-radius: 999px; padding: 1px 8px; letter-spacing: 0.03em;
}
.comment-quote { font-size: 0.88rem; color: #334155; font-style: italic; cursor: pointer; margin-bottom: 3px; }
.comment-quote:hover { color: var(--accent); }
.comment-note { font-size: 0.92rem; margin-bottom: 7px; white-space: pre-wrap; }
.comment-actions { display: flex; gap: 6px; }
.comment-edit { margin-top: 8px; gap: 8px; }

.floating { position: absolute; z-index: 50; box-shadow: 0 4px 18px rgba(20, 30, 45, 0.22); }
#add-btn { transform: translateX(-50%); }
.add-form { width: 330px; padding: 14px 16px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.add-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 0.9rem; }
.add-quote-wrap {
  font-size: 0.85rem; color: var(--muted);
  max-height: 3.6em; overflow: hidden;
}
.add-quote { font-style: italic; color: #334155; }

.key-status { font-weight: 600; }
.key-status.ok { color: #14532d; }
.key-status.warn { color: #92400e; }

@media (max-width: 950px) {
  .grading-cols { grid-template-columns: 1fr; }
  .comments-panel { position: static; max-height: none; }
  .check-area { align-items: flex-start; text-align: left; }
}
@media (max-width: 620px) {
  .container { padding: 16px 12px 48px; }
  .card { padding: 16px; }
  .topbar-inner { padding: 8px 12px; }
  .essay-panel { padding: 16px; }
}
