/* 师生连线 TutorLink —— 不依赖任何外部字体或 CDN */
:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #1d2a26;
  --ink-2: #4b5a55;
  --muted: #7d8a85;
  --line: #e6e0d4;
  --brand: #0e5e4c;
  --brand-2: #127a63;
  --brand-soft: #e3f1ec;
  --accent: #f6c453;
  --accent-ink: #6b4a00;
  --online: #1fa36f;
  --busy: #e0962b;
  --offline: #b6bdb9;
  --danger: #c2412d;
  --danger-soft: #fbe9e5;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(29, 42, 38, .06), 0 6px 20px rgba(29, 42, 38, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--font); min-height: 100vh;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 16px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* 顶栏 */
.header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: rgba(246, 243, 236, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1160px; margin: 0 auto; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 8px; }
.me-chip { display: flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border-radius: 999px; color: var(--ink); font-weight: 600; font-size: 14px; }
.me-chip:hover { background: var(--surface); text-decoration: none; }
.me-chip span:last-child { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { max-width: 1160px; margin: 0 auto; padding-block: 24px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }

/* 按钮 */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; padding: 9px 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; color: var(--ink);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .6; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-2); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-xs { padding: 3px 9px; font-size: 12.5px; border-radius: 8px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-ghost.loading::after { border-color: var(--line); border-top-color: var(--brand); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }
.lang { min-width: 52px; }

/* 卡片 & 表单 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 14px; }
.stack-lg { display: grid; gap: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 .full, .grid2 > .form-error { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field-label em { font-style: normal; font-weight: 400; color: var(--muted); }
.field-hint { font-size: 12.5px; color: var(--muted); }
.field-error, .form-error { font-size: 13px; color: var(--danger); min-height: 0; }
.field-error:empty, .form-error:empty { display: none; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px rgba(18, 122, 99, .15); }
.invalid { border-color: var(--danger) !important; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: #fdf6e3; color: var(--accent-ink); font-size: 13px; }
.note span { flex: none; margin-top: 2px; }

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.segmented button { appearance: none; border: 0; background: transparent; font: inherit; font-weight: 600; padding: 7px 18px; border-radius: 9px; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* 头像 */
.avatar { position: relative; display: inline-block; flex: none; border-radius: 50%; background: var(--brand-soft); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar-sm { width: 30px; height: 30px; }
.avatar-md { width: 44px; height: 44px; }
.avatar-lg { width: 60px; height: 60px; }
.avatar-xl { width: 84px; height: 84px; }
.avatar .dot { position: absolute; right: 0; bottom: 0; width: 26%; height: 26%; min-width: 10px; min-height: 10px; border-radius: 50%; border: 2.5px solid var(--surface); }
.dot-online { background: var(--online); }
.dot-busy { background: var(--busy); }
.dot-offline { background: var(--offline); }
.dot-inline { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.avatar-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--brand); }
.picker { display: flex; align-items: center; gap: 16px; cursor: pointer; }
.picker-side { display: grid; gap: 6px; justify-items: start; }
.picker:hover .picker-preview { box-shadow: 0 0 0 3px var(--brand-soft); }

/* 徽章 */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.badge-online { background: #e2f5ec; color: #12704b; }
.badge-busy { background: #fcefd9; color: #8a5508; }
.badge-offline { background: #eef0ef; color: #6d7672; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill-pending { background: #fcefd9; color: #8a5508; }
.pill-accepted { background: #e2f5ec; color: #12704b; }
.pill-rejected { background: var(--danger-soft); color: var(--danger); }
.pill-cancelled, .pill-expired { background: #eef0ef; color: #6d7672; }
.role-tag { margin-left: 10px; font-size: 12px; font-weight: 700; vertical-align: middle; padding: 2px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }

/* 登录注册 */
.auth { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: start; padding-top: 24px; }
.hero { padding-top: 32px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.12; letter-spacing: -.02em; }
.hero-sub { margin-top: 16px; font-size: 16.5px; color: var(--ink-2); max-width: 460px; }
.hero-points { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.hero-points li { display: flex; gap: 10px; align-items: center; color: var(--ink-2); }
.hero-points .pt { color: var(--online); display: flex; }
.auth-card { display: grid; gap: 14px; max-width: 460px; width: 100%; justify-self: end; }
.auth-card.wide { max-width: 560px; }
.switch { text-align: center; color: var(--muted); font-size: 14px; }

/* 主布局 */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.side-col { position: sticky; top: 78px; display: grid; gap: 12px; }
.main-col { display: grid; gap: 16px; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h1 { display: flex; align-items: baseline; gap: 10px; }
.count { font-size: 13px; font-weight: 600; color: var(--online); }
.count:empty { display: none; }
#incoming-count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 9px; }
.tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.search { width: 260px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }

.teacher-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.tcard.online:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(29,42,38,.06), 0 12px 28px rgba(29,42,38,.1); }
.tcard.offline { opacity: .72; }
.tcard.offline .avatar img { filter: grayscale(.6); }
.tcard-top { display: flex; gap: 12px; align-items: center; }
.tcard-id { display: grid; gap: 3px; justify-items: start; min-width: 0; }
.tcard-id h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.subject { font-weight: 600; color: var(--brand); font-size: 14px; }
.bio { color: var(--ink-2); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.tcard .btn { margin-top: auto; }

.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 48px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); grid-column: 1 / -1; }
.empty p { max-width: 360px; }

/* 请求列表 */
.req-list { display: grid; gap: 10px; }
.req { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; }
.req-accepted { border-color: #bfe3d2; }
.req-head { display: flex; align-items: center; gap: 10px; }
.req-who { display: grid; flex: 1; min-width: 0; }
.req-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-foot { display: flex; align-items: center; justify-content: space-between; }
.req-reason { font-size: 13.5px; color: var(--ink-2); }

.meeting { background: #f1f9f5; border: 1px solid #cfe9dc; border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.meeting-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.meeting-row > span:first-child { color: var(--muted); min-width: 64px; }
.meeting-row.big strong { font-size: 18px; color: var(--brand); flex: 1; }
.meeting-note { font-size: 13px; color: var(--ink-2); border-top: 1px dashed #cfe9dc; padding-top: 6px; }

/* 教师端 */
.status-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; padding: 18px 22px; }
.status-card > div:first-child { display: grid; gap: 8px; justify-items: start; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.status-side { display: grid; gap: 6px; justify-items: end; max-width: 320px; text-align: right; }
.incoming { display: grid; gap: 14px; }
.incoming-card { display: grid; gap: 12px; padding: 18px; border-left: 4px solid var(--accent); animation: pop .35s ease-out; }
.msg { margin: 0; padding: 10px 14px; background: var(--surface-2); border-radius: 10px; color: var(--ink-2); font-size: 14px; border-left: 3px solid var(--line); }
.incoming-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* 弹窗 */
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(20, 30, 27, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; display: grid; gap: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .2s ease-out; }
.modal > .muted { margin-top: -8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.who { display: flex; gap: 12px; align-items: center; }

.narrow { max-width: 720px; margin: 0 auto; }
.narrow .card { display: grid; gap: 16px; }

/* 提示 */
.toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: drop .25s ease-out; transition: opacity .4s, transform .4s; }
.toast-success { background: var(--brand); }
.toast-error { background: var(--danger); }
.toast-accent { background: var(--accent); color: var(--accent-ink); }
.toast.out { opacity: 0; transform: translateY(-6px); }

.boot { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }

/* 手机 */
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .side-col { position: static; }
  .auth { grid-template-columns: 1fr; gap: 24px; padding-top: 0; }
  .hero { padding-top: 8px; }
  .auth-card { justify-self: stretch; max-width: none; }
  .auth-card.wide { max-width: none; }
}
@media (max-width: 560px) {
  .main { padding-block-start: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .tools { width: 100%; }
  .card { padding: 18px; }
  .status-side { justify-items: start; text-align: left; }
  .me-chip span:last-child { display: none; }
  .hero h1 { font-size: 30px; }
  .hero-points { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
