:root {
  --green: #d7f5dd;
  --green-border: #4caf50;
  --pale-green: #eef8f0;
  --pale-green-border: #9ecfa4;
  --yellow: #fff6cf;
  --yellow-border: #d4a72c;
  --red: #fde0df;
  --red-border: #d64545;
  --gray: #ececec;
  --gray-border: #9a9a9a;
  --blue: #dcebfb;
  --blue-border: #4a86c5;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 0 1.5rem 3rem;
  color: #222;
  background: #fafafa;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 0;
  border-bottom: 1px solid #ddd;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

nav a {
  text-decoration: none;
  color: #2255aa;
  font-weight: 600;
}

nav a:hover { text-decoration: underline; }

nav .student-name {
  font-weight: 700;
  color: #444;
  margin-right: auto;
}

.refresh-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.refresh-form button {
  font: inherit;
  font-weight: 600;
  color: #2255aa;
  background: none;
  border: 1px solid #2255aa;
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

.refresh-form button:hover { background: #eaf1fb; }

.refresh-form .last-synced {
  font-size: 0.8rem;
  color: #888;
}

.logout-btn {
  font: inherit;
  font-weight: 600;
  color: #888;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
}

.logout-btn:hover { background: #f0f0f0; }

.login-required {
  max-width: 32rem;
}

.legend {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #555;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend .swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  display: inline-block;
}

.col-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fafafa;
  padding: 0.5rem 0;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid #ddd;
}

.col-switcher[hidden] { display: none; }

.col-arrow {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  font-size: 1.3rem;
  line-height: 1;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
}

.col-arrow:disabled { opacity: 0.35; cursor: default; }

.col-select {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  text-align-last: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #333;
  padding: 0.55rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
}

.board {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  overflow-x: auto;
}

.column {
  flex: 1 1 200px;
  min-width: 200px;
}

.column-manual {
  display: none;
}

.column h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
  margin: 0 0 0.6rem;
}

.card {
  position: relative;
  display: block;
  border-radius: 8px;
  border: 1px solid;
  padding: 0.6rem 4.5rem 0.6rem 0.7rem;
  margin-bottom: 0.6rem;
  color: #222;
}

.class-icon {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  flex: none;
}

.course-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.class-icon-large {
  position: static;
  width: 5rem;
  height: 5rem;
  font-size: 2.6rem;
}

.course-header h1 { margin: 0; }
.course-header p { margin: 0.2rem 0 0; }

.class-icon-inline {
  position: static;
  display: inline-flex;
  width: 1.6rem;
  height: 1.6rem;
  font-size: 0.9rem;
  vertical-align: middle;
  margin-right: 0.4rem;
  box-shadow: none;
}

.card-link { display: block; text-decoration: none; color: inherit; }
.card .course { font-size: 0.75rem; color: #555; }
.card .name { font-weight: 600; margin: 0.15rem 0; }
.card .meta { font-size: 0.75rem; color: #555; }

.card-status {
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.6rem;
  row-gap: 0.15rem;
  font-size: 0.7rem;
  margin: 0.45rem 0 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.card-status label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0;
  cursor: pointer;
  white-space: nowrap;
}

.card-status input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
}

.card-extra {
  font-size: 0.75rem;
  color: #2255aa;
}

.link-text {
  cursor: pointer;
  text-decoration: underline dotted;
}

.link-text:hover { text-decoration: underline solid; }

.comment-icon {
  cursor: default;
  white-space: nowrap;
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.comment-list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid #eee;
}

.comment-author {
  font-weight: 600;
}

.comment-date {
  font-size: 0.8rem;
  color: #888;
  margin-left: 0.5rem;
}

.comment-list p {
  margin: 0.3rem 0 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
  width: 90%;
  max-width: 340px;
}

.modal h3 { margin: 0 0 0.75rem; }
.modal p { margin: 0.5rem 0; }

.error-text {
  color: #c62828;
  font-size: 0.9rem;
}

.modal input[type="number"],
.modal textarea {
  width: 100%;
  font: inherit;
  padding: 0.4rem;
  box-sizing: border-box;
}

.modal textarea { min-height: 80px; resize: vertical; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.card-green  { background: var(--green);  border-color: var(--green-border); }
.card-pale_green { background: var(--pale-green); border-color: var(--pale-green-border); }
.card-yellow { background: var(--yellow); border-color: var(--yellow-border); }
.card-red    { background: var(--red);    border-color: var(--red-border); }
.card-gray   { background: var(--gray);   border-color: var(--gray-border); }
.card-blue   { background: var(--blue);   border-color: var(--blue-border); }

.table-scroll {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #ddd;
}

th { color: #555; font-size: 0.8rem; text-transform: uppercase; }
th a { color: inherit; text-decoration: none; }
th a:hover { text-decoration: underline; }

.muted { color: #888; font-size: 0.85em; }

form.inline { display: inline; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field input, .field select, .field textarea {
  padding: 0.4rem;
  font-size: 1rem;
  width: 100%;
  max-width: 320px;
}

button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
}

.empty { color: #888; font-style: italic; }

.next-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.next-progress {
  font-size: 0.85rem;
  color: #888;
}

.next-column {
  max-width: 480px;
}

.next-card { position: relative; }

.mark-done-btn {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #2e7d32;
  background: #fff;
  border: 1px solid #4caf50;
  border-radius: 6px;
  cursor: pointer;
}

.mark-done-btn:hover { background: #eef8f0; }
.mark-done-btn:disabled { opacity: 0.6; cursor: default; }

.done-flash { animation: done-pop 0.35s ease; }

@keyframes done-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.done-message {
  margin-top: 0.5rem;
  text-align: center;
  font-weight: 700;
  color: #2e7d32;
  animation: done-fade-in 0.2s ease;
}

@keyframes done-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (max-width: 640px) {
  body { padding: 0 0.75rem 2rem; }

  nav { gap: 0.75rem; }

  .card {
    padding-right: 3.2rem;
  }

  .class-icon {
    width: 2.6rem;
    height: 2.6rem;
    font-size: 1.4rem;
  }

  .card-status {
    flex-direction: column;
    gap: 0;
  }

  .card-status label {
    padding: 0.4rem 0;
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
  }

  .modal {
    width: 94%;
  }

  .next-column {
    max-width: 100%;
  }

  .class-icon-large {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.8rem;
  }
}

.account-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.account-header select {
  padding: 0.4rem;
  font-size: 1rem;
}

.account-header button {
  font: inherit;
  font-weight: 600;
  color: #2255aa;
  background: none;
  border: 1px solid #2255aa;
  border-radius: 4px;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
}

.account-header button:hover { background: #eaf1fb; }

.link-result {
  margin-bottom: 1.5rem;
  max-width: 32rem;
}

.link-output {
  width: 100%;
  font: inherit;
  padding: 0.4rem;
  box-sizing: border-box;
}

.editable-label,
.label-input {
  cursor: text;
  border-bottom: 1px dotted #999;
}

.label-input {
  font: inherit;
  border: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.15rem 0.3rem;
}

.revoke-btn {
  font: inherit;
  font-weight: 600;
  color: #c62828;
  background: none;
  border: 1px solid #c62828;
  border-radius: 4px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}

.revoke-btn:hover { background: #fde0df; }
