:root {
  --ink: #1C1712;
  --text: #3A332B;
  --muted: #6F665C;
  --line: #E7E0D8;
  --line-strong: #D5CABE;
  --paper: #F5F0EB;
  --bg: #FFFFFF;
  --accent: #A85C16;
  --accent-hover: #8E4C0F;
  --accent-soft: #FBEFE2;
  --red: #D93B30;
  --green: #2F7A4B;
  --green-soft: #E6F3EA;
  --blue: #2B5C8A;
  --blue-soft: #E7F0F8;
  --gray-soft: #EFEBE6;
  --radius: 12px;
  --font: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Apple SD Gothic Neo", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.6 var(--font); color: var(--text); background: var(--bg);
  word-wrap: break-word; overflow-wrap: break-word;
}
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.35; }
h1 { font-size: 22px; } h2 { font-size: 19px; } h3 { font-size: 17px; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.pre { white-space: pre-wrap; }
.ic { display: inline-flex; vertical-align: middle; flex: none; }
.ic svg { display: block; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { height: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; line-height: 1.2;
}
.btn:active { background: var(--gray-soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-hover); }
.btn-danger { color: var(--red); border-color: #EBC0BC; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 0 12px; font-size: 15px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink); cursor: pointer; border-radius: 10px; padding: 0;
}
.icon-btn:active { background: var(--gray-soft); }

.field { margin-bottom: 14px; }
.field > label, .label { display: block; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=tel], textarea, select {
  width: 100%; min-height: 44px; padding: 9px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; outline: none; appearance: none; -webkit-appearance: none;
}
select {
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, #6F665C 50%), linear-gradient(135deg, #6F665C 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168, 92, 22, .15); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

.notice-box { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--ink); font-size: 15px; margin-bottom: 12px; }
.err { color: var(--red); font-size: 15px; margin: 6px 0; }
.ok-box { background: var(--green-soft); color: #1F5B37; }
.warn-box { background: #FFF1CC; color: #6A4B00; }
.err-box { background: #FDE8E6; color: #9B2219; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 14px; line-height: 1.7; background: var(--gray-soft); color: var(--text); white-space: nowrap; }
.chip-open { background: #FFF1CC; color: #6A4B00; }
.chip-answered { background: var(--green-soft); color: #1F5B37; }
.chip-closed { background: var(--gray-soft); color: var(--muted); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-auto { background: var(--blue-soft); color: var(--blue); }
.chip-human { background: var(--green-soft); color: #1F5B37; }
.chip-none { background: #FFE3E0; color: #9B2219; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex: none; }
.badge {
  display: inline-block; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--red); color: #fff; font-size: 13px; line-height: 20px; text-align: center; font-weight: 700;
}

.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.photo-strip { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ph { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--gray-soft); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-x {
  position: absolute; top: 0; right: 0; width: 44px; height: 44px; border: 0; padding: 0; cursor: pointer;
  background: transparent; display: flex; align-items: flex-start; justify-content: flex-end;
}
.ph-x .ic { margin: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(28, 23, 18, .75); color: #fff; align-items: center; justify-content: center; }
.photo-strip:empty { display: none; }
.photo-strip + .attach-btns { margin-top: 10px; }
.attach-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.attach-btns > .btn, .attach-cell > .btn { display: flex; width: 100%; padding: 0 8px; text-align: center; }
.attach-cell:empty { display: none; }
.photo-count { margin-top: 4px; text-align: center; }
.photo-add { position: relative; cursor: pointer; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { width: 96px; height: 96px; border-radius: 10px; object-fit: cover; background: var(--gray-soft); cursor: zoom-in; border: 1px solid var(--line); display: block; }
.progress { height: 8px; background: var(--gray-soft); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

.lightbox { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1000; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center; overflow: auto; }
.lightbox img { max-width: 100%; max-height: 100%; display: block; }
.lightbox .icon-btn { position: fixed; top: 8px; right: 8px; color: #fff; background: rgba(255, 255, 255, .15); z-index: 2; }
.lightbox .spinner { position: absolute; border-color: #555; border-top-color: #fff; }
.sheet-mask { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 900; background: rgba(28, 23, 18, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; background: #fff;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
}
.sheet h2 { margin-bottom: 10px; }
@media (min-width: 700px) {
  .sheet-mask { align-items: center; }
  .sheet { border-radius: 16px; }
}
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 1100;
  background: rgba(28, 23, 18, .92); color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 15px; max-width: 86vw; text-align: center;
}
.toast.err { background: rgba(175, 36, 25, .95); color: #fff; margin: 0; }

/* ---- small Korean lines (student screens): Chinese stays main, Korean small + muted ---- */
.kl { display: block; font-size: 12.5px; line-height: 1.4; font-weight: 400; color: var(--kl-color, var(--muted)); }
.kl-pre { white-space: pre-wrap; }
.kl-hint { margin-top: 4px; }
.kl-sep { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.bi { text-align: inherit; }
.bi-stack { display: inline-flex; flex-direction: column; align-items: center; text-align: center; }
.bi-block { display: block; }
.bi-inline .kl { display: inline; margin-left: 6px; }
body.hide-ko .kl { display: none !important; }
.btn-primary .kl, .cat[aria-checked=true] .kl { --kl-color: rgba(255, 255, 255, .8); }
.toast .kl { --kl-color: rgba(255, 255, 255, .78); }
.chip .kl { --kl-color: currentColor; opacity: .8; font-size: 12px; }
.field > label .kl, .label .kl { font-weight: 400; }
h1 .kl, h2 .kl, h3 .kl { font-size: 13px; margin-top: 1px; }

.kobar { display: flex; justify-content: flex-end; background: #fff; border-bottom: 1px solid var(--line); padding: 0 6px; }
.kobar.plain { background: transparent; border-bottom: 0; }
.ko-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border: 0; background: transparent; font: inherit; color: var(--ink); cursor: pointer; }
.ko-switch .sw { position: relative; width: 40px; height: 24px; border-radius: 12px; background: #C9BFB3; flex: none; }
.ko-switch .sw i { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.ko-switch[aria-checked=true] .sw { background: var(--accent); }
.ko-switch[aria-checked=true] .sw i { left: 18px; }
.ko-lab { font-size: 14px; }
.ko-lab b { font-weight: 700; }
.ko-sep, .ko-k { font-size: 12.5px; color: var(--muted); }

/* ---- links & videos ---- */
.video-add { position: relative; cursor: pointer; }
.video-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.video-list:empty { display: none; }
.vcard { border: 1px solid var(--line-strong); border-radius: 12px; padding: 6px 4px 8px 12px; background: #fff; }
.vcard.failed { border-color: #EBC0BC; background: #FFF8F7; }
.vrow { display: flex; align-items: center; gap: 10px; }
.vinfo { flex: 1 1 auto; min-width: 0; }
.vname { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vmeta { font-size: 14px; color: var(--muted); }
.vcard .progress { margin: 4px 8px 2px 0; }
.vcard .err { margin: 4px 8px 4px 0; }
.vcard .btn { margin: 4px 0 2px; }
.link-input { margin: 0; }
.link-input .link-ta { font-size: 16px; }
.link-chips { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.link-chips:empty { display: none; }
.link-chip { display: flex; align-items: flex-start; gap: 4px; background: var(--paper); border-radius: 10px; padding: 4px 2px 4px 12px; }
.link-chip .icon-btn { flex: none; }
.lc-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; padding: 6px 0; }
.lc-host { color: var(--ink); font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; word-break: break-all; }
.lc-url { font-size: 13px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; word-break: break-all; font-weight: 400; }
.links { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.link-card { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; max-width: 100%; }
.link-card:active { background: var(--accent-soft); }
.link-card .ic { color: var(--accent); }
.videos { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.vid-wrap { width: 300px; max-width: 100%; }
.vid { display: block; width: 100%; max-height: 60vh; background: #000; border-radius: 10px; }
.vcap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.vcap-name { min-width: 0; overflow-wrap: anywhere; }
.vfail { margin-top: 4px; font-size: 14px; color: var(--red); }
.meta-i { display: inline-flex; align-items: center; gap: 4px; }
.link-input .link-ta { min-height: 72px; }
.composer-attach { max-height: 36vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.composer .btn-primary { flex: none; white-space: nowrap; }
.vrow .icon-btn { flex: none; }
