:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --panel: #fffdfa;
  --ink: #25231f;
  --muted: #827b72;
  --line: #e7e0d7;
  --soft: #eef6f1;
  --accent: #516b61;
  --danger: #a64b4b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  padding: 12px 20px;
  cursor: pointer;
}

button:hover {
  opacity: 0.86;
}

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

.hidden {
  display: none !important;
}

.login-card,
.panel,
.topbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(60, 49, 38, 0.08);
}

.login-card {
  max-width: 480px;
  margin: 8vh auto 0;
  padding: 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 32px;
}

h2 {
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--ink);
  padding: 12px 14px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
}

.error {
  min-height: 22px;
  color: var(--danger);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
}

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

.mode-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  border: 1px solid var(--line);
}

.mode-pill.loading {
  color: var(--muted);
  background: white;
}

.mode-pill.review {
  color: #8a5b18;
  background: #fff6e6;
  border-color: #ead6b6;
}

.mode-pill.live {
  color: #2f4a42;
  background: #eef6f1;
  border-color: #d8e7df;
}

.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

.tabs {
  display: flex;
  gap: 10px;
  margin: 22px 0;
}

.tab {
  background: white;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active {
  background: var(--accent);
  color: white;
}

.panel {
  padding: 24px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 18px;
}

.list {
  display: grid;
  align-content: start;
  gap: 12px;
}

.list-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  padding: 16px;
  text-align: left;
}

.list-item.active {
  border-color: var(--accent);
  background: var(--soft);
}

.list-title {
  display: block;
  margin-bottom: 6px;
  font-weight: 700;
}

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

.detail {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 20px;
}

.thread-item {
  position: relative;
  padding-right: 48px;
}

.thread-preview {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.thread-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: #d85b56;
  color: white;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.admin-letter-timeline {
  display: grid;
  gap: 12px;
  max-height: 360px;
  margin: 18px 0;
  overflow: auto;
  padding-right: 6px;
}

.admin-letter-row {
  display: flex;
}

.admin-student-row {
  justify-content: flex-start;
}

.admin-reply-row {
  justify-content: flex-end;
}

.admin-letter-bubble {
  max-width: 82%;
  padding: 14px 16px;
  border: 1px solid var(--line);
}

.admin-student-row .admin-letter-bubble {
  border-radius: 16px 16px 16px 4px;
  background: #faf7f2;
}

.admin-reply-row .admin-letter-bubble {
  border-radius: 16px 16px 4px 16px;
  background: #eef6f1;
}

.admin-letter-bubble strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 13px;
}

.admin-letter-bubble p {
  margin: 0;
  line-height: 1.75;
  white-space: pre-wrap;
}

.admin-letter-bubble span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.letter-content {
  margin: 14px 0 18px;
  padding: 16px;
  border-radius: 14px;
  background: #faf7f2;
  line-height: 1.8;
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 14px;
}

.checkline {
  display: flex;
  align-items: end;
  gap: 8px;
  padding-bottom: 12px;
}

.checkline input {
  width: auto;
}

.announcement-form {
  max-width: 680px;
  margin-bottom: 22px;
}

.announcement-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.announcement-item.long {
  background: #f7fbf8;
  border-color: #dce9e1;
}

.announcement-item.short {
  background: #fffaf2;
  border-color: #eadfce;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(320px, 1fr);
  gap: 18px;
}

.mode-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 20px;
}

.primary-mode-card {
  background: #fbf8f3;
}

.domain-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.domain-list span {
  padding: 12px 14px;
  color: var(--ink);
  border-radius: 12px;
  background: #f7f4ef;
  border: 1px solid var(--line);
}

.account-tools {
  max-width: 560px;
  margin-bottom: 18px;
}

.account-list {
  grid-template-columns: 1fr;
}

.account-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.account-item.active-account {
  background: #f7fbf8;
  border-color: #dce9e1;
}

.account-main {
  min-width: 0;
}

.account-actions {
  display: grid;
  align-content: start;
  justify-items: end;
  gap: 12px;
  min-width: 170px;
}

.account-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.switch-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
  color: var(--ink);
}

.switch-line input {
  width: auto;
}

.form-actions,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.small-action {
  padding: 8px 14px;
  font-size: 13px;
}

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

@media (max-width: 820px) {
  .split,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head {
    display: block;
  }

  .topbar-actions {
    margin-top: 18px;
  }

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

  .account-item {
    display: block;
  }

  .account-actions {
    justify-items: start;
    margin-top: 14px;
  }
}
