:root {
  --bg: #f4f8fb;
  --paper: #fff;
  --ink: #0f2430;
  --muted: #4a6270;
  --line: #d5e3ea;
  --blue: #1f6feb;
  --blue-deep: #0b4db8;
  --teal: #1aa6a0;
  --green: #3d9a6a;
  --shadow: 0 18px 50px rgba(15, 36, 48, 0.08);
  --nav-h: 60px;
  --dock-h: 72px;
  --radius: 18px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: "Sora", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 90% -10%, rgba(31, 111, 235, 0.10), transparent 60%),
    radial-gradient(700px 400px at -10% 20%, rgba(26, 166, 160, 0.10), transparent 55%),
    var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, .btn { font: inherit; cursor: pointer; border: 0; }
.wrap { width: min(1080px, calc(100% - 2rem)); margin-inline: auto; }
.wrap-chat { width: min(1180px, calc(100% - 1rem)); }

.nav {
  position: sticky; top: 0; z-index: 20; height: var(--nav-h);
  display: flex; align-items: center;
  backdrop-filter: blur(16px);
  background: rgba(244, 248, 251, 0.88);
  border-bottom: 1px solid rgba(213, 227, 234, 0.7);
}
.nav-in {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: min(1080px, calc(100% - 2rem)); margin-inline: auto;
}
body.edu-chat .nav-in { width: min(1180px, calc(100% - 1rem)); }
body.edu-chat .brand { flex: 1; }
.brand { font-weight: 700; letter-spacing: 0.02em; }
.brand em { font-style: normal; color: var(--blue); }
.brand span { font-weight: 500; color: var(--muted); margin-left: 0.35rem; font-size: 0.82rem; }
.nav-meta { display: flex; align-items: center; gap: 0.55rem; font-size: 0.82rem; color: var(--muted); }
.who-label { font-weight: 600; color: var(--muted); }
.wallet-pill {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: 0.28rem 0.7rem; font-weight: 700; color: var(--ink); font-size: 0.82rem;
  box-shadow: 0 8px 18px rgba(15, 36, 48, 0.04);
}
.wallet-pill:hover { border-color: #b9d0ea; }
.wallet-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); display: inline-block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1rem; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-deep); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: transparent; color: var(--muted); }
.btn-send {
  width: 44px; height: 44px; border-radius: 14px; padding: 0;
  background: var(--blue); color: #fff; flex: none;
}
.btn-send:hover { background: var(--blue-deep); }
.btn-send svg { width: 18px; height: 18px; }

h1, h2, .serif { font-family: "Fraunces", serif; }
.kicker {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--teal); margin-bottom: 0.4rem;
}
.hero-mini { padding: 1.6rem 0 1.2rem; }
.hero-mini h1 { font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 600; letter-spacing: -0.02em; }
.hero-mini p { color: var(--muted); margin-top: 0.45rem; max-width: 48ch; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.2rem; box-shadow: var(--shadow);
  transition: transform .22s var(--ease), border-color .22s var(--ease), box-shadow .22s var(--ease);
}
.card h3 { font-size: 1.05rem; margin-bottom: 0.35rem; }
.card p, .muted { color: var(--muted); font-size: 0.9rem; }
a.card:hover { border-color: rgba(31, 111, 235, 0.35); transform: translateY(-2px); }

.form { display: grid; gap: 0.7rem; margin-top: 1rem; }
label { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
input, textarea, select {
  width: 100%; padding: 0.7rem 0.8rem; border: 1px solid var(--line);
  border-radius: 12px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.8rem; }
.crumb a { color: var(--blue); }
.banner {
  background: linear-gradient(135deg, #eef6f4, #eef4fb);
  border: 1px solid #cfe6e2; border-radius: 14px;
  padding: 0.85rem 1rem; font-size: 0.88rem; color: var(--muted); margin: 1rem 0;
}
.err { color: #b42318; font-size: 0.88rem; min-height: 1.2em; }
.split { display: grid; gap: 1.2rem; grid-template-columns: 1fr; }
@media (min-width: 880px) {
  .split-2 { grid-template-columns: 1.1fr 0.9fr; }
  .split-chat { grid-template-columns: 0.85fr 1.15fr; align-items: start; }
}

.chat, .chat-shell {
  background: var(--paper); border: 1px solid var(--line); border-radius: 22px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.chat-workspace {
  position: relative;
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  gap: 0.7rem;
  height: calc(100dvh - var(--nav-h) - var(--dock-h) - env(safe-area-inset-bottom, 0px) - 0.75rem);
  min-height: 420px;
  margin: 0.5rem 0 0;
}
.chat-rail {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.chat-rail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: 0.85rem 0.9rem; border-bottom: 1px solid var(--line);
}
.chat-rail-head h2 { font-size: 0.92rem; font-weight: 700; }
.chat-rail-head small { display: block; color: var(--muted); font-size: 0.68rem; font-weight: 600; margin-top: 0.1rem; }
.btn-new {
  flex: none; border-radius: 999px; padding: 0.35rem 0.7rem;
  background: var(--blue); color: #fff; font-size: 0.72rem; font-weight: 700;
}
.btn-new:hover { background: var(--blue-deep); }
.chat-thread-list { flex: 1; overflow-y: auto; padding: 0.45rem; }
.chat-thread-item {
  width: 100%; text-align: left; background: transparent;
  border: 1px solid transparent; border-radius: 14px;
  padding: 0.7rem 0.75rem; margin-bottom: 0.25rem; color: var(--ink);
}
.chat-thread-item:hover { background: #eef4f8; }
.chat-thread-item.is-on { background: #e8f0fe; border-color: #c9daf5; }
.chat-thread-item .t-title {
  font-weight: 700; font-size: 0.84rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-thread-item .t-meta {
  display: flex; justify-content: space-between; gap: 0.5rem;
  margin-top: 0.22rem; font-size: 0.7rem; color: var(--muted);
}
.chat-thread-item .t-pend { color: #8a692f; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.chat-rail-empty { padding: 1rem 0.8rem; color: var(--muted); font-size: 0.82rem; }
.chat-scrim { display: none; }
.btn-rail {
  display: none; width: 38px; height: 38px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); align-items: center; justify-content: center;
}
.btn-rail span { display: block; width: 16px; height: 1.6px; background: var(--ink); margin: 3px 0; border-radius: 2px; }
.chat-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  padding: 0.7rem 1rem 0.55rem; border-bottom: 0; background: #fbfcfd;
}
.chat-who { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.chat-who-mark {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--blue), var(--teal));
  color: #fff; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em;
}
.chat-who strong { font-size: 0.92rem; display: block; }
.chat-who em {
  display: block; font-style: normal; color: var(--muted); font-size: 0.72rem; font-weight: 500;
}
.chat-title-row {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0 0.85rem 0.65rem; border-bottom: 1px solid var(--line); background: #fbfcfd;
}
.chat-title-row input {
  border: 1px solid transparent; background: transparent; border-radius: 10px;
  padding: 0.28rem 0.45rem; font-weight: 700; font-size: 0.9rem; color: var(--ink);
}
.chat-title-row input:hover { border-color: var(--line); background: #fff; }
.chat-title-row input:focus {
  outline: 0; border-color: #b9d0ea; background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}
.chat-title-row .hint { color: var(--muted); font-size: 0.68rem; white-space: nowrap; }
.chat-shell {
  height: 100%;
  min-height: 0;
  margin: 0;
}
@media (max-width: 860px) {
  .btn-rail { display: inline-flex; flex-direction: column; }
  .chat-workspace { grid-template-columns: 1fr; }
  .chat-rail {
    position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 300px);
    z-index: 16; transform: translateX(-110%); transition: transform .22s var(--ease);
  }
  .chat-workspace.rail-open .chat-rail { transform: none; }
  .chat-scrim {
    display: none; position: absolute; inset: 0; background: rgba(15, 36, 48, 0.28); z-index: 15;
  }
  .chat-workspace.rail-open .chat-scrim { display: block; }
  .chat-title-row .hint { display: none; }
}
.chat-log {
  flex: 1; overflow-y: auto; padding: 1.1rem 1rem 0.6rem;
  display: flex; flex-direction: column; gap: 0.65rem;
}
.chat-empty {
  margin: auto; text-align: center; max-width: 28ch; padding: 1.5rem 0.5rem;
}
.chat-empty h2 { font-size: 1.35rem; font-weight: 600; margin-bottom: 0.4rem; }
.chat-empty p { color: var(--muted); font-size: 0.92rem; }
.msg {
  padding: 0.75rem 0.95rem; border-radius: 16px; font-size: 0.94rem;
  white-space: pre-wrap; max-width: 86%; line-height: 1.45;
}
.msg.user { background: #e8f0fe; margin-left: auto; border-bottom-right-radius: 6px; }
.msg.assistant { background: #f3f7f6; margin-right: auto; border-bottom-left-radius: 6px; }
.msg.system { background: #eef6f4; color: var(--muted); font-size: 0.86rem; max-width: 100%; }
.msg .who { font-size: 0.7rem; font-weight: 700; color: var(--muted); margin-bottom: 0.22rem; letter-spacing: 0.02em; }
.chat-status { font-size: 0.75rem; color: var(--muted); padding: 0 1rem 0.35rem; min-height: 1.1em; }
.chat-compose {
  display: flex; gap: 0.5rem; align-items: flex-end;
  padding: 0.7rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: #fbfcfd;
}
.chat-compose textarea {
  min-height: 44px; max-height: 160px; resize: none; border-radius: 14px;
  padding: 0.7rem 0.85rem; line-height: 1.4;
}

.file-list { list-style: none; display: grid; gap: 0.4rem; margin-top: 0.6rem; }
.file-list a { color: var(--blue); font-size: 0.88rem; }
.code-pill {
  font-family: ui-monospace, monospace; background: #eef4fb; padding: 0.2rem 0.55rem;
  border-radius: 8px; letter-spacing: 0.08em; font-weight: 700;
}
.slot-chip { font-size: 0.78rem; padding: 0.2rem 0.55rem; border-radius: 999px; border: 1px solid var(--line); }
.slot-chip.on { background: #e7f6ee; border-color: #b7e0c6; }
.slot-chip.off { background: #f4f6f8; }
.inst-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stat { font-family: "Fraunces", serif; font-size: 1.8rem; font-weight: 600; letter-spacing: -0.03em; }
footer.note { padding: 2rem 0 1rem; font-size: 0.8rem; color: var(--muted); }
.hidden { display: none !important; }
.wrap-narrow { width: min(440px, calc(100% - 2rem)); }
.seg {
  display: flex; gap: 0.3rem; background: #eef4f8; padding: 0.22rem;
  border-radius: 999px; width: fit-content;
}
body.edu-chat { height: 100dvh; overflow: hidden; }
body.edu-chat.edu-has-dock { padding-bottom: 0; }
