/* =========================================================
   课堂同屏 · 设计基础
   ========================================================= */

:root {
  --ink-950: #081611;
  --ink-900: #0f211a;
  --ink-850: #142a22;
  --ink-800: #19342a;
  --ink-700: #24473a;
  --ink-600: #356052;

  --paper: #f4f0e6;
  --paper-deep: #ebe5d6;
  --paper-soft: #faf7ef;
  --paper-card: #fffdf8;
  --line: #ded7c7;
  --line-strong: #c9c0ad;

  --text: #18251f;
  --text-soft: #66736b;
  --text-faint: #8b948c;

  --green: #1d6b52;
  --green-deep: #0f4b39;
  --green-soft: #d7ebdf;
  --mint: #bfe3cf;
  --amber: #e2a13d;
  --amber-soft: #f7e7c7;
  --coral: #cd6447;
  --coral-soft: #f6dfd7;
  --blue: #4f7d9f;
  --blue-soft: #dde9f1;

  --font-sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --font-mono: "SFMono-Regular", "IBM Plex Mono", Menlo, Consolas, monospace;

  --radius-xs: 10px;
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 28px;
  --radius-xl: 36px;

  --shadow-sm: 0 2px 8px rgba(18, 38, 30, 0.05);
  --shadow-md: 0 18px 44px -24px rgba(18, 38, 30, 0.28);
  --shadow-lg: 0 36px 80px -36px rgba(8, 22, 17, 0.4);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--paper);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

svg {
  width: 1em;
  height: 1em;
}

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

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  color: var(--paper-soft);
  background: var(--green);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- 通用组件 ---------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--paper-soft);
  background: var(--ink-850);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-name {
  display: block;
  color: inherit;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.17em;
  line-height: 1.2;
  text-transform: uppercase;
}

.btn {
  --btn-bg: var(--ink-850);
  --btn-fg: var(--paper-soft);
  --btn-border: transparent;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  color: var(--btn-fg);
  background: var(--btn-bg);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition:
    transform 180ms var(--ease-out),
    box-shadow 180ms var(--ease-out),
    background 180ms ease,
    border-color 180ms ease,
    opacity 180ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -10px rgba(12, 31, 23, 0.55);
}

.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.btn-primary {
  --btn-bg: var(--green);
}

.btn-primary:hover {
  --btn-bg: var(--green-deep);
}

.btn-amber {
  --btn-bg: var(--amber);
  --btn-fg: var(--ink-950);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-border: var(--line);
}

.btn-ghost:hover {
  --btn-bg: var(--paper-card);
  --btn-border: var(--line-strong);
}

.btn-quiet {
  --btn-bg: transparent;
  --btn-fg: var(--text-soft);
}

.btn-quiet:hover {
  --btn-bg: rgba(24, 37, 31, 0.06);
  --btn-fg: var(--text);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  gap: 6px;
  font-size: 12.5px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-lg {
  min-height: 52px;
  padding: 0 24px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 11px;
  color: var(--text-soft);
  transition: background 160ms ease, color 160ms ease;
}

.icon-btn:hover {
  color: var(--text);
  background: rgba(24, 37, 31, 0.06);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn.is-danger:hover {
  color: var(--coral);
  background: var(--coral-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--text-soft);
  background: rgba(24, 37, 31, 0.06);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge-dot::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-green {
  color: var(--green-deep);
  background: var(--green-soft);
}

.badge-amber {
  color: #7a4d0c;
  background: var(--amber-soft);
}

.badge-coral {
  color: #8d3620;
  background: var(--coral-soft);
}

.badge-blue {
  color: #2d5572;
  background: var(--blue-soft);
}

.badge-dark {
  color: var(--mint);
  background: rgba(255, 255, 255, 0.09);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper-card);
  box-shadow: var(--shadow-sm);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.18em;
  line-height: 1.3;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 16px;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #55c695;
  box-shadow: 0 0 0 0 rgba(85, 198, 149, 0.55);
  animation: livePulse 2.4s infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(85, 198, 149, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(85, 198, 149, 0); }
  100% { box-shadow: 0 0 0 0 rgba(85, 198, 149, 0); }
}

/* ---------- 表单 ---------- */

.field {
  display: grid;
  gap: 7px;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.field-label small {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--paper-soft);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.input,
.select {
  height: 44px;
  padding: 0 13px;
}

.textarea {
  min-height: 108px;
  padding: 12px 13px;
  line-height: 1.7;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: #a4aaa2;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: var(--line-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--green);
  background: var(--paper-card);
  box-shadow: 0 0 0 3px rgba(29, 107, 82, 0.1);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  cursor: pointer;
}

.switch-copy {
  display: grid;
  gap: 2px;
}

.switch-copy strong {
  font-size: 13px;
  font-weight: 650;
}

.switch-copy small {
  color: var(--text-soft);
  font-size: 11.5px;
  line-height: 1.5;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  display: block;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d5cfc1;
  transition: background 180ms ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper-card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  transition: transform 200ms var(--ease-spring);
}

.switch input:checked + .switch-track {
  background: var(--green);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

/* ---------- 头像 ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  color: var(--green-deep);
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.avatar-lg {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  font-size: 16px;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 11px;
}

.avatar[data-tone="1"] { color: #7a4d0c; background: var(--amber-soft); }
.avatar[data-tone="2"] { color: #8d3620; background: var(--coral-soft); }
.avatar[data-tone="3"] { color: #2d5572; background: var(--blue-soft); }
.avatar[data-tone="4"] { color: #4a3d70; background: #e8e0f3; }
.avatar[data-tone="5"] { color: #4e5a22; background: #e8edd3; }

/* ---------- Toast ---------- */

.toast-host {
  position: fixed;
  z-index: 200;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 9px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  color: var(--paper-soft);
  background: #12261e;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  line-height: 1.5;
  pointer-events: auto;
  animation: toastIn 320ms var(--ease-out);
  backdrop-filter: blur(12px);
}

.toast.is-leaving {
  animation: toastOut 220ms ease forwards;
}

.toast svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--mint);
}

.toast[data-tone="error"] svg {
  color: #f0a58e;
}

.toast[data-tone="amber"] svg {
  color: var(--amber);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(6px) scale(0.98); }
}

/* ---------- 对话框 ---------- */

dialog {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  color: var(--text);
  background: var(--paper-card);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(8, 22, 17, 0.56);
  backdrop-filter: blur(3px);
}

dialog[open] {
  animation: dialogIn 280ms var(--ease-out);
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 26px 0;
}

.dialog-head h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.dialog-head p {
  margin-top: 5px;
  color: var(--text-soft);
  font-size: 12.5px;
}

.dialog-body {
  display: grid;
  gap: 16px;
  padding: 20px 26px;
}

.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  padding: 0 26px 24px;
}

/* ---------- 滚动条 ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: #c9c1b1 transparent;
}

*::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

*::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: #c9c1b1;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- 动效偏好 ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
