/* StudyChat (스터디챗) — visual system.
   Cool neutral surfaces, one indigo-violet accent used for anything the AI does,
   Pretendard for Korean and Latin text, and a matching dark theme. */

@font-face {
  font-family: "Pretendard Variable";
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
  src: url("/vendor/pretendard/PretendardVariable.woff2") format("woff2-variations");
}
/* The letters of a page StudyChat made itself (a web page, a transcript, pasted text:
   textpdf.js draws them in Pretendard): its invisible text layer, which selections and
   highlights are measured on, is set in the same letters so it lies exactly on the printed
   ones (viewer.js). Ascent and descent add up to one em, as PDF.js places a line of the
   layer as if they did, so the line sits on the printed line rather than below it. */
@font-face {
  font-family: "StudyChat Page Text";
  font-weight: 45 920;
  font-style: normal;
  font-display: block;
  ascent-override: 80%;
  descent-override: 20%;
  line-gap-override: 0%;
  src: url("/vendor/pretendard/PretendardVariable.woff2") format("woff2-variations");
}

:root {
  --bg: #f5f5f8;
  --surface: #ffffff;
  --surface-2: #f1f1f6;
  --surface-3: #e8e8f0;
  --ink: #14141b;
  --ink-2: #3b3b49;
  --muted: #6e6e7e;
  --line: #e5e5ee;
  --line-strong: #d2d2de;

  --accent: #5a5af0;
  --accent-2: #8a5cf6;
  --accent-ink: #ffffff;
  --accent-soft: #eeeefd;
  --accent-text: #4a48d8;
  --grad: linear-gradient(135deg, #5a5af0 0%, #8a5cf6 55%, #b765f2 100%);
  --ring: 0 0 0 3px rgb(90 90 240 / 0.22);

  --good: #0f8a55;
  --good-soft: #e2f6ec;
  --bad: #cf3e56;
  --bad-soft: #fdeaee;
  --warn: #9a6200;
  --warn-soft: #fdf2d6;
  --mark: #ffe680;
  --mark-ink: #3d3200;

  --pdf-bg: #e9e9f0;
  --shadow-sm: 0 1px 2px rgb(20 20 40 / 0.06);
  --shadow: 0 1px 2px rgb(20 20 40 / 0.05), 0 8px 24px rgb(20 20 40 / 0.08);
  --shadow-lg: 0 2px 6px rgb(20 20 40 / 0.06), 0 18px 48px rgb(20 20 40 / 0.16);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --font: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0c11;
    --surface: #15151c;
    --surface-2: #1d1d26;
    --surface-3: #282833;
    --ink: #f2f2f7;
    --ink-2: #cdcdd9;
    --muted: #8f8fa1;
    --line: #272732;
    --line-strong: #383846;

    --accent: #8482ff;
    --accent-2: #a57bff;
    --accent-ink: #0c0c11;
    --accent-soft: #22223f;
    --accent-text: #a9a7ff;
    --grad: linear-gradient(135deg, #7a78ff 0%, #a57bff 55%, #cf85ff 100%);
    --ring: 0 0 0 3px rgb(132 130 255 / 0.3);

    --good: #5fd49b;
    --good-soft: #15301f;
    --bad: #ff8fa1;
    --bad-soft: #3a1a22;
    --warn: #f0c060;
    --warn-soft: #33290f;
    --mark: #6b5800;
    --mark-ink: #fff3b8;

    --pdf-bg: #08080c;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 10px 28px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 2px 6px rgb(0 0 0 / 0.5), 0 22px 56px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 var(--font);
  letter-spacing: -0.005em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  height: 100%;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

p {
  margin: 0 0 0.65em;
}

a {
  color: var(--accent-text);
  text-underline-offset: 3px;
}

code {
  background: var(--surface-2);
  border-radius: 5px;
  padding: 0.08em 0.4em;
  font-size: 0.9em;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgb(90 90 240 / 0.22);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.pre {
  white-space: pre-wrap;
}
.pad {
  padding: 16px;
}
.spacer {
  flex: 1;
}
.icon {
  flex: none;
  display: block;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  padding: 9px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, filter 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn.primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 1px 2px rgb(60 50 200 / 0.3), 0 6px 16px rgb(90 80 240 / 0.24);
}
.btn.primary:hover:not(:disabled) {
  background: var(--grad);
  filter: brightness(1.08);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
.btn.ghost:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--ink);
}
.btn.small {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 7px;
}
.btn.large {
  padding: 12px 20px;
  font-size: 15px;
  border-radius: 10px;
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  padding: 0; /* (the browser's own button padding would push a small one's icon off its middle) */
  border-radius: 8px;
  cursor: pointer;
  flex: none;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-btn.danger:hover {
  background: var(--bad-soft);
  color: var(--bad);
}

.link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent-text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}
.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link.small {
  font-size: 13px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.chip .icon {
  color: var(--accent);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.send-btn {
  appearance: none;
  border: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  flex: none;
  display: inline-grid;
  place-items: center;
  box-shadow: 0 1px 2px rgb(60 50 200 / 0.3), 0 4px 12px rgb(90 80 240 / 0.25);
  transition: filter 0.15s, opacity 0.15s, transform 0.05s;
}
.send-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}
.send-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.send-btn.busy .icon {
  animation: nudge 1s ease-in-out infinite;
}
@keyframes nudge {
  50% {
    transform: translateY(-3px);
  }
}

:is(.btn, .icon-btn, .link, .chip, .send-btn, .qchip, .pick, .seg-btn, .tool, .action, .swatch, .drop, .dd, .exam-card, input, textarea, summary):focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag.ok {
  background: var(--good-soft);
  color: var(--good);
}
.tag.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.tag.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.tag.live,
.tag.ai {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.tag.web {
  background: var(--good-soft);
  color: var(--good);
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  display: inline-block;
  flex: none;
  animation: spin 0.8s linear infinite;
}
.spinner.large {
  width: 22px;
  height: 22px;
  border-width: 3px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .spinner {
    animation-duration: 2.4s !important;
  }
}

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

/* ---------- dropdown ---------- */

.dd {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 8px 6px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.dd:hover {
  background: var(--surface-2);
}
.dd[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.dd.block {
  display: flex;
  width: 100%;
}
.dd > .icon:first-child {
  color: var(--accent);
}
.dd > .icon:last-child {
  color: var(--muted);
  margin-left: auto;
  transition: transform 0.15s;
}
.dd[aria-expanded="true"] > .icon:last-child {
  transform: rotate(180deg);
}
.dd-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dd-prefix {
  color: var(--muted);
  font-weight: 500;
}

.dd-menu {
  position: fixed;
  z-index: 200;
  overflow: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  outline: none;
  animation: pop-in 0.12s ease-out;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.985);
  }
}
.dd-group {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 10px 4px;
}
.dd-group:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.dd-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.dd-opt.active {
  background: var(--surface-2);
}
.dd-opt.selected .dd-title {
  color: var(--accent-text);
}
.dd-opt.disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.dd-text {
  flex: 1;
  min-width: 0;
}
.dd-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.dd-title {
  font-weight: 650;
  font-size: 14px;
}
.dd-meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dd-note {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}
.dd-check {
  width: 16px;
  flex: none;
  color: var(--accent);
}

/* ---------- segmented control ---------- */

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border-radius: 10px;
}
.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.seg-btn:hover {
  color: var(--ink);
}
.seg-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.seg-btn.active .icon {
  color: var(--accent);
}

/* ---------- library ---------- */

.library {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 24px 96px;
}
.lib-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 44px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 16px;
  letter-spacing: -0.02em;
}
/* The app's mark (and its tab icon, index.html): a soft lavender tile with the sparkle outlined in the accent colour. */
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.hero {
  text-align: center;
  margin-bottom: 32px;
}
.eyebrow {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(28px, 4.4vw, 42px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.2;
  margin-bottom: 12px;
}
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  color: var(--muted);
  font-size: 16px;
  max-width: 560px;
  margin: 0 auto;
}

.banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.banner-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.banner-text {
  flex: 1;
  display: grid;
  gap: 1px;
  font-size: 13.5px;
  color: var(--ink-2);
}
.banner-text strong {
  font-size: 15px;
  color: var(--ink);
}

.upload {
  padding: 18px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
}
.drop {
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  padding: 34px 16px;
  text-align: center;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 4px;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover,
.drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--accent);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
}
.drop-title {
  font-weight: 700;
  font-size: 16px;
}
.drop-sub {
  font-size: 13px;
  color: var(--muted);
}
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 16px;
}
.upload-field {
  display: grid;
  gap: 6px;
  min-width: 0;
  align-content: start;
}
.upload-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}
.upload-submit {
  display: flex;
  gap: 10px;
}
.upload p {
  margin: 0;
}
.field-label {
  font-weight: 650;
  font-size: 13.5px;
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 40px 0 14px;
}
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}
.exam-card {
  display: grid;
  gap: 6px;
  padding: 16px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.exam-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.exam-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.exam-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}
.exam-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.exam-error {
  font-size: 13px;
  color: var(--bad);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.exam-progress {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.bar {
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--grad);
  transition: width 0.4s;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 24px;
}
.step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  display: grid;
  gap: 4px;
  align-content: start;
}
.step-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 8px;
}
.step-n {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-text);
}
.step p {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------- study screen ---------- */

.study {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  min-height: 56px;
  position: relative;
  z-index: 10;
}
.top-info {
  display: grid;
  gap: 1px;
  min-width: 90px;
  flex: 0 1 auto;
  overflow: hidden;
}
.top-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-status {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.top-status .tag.bad {
  display: block;
  max-width: 340px;
}
.top-tools {
  flex: none;
}
.zoom {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 2px;
}
.zoom .icon-btn {
  width: 28px;
  height: 28px;
}
.zoom .icon-btn:hover {
  background: var(--surface);
}
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
}
.pane {
  flex: 1;
  min-width: 0;
  position: relative;
  background: var(--pdf-bg);
}
.pdf-container {
  position: absolute;
  inset: 0;
  overflow: auto;
}
.pdf-container:focus {
  outline: none;
}
/* The paper is the original PDF, drawn page for page; only the frame around it is ours. */
.pdfViewer .page {
  box-shadow: 0 1px 3px rgb(20 20 40 / 0.12), 0 10px 30px rgb(20 20 40 / 0.1);
  /* PDF.js sizes a page without its frame. Counted in (as `* { box-sizing: border-box }`
     does), the drawn page came out a frame's width smaller than its text layer, so a
     selection or highlight slid off the letters toward the right and the foot of the page. */
  box-sizing: content-box;
}
/* (a page StudyChat made: its text layer is set as it was printed, with no kerning: viewer.js unkern) */
.pdfViewer .textLayer.unkerned span {
  font-kerning: none;
}
.pdfViewer .textLayer.bold-probe span {
  font-weight: 700;
}
.pdfViewer .textLayer ::selection {
  background: rgb(255 208 60 / 0.5);
}
.pane.marking .textLayer :is(span, br) {
  cursor: crosshair;
}

.resizer {
  width: 5px;
  cursor: col-resize;
  background: var(--line);
  flex: none;
  touch-action: none;
  transition: background 0.15s;
}
.resizer:hover {
  background: var(--accent);
}

.side {
  width: 480px;
  max-width: 64vw;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
}
.side-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 10px;
}
.side-head .tabs {
  display: flex;
}
.side-head .tabs .seg-btn {
  flex: 1;
}

.qnav {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 104px;
  overflow: auto;
}
.qgroup {
  display: flex;
  gap: 1px;
  padding: 2px;
  border-radius: 9px;
  background: var(--surface-2);
}
.qgroup.pending,
.qgroup.running {
  opacity: 0.55;
}
.qgroup.running {
  animation: pulse 1.4s ease-in-out infinite;
}
.qgroup.error {
  background: var(--bad-soft);
}
@keyframes pulse {
  50% {
    opacity: 0.95;
  }
}
.qchip {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  min-width: 28px;
  height: 26px;
  padding: 0 5px;
  border-radius: 7px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s, color 0.12s;
}
.qchip:hover {
  background: var(--surface);
}
.qchip.answered {
  border-color: var(--line-strong);
  background: var(--surface);
}
.qchip.seen {
  color: var(--muted);
}
.qchip.right {
  background: var(--good-soft);
  color: var(--good);
}
.qchip.wrong {
  background: var(--bad-soft);
  color: var(--bad);
}
.qchip.current {
  background: var(--ink);
  color: var(--bg);
  border-color: transparent;
}

.tabpanel {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.tabpanel.notes {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side ::selection {
  background: var(--mark);
  color: var(--mark-ink);
}

/* ---------- notes ---------- */

.group-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 2px 2px 0;
}
.group-info {
  min-width: 0;
}
.group-title {
  font-weight: 750;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.group-num {
  color: var(--accent-text);
  margin-right: 8px;
}

.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  line-height: 1.75;
  box-shadow: var(--shadow-sm);
}
.note-card h3 {
  font-size: 16px;
  font-weight: 750;
}
.note-card h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
  margin: 18px 0 6px;
}
.note-card p:last-child {
  margin-bottom: 0;
}
.note-card.question.current {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent), var(--shadow-sm);
}
.empty-card,
.search-empty,
.chat-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
  padding: 30px 22px;
}
.empty-card p,
.search-empty p,
.chat-empty p {
  margin: 0 0 8px;
  max-width: 340px;
  font-size: 14px;
}
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}
.empty-icon.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.background summary {
  cursor: pointer;
  font-weight: 750;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px -6px 8px;
  padding: 4px 6px;
  border-radius: 8px;
  list-style: none;
}
.background summary::-webkit-details-marker {
  display: none;
}
.background summary .muted {
  font-weight: 500;
}
.background summary::after {
  content: "";
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-135deg) translate(-2px, -2px);
  transition: transform 0.15s;
}
.background:not([open]) summary::after {
  transform: rotate(45deg) translate(-2px, -2px);
}
.background:not([open]) summary {
  margin-bottom: -4px;
}
.card-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}
.concepts {
  margin: 0;
  display: grid;
  gap: 8px;
}
.concept {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.concepts dt {
  font-weight: 700;
}
.concepts dd {
  margin: 2px 0 0;
}
.concepts dd p {
  margin: 0 0 4px;
}
.in-passage {
  color: var(--ink-2);
  font-size: 14px;
}
.in-passage strong {
  color: var(--accent-text);
}
.vocab {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}
.vocab li {
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.vocab strong {
  flex: none;
}
.vocab span {
  color: var(--ink-2);
}
.written-by {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.q-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.prep {
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.prep h4 {
  margin-top: 0;
  color: var(--accent-text);
}
.picks {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.picks-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 6px;
}
.pick {
  appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s, transform 0.05s;
}
.pick:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}
.pick:active {
  transform: scale(0.95);
}
.pick.chosen {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.pick.is-answer {
  background: var(--good);
  border-color: var(--good);
  color: var(--surface);
}
.pick.is-wrong {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad);
}
.reveal {
  margin-top: 14px;
  width: 100%;
}
.answer-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.answer-badge {
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.answer-badge b {
  font-size: 20px;
  color: var(--good);
}
.note-warning {
  background: var(--warn-soft);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  margin-top: 10px;
}
.choices {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.choices li {
  display: flex;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid transparent;
}
.choices li.correct {
  background: var(--good-soft);
  border-color: color-mix(in srgb, var(--good) 30%, transparent);
}
.choices .label {
  font-weight: 750;
  flex: none;
}
.choices li.correct .label {
  color: var(--good);
}
.q-foot {
  display: flex;
  gap: 4px;
  margin: 12px -6px -4px;
}

/* ---------- composer (chat and search) ---------- */

.composer {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow);
}
.composer-input,
.composer-input:focus {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  resize: none;
  padding: 6px 8px;
  min-height: 34px;
  max-height: 180px;
  field-sizing: content;
  line-height: 1.55;
}
.composer-main {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.composer-pickers {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.composer-pickers .dd {
  border-color: transparent;
  background: var(--surface-2);
}
.composer-pickers .dd:hover {
  background: var(--surface-3);
}

/* ---------- chat ---------- */

.tabpanel.chat,
.tabpanel.search {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-head,
.search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  min-height: 42px;
}
.chat-head .muted {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-empty {
  margin: auto 0;
}
.chat-empty .chip {
  width: 100%;
  max-width: 340px;
  justify-content: flex-start;
}
.msg {
  max-width: 94%;
  line-height: 1.72;
}
.msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--bg);
  padding: 9px 14px;
  border-radius: 16px 16px 4px 16px;
}
.msg.user .msg-body {
  white-space: pre-wrap;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 12px 15px;
  border-radius: 4px 16px 16px 16px;
  box-shadow: var(--shadow-sm);
}
.msg-quote,
.chat-quote {
  margin: 0 0 8px;
  padding: 5px 10px;
  border-left: 3px solid #e3b400;
  background: var(--mark);
  color: var(--mark-ink);
  border-radius: 6px;
  font-size: 13px;
  white-space: normal;
}
.msg-quote {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.msg-image {
  display: block;
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
}
.msg-meta {
  margin-top: 8px;
  font-size: 12px;
}
.msg-meta:empty {
  display: none;
}
.msg-sources {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.source {
  font-size: 12.5px;
  font-weight: 550;
  text-decoration: none;
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 10px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.source:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.chat-compose,
.search-top {
  padding: 10px 12px 12px;
}
.search-top {
  padding-bottom: 4px;
}
.chat-quote {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 0 0 6px;
}
.chat-quote .icon-btn,
.chat-image .icon-btn {
  width: 22px;
  height: 22px;
  color: inherit;
}
.chat-quote-text {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat-image {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 6px;
  background: var(--surface-2);
  border-radius: 10px;
}
.chat-image img {
  height: 44px;
  max-width: 120px;
  object-fit: cover;
  border-radius: 6px;
  background: #fff;
}
.chat-image .muted {
  flex: 1;
}

/* ---------- search ---------- */

.search-results {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.search-empty {
  margin: auto 0;
}
.result {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  line-height: 1.72;
}
.result-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.result-head h3 {
  flex: 1;
  font-size: 16px;
  font-weight: 750;
}
.result-head .icon-btn {
  width: 26px;
  height: 26px;
  margin: -2px -6px 0 0;
}
.result-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 10px;
  min-height: 0;
}
.result-tags:empty {
  display: none;
}

/* ---------- rendered markdown ---------- */

.md > :first-child {
  margin-top: 0;
}
.md > :last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0 0 0.75em;
}
.md ul,
.md ol {
  margin: 0 0 0.75em;
  padding-left: 1.3em;
}
.md li + li {
  margin-top: 0.3em;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  font-size: 1em;
  font-weight: 750;
  margin: 1.1em 0 0.4em;
}
.md strong {
  font-weight: 700;
}
.md blockquote {
  margin: 0 0 0.75em;
  padding-left: 12px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}
.md pre {
  overflow: auto;
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 10px;
}
.md table {
  border-collapse: collapse;
  display: block;
  overflow: auto;
  margin-bottom: 0.75em;
}
.md th,
.md td {
  border: 1px solid var(--line);
  padding: 5px 9px;
}
.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1em 0;
}

/* ---------- reading tools ---------- */

.tool-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border-radius: 12px;
}
.tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.tool:hover {
  background: var(--surface);
  color: var(--ink);
}
.tool.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 1px 2px rgb(60 50 200 / 0.3), 0 4px 12px rgb(90 80 240 / 0.25);
}
.swatches {
  display: inline-flex;
  gap: 5px;
  padding: 0 8px 0 4px;
}
.swatch {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 0 0 1px var(--line-strong);
}
.swatch.active {
  box-shadow: 0 0 0 2px var(--ink);
}
.swatch.yellow {
  background: #ffe04a;
}
.swatch.green {
  background: #86e09a;
}
.swatch.pink {
  background: #ff9ec4;
}
.tool-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 550;
  background: color-mix(in srgb, var(--ink) 88%, transparent);
  color: var(--bg);
  padding: 5px 13px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Saved highlighter marks sit above the page and let clicks and selections through. */
.hl-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.hl {
  position: absolute;
  border-radius: 2px;
}
.hl.yellow {
  background: rgb(255 224 74 / 0.55);
}
.hl.green {
  background: rgb(134 224 154 / 0.55);
}
.hl.pink {
  background: rgb(255 158 196 / 0.55);
}

/* The selection on a page whose text cannot be selected natively. */
.pick-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: multiply;
}
.pick-strip {
  position: absolute;
  background: rgb(255 208 60 / 0.55);
  border-radius: 2px;
}
.pdf-container.over-text {
  cursor: text;
}

.capture-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  cursor: crosshair;
  background: rgb(20 20 40 / 0.08);
  touch-action: none;
}
.capture-box {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: rgb(90 90 240 / 0.1);
  box-shadow: 0 0 0 9999px rgb(20 20 40 / 0.22);
}

.popover {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in 0.12s ease-out;
}
.action-bar {
  display: flex;
  gap: 2px;
  padding: 4px;
}
.action {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.action .icon {
  color: var(--accent);
}
.action:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.action.danger .icon {
  color: var(--bad);
}
.action.danger:hover {
  background: var(--bad-soft);
  color: var(--bad);
}
.pop-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 8px 9px 14px;
  background: var(--mark);
  color: var(--mark-ink);
}
.pop-quote {
  flex: 1;
  font-weight: 700;
  padding-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pop-quote img {
  display: block;
  max-width: 100%;
  max-height: 96px;
  border-radius: 6px;
  background: #fff;
}
.result-image {
  display: block;
  max-width: 100%;
  max-height: 120px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.pop-head .icon-btn {
  color: inherit;
  width: 28px;
  height: 28px;
}
.pop-head .icon-btn:hover {
  background: rgb(0 0 0 / 0.1);
}
.pop-body {
  padding: 13px 15px;
  overflow: auto;
  line-height: 1.72;
}
.pop-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.pop-input {
  flex: 1;
  min-width: 0;
  padding: 7px 11px !important;
  font-size: 13px !important;
  background: var(--surface-2) !important;
  border-color: transparent !important;
}
.pop-input:focus {
  border-color: var(--accent) !important;
  background: var(--surface) !important;
}
.pop-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
}
.pop-error {
  color: var(--bad);
  background: var(--bad-soft);
  border-radius: 10px;
  padding: 9px 12px;
}
.capture-body {
  display: grid;
  gap: 10px;
}
.pop-textarea {
  resize: none;
  font-size: 14px !important;
}

/* ---------- settings dialog & toasts ---------- */

.app-dialog {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-lg);
}
.app-dialog[open] {
  animation: pop-in 0.16s ease-out;
}
.app-dialog::backdrop {
  background: rgb(10 10 20 / 0.5);
  backdrop-filter: blur(3px);
}
.dialog-body {
  padding: 24px;
  display: grid;
  gap: 14px;
}
.dialog-body h2 {
  font-size: 22px;
  font-weight: 800;
}
.dialog-body p {
  margin: 0;
}
.dialog-section {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-text);
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
h2 + .dialog-section {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
.field {
  display: grid;
  gap: 5px;
}
.field-help,
.usage {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}
.model-grid {
  display: grid;
  gap: 12px;
}
.model-role {
  display: grid;
  gap: 5px;
}
.model-pick {
  display: flex;
  gap: 6px;
}
.model-pick .dd.block {
  flex: 1;
  width: auto;
}
.usage {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  position: sticky;
  bottom: -24px;
  margin: 4px -24px -24px;
  padding: 14px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}

#toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  z-index: 300;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--ink);
  color: var(--bg);
  font-weight: 550;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.16s ease-out;
}
.toast.error {
  background: var(--bad);
  color: #fff;
}

/* ---------- narrow windows ---------- */

@media (max-width: 860px) {
  .workspace {
    flex-direction: column;
  }
  .side {
    width: 100% !important;
    max-width: none;
    height: 58%;
  }
  .resizer {
    display: none;
  }
  .upload-grid,
  .steps {
    grid-template-columns: 1fr;
  }
  .upload-submit {
    flex-wrap: wrap;
  }
  .lib-nav {
    margin-bottom: 28px;
  }
  .banner {
    flex-wrap: wrap;
  }
}

/* ---------- right-hand panel: problems on top, AI box docked below ---------- */

.problems {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.group-steps {
  display: flex;
  gap: 2px;
  flex: none;
}
.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.q-head {
  align-items: baseline;
  gap: 10px;
}
.q-head h3 {
  flex: none;
}
.q-stem {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.55;
}
.pick:disabled {
  cursor: default;
  opacity: 1;
}
.pick:disabled:not(.chosen):not(.is-answer):not(.is-wrong) {
  opacity: 0.45;
}
.verdict {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
}
.verdict.right {
  background: var(--good-soft);
  color: var(--good);
}
.verdict.wrong {
  background: var(--bad-soft);
  color: var(--bad);
}
.verdict-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: currentColor;
  display: grid;
  place-items: center;
  flex: none;
}
.verdict-mark .icon {
  color: var(--surface);
}
.verdict .answer-badge {
  color: var(--ink);
  margin-left: 4px;
}
.verdict .answer-badge b {
  color: inherit;
}
.why {
  margin: 12px 0 0;
}
.my-wrong {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bad-soft);
}
.my-wrong strong {
  color: var(--bad);
  font-size: 13px;
}
.my-wrong p {
  margin: 2px 0 0;
}
.all-choices {
  margin-top: 12px;
}
.all-choices summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  color: var(--accent-text);
  padding: 4px 0;
  border-radius: 6px;
}
.all-choices .choices {
  margin-top: 8px;
}
.revealed > .pop-loading,
.revealed > .pop-error {
  margin-top: 12px;
}
.revealed > .btn {
  margin-top: 8px;
}

.dock {
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgb(20 20 40 / 0.06);
  max-height: 100%;
}
.dock.open {
  height: 56%;
  min-height: 280px;
}
.dock-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 0 14px;
  min-height: 38px;
  cursor: pointer;
  user-select: none;
}
.dock-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.dock-title .icon {
  color: var(--accent);
}
.dock-scope {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.dock-toggle .icon {
  transition: transform 0.15s;
  transform: rotate(180deg);
}
.dock.open .dock-toggle .icon {
  transform: none;
}
.dock .chat-list {
  padding: 8px 14px 6px;
}
.dock .chat-compose {
  padding: 6px 10px 10px;
}
.dock .composer {
  box-shadow: none;
  background: var(--surface-2);
  border-color: transparent;
}
.dock .composer:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.dock .composer-pickers .dd {
  background: var(--surface);
}
.chat-empty {
  padding: 14px 8px;
}
.chat-empty p {
  max-width: none;
  margin: 0;
  font-size: 13.5px;
}

.toggle {
  appearance: none;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.toggle:hover {
  color: var(--ink);
}
.toggle.on {
  background: var(--good-soft);
  border-color: color-mix(in srgb, var(--good) 40%, transparent);
  color: var(--good);
}
.toggle:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.attachments {
  display: grid;
  gap: 4px;
  padding: 2px 2px 6px;
  max-height: 150px;
  overflow: auto;
}
.attachments .chat-quote {
  margin: 0;
}
.chat-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chat-images .chat-image {
  position: relative;
  margin: 0;
  padding: 4px;
}
.chat-images .chat-image img {
  height: 52px;
  max-width: 160px;
}
.chat-images .chat-image .icon-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  width: 20px;
  height: 20px;
}
.msg-web {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.75;
  margin-bottom: 2px;
}
.msg-quote + .msg-quote {
  margin-top: -4px;
}

/* ---------- saved 뜻 풀이 notes on the paper ---------- */

.hl.note {
  background: rgb(138 92 246 / 0.16);
  border-bottom: 2px solid rgb(110 80 235 / 0.9);
  border-radius: 2px 2px 0 0;
}
.pdf-container.over-note {
  cursor: help;
}
.note-tip {
  position: fixed;
  z-index: 45;
  pointer-events: none;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.65;
  max-height: 46vh;
  overflow: hidden;
  animation: pop-in 0.1s ease-out;
}

/* ---------- upload: answer key drop area ---------- */

.lib-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.key-drop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.key-drop:hover,
.key-drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.key-drop.has-file {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}
.key-drop:focus-visible,
.drop:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.key-drop-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}
.key-drop-text {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.key-drop-text strong {
  font-size: 14px;
}
.key-name {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-drop.has-file .key-name {
  color: var(--accent-text);
  font-weight: 600;
}
.upload-submit input {
  flex: 1;
  min-width: 0;
}

/* A file dragged over the study screen */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgb(10 10 20 / 0.45);
  backdrop-filter: blur(3px);
  pointer-events: none;
}
.drop-overlay[hidden] {
  display: none;
}
.drop-overlay-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 36px;
  border-radius: var(--r-lg);
  border: 2px dashed var(--accent);
  background: var(--surface);
  color: var(--accent-text);
  box-shadow: var(--shadow-lg);
}
.drop-overlay-card strong {
  color: var(--ink);
  font-size: 16px;
}
.drop-overlay-card span {
  font-size: 13px;
  color: var(--muted);
}

/* ---------- sections of reading material ---------- */

.qchip.section {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 190px;
  padding: 0 9px 0 4px;
  background: var(--surface-2);
  font-weight: 550;
}
.qchip.section b {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--surface);
  font-size: 11.5px;
  line-height: 18px;
  text-align: center;
  color: var(--muted);
}
.qchip.section span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qchip.section.current {
  background: var(--ink);
  color: var(--bg);
}
.qchip.section.current b {
  background: color-mix(in srgb, var(--bg) 22%, transparent);
  color: var(--bg);
}
.section-card {
  display: grid;
  gap: 12px;
}
.section-card p {
  margin: 0;
}
.section-asks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.section-asks .btn .icon {
  color: var(--accent);
}
.verdict.written {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.answer-text {
  margin: 12px 0 0;
  font-weight: 650;
  line-height: 1.65;
}

/* ---------- account, free allowance and credits (hosted site) ---------- */

.account-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.account-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.account-chip:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.account-chip .icon {
  color: var(--accent);
}
.account-chip.paid {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.dialog-group {
  display: grid;
  gap: 14px;
}
.dialog-group[hidden] {
  display: none;
}
.account-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.account-figure {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.account-figure strong {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.account-figure strong small {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.account-row input {
  flex: 1;
  min-width: 0;
}
.account-signin {
  display: grid;
  gap: 8px;
}
.packs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pack {
  appearance: none;
  display: grid;
  justify-items: start;
  gap: 3px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.pack strong {
  font-size: 16px;
  font-weight: 750;
}
.pack > span:not(.tag) {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pack:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.pack:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-size: 13.5px;
}
.history li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.history li:last-child {
  border-bottom: 0;
}
.history .plus {
  color: var(--good);
}
@media (max-width: 560px) {
  .packs {
    grid-template-columns: 1fr;
  }
}

/* ---------- AI box filling the whole right-hand panel ---------- */

.side.chat-only .side-head,
.side.chat-only .problems {
  display: none;
}
.dock.full {
  flex: 1;
  height: auto;
  min-height: 0;
  max-height: none;
  border-top: 0;
  box-shadow: none;
}
.dock.full .dock-head {
  cursor: default;
  padding-top: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.dock.full .chat-list {
  padding-top: 14px;
}
.dock-full[hidden],
.dock-toggle[hidden] {
  display: none;
}
.chat-empty strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}
.dock.full .chat-empty {
  margin: auto 0;
  padding: 24px 12px;
  text-align: center;
}
.dock.full .chat-empty p {
  max-width: 420px;
  margin: 0 auto;
}

/* ---------- reading help / problem solving ---------- */

.mode-pick .seg-btn {
  padding: 5px 9px;
}
.upload-mode {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.key-drop[hidden] {
  display: none;
}
@media (max-width: 900px) {
  .mode-pick .seg-btn {
    font-size: 0;
    gap: 0;
  }
}

/* ---------- sign-up, sign-in and account forms ---------- */

.account-form {
  gap: 12px;
}
.account-form input[type="email"],
.account-form input[type="password"],
.account-form input[type="text"] {
  width: 100%;
}
.back-link {
  justify-self: start;
}
.form-error {
  color: var(--bad);
  font-size: 13.5px;
  min-height: 1.2em;
  margin: 0;
}
.checks {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-2);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.check input {
  margin-top: 3px;
  accent-color: var(--accent);
}
.account-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.account-email {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.link.danger {
  color: var(--bad);
}
.admin-code summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.admin-code .account-row {
  margin-top: 8px;
}
.account-chip-login {
  padding-left: 8px;
  margin-left: 2px;
  border-left: 1px solid var(--line-strong);
  color: var(--accent-text);
}
.dialog-actions .link {
  align-self: center;
}

/* ---------- policy pages and footer ---------- */

.legal h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.legal section {
  margin-top: 26px;
}
.legal h2 {
  font-size: 16px;
  font-weight: 750;
  margin: 0 0 8px;
}
.legal p,
.legal li {
  line-height: 1.75;
  color: var(--ink-2);
  font-size: 14.5px;
}
.legal ul {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}
.site-footer {
  margin-top: 72px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.site-footer p {
  margin: 0;
}
.footer-links {
  display: flex;
  gap: 16px;
}
.footer-links a {
  color: var(--ink-2);
  text-decoration: none;
}
.footer-links a:hover {
  text-decoration: underline;
}
.footer-info {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

/* ---------- sign-in and sign-up forms ---------- */

.app-dialog.narrow {
  width: min(430px, calc(100vw - 32px));
}
.account-form {
  gap: 14px;
  padding: 26px 26px 24px;
}
.account-form h2 {
  font-size: 24px;
  letter-spacing: -0.02em;
  margin-top: -2px;
}
.account-form .field {
  gap: 6px;
}
.account-form .field-label {
  font-size: 13px;
  color: var(--ink-2);
}
.account-form input[type="text"],
.account-form input[type="email"],
.account-form input[type="password"] {
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 15px;
}
.account-form input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
.account-form button[type="submit"] {
  width: 100%;
  height: 48px;
  justify-content: center;
  border-radius: 12px;
  font-size: 15.5px;
  margin-top: 2px;
}
.account-form .form-error:empty {
  display: none;
}
.account-form .form-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bad-soft);
}
.pw-wrap {
  position: relative;
  display: block;
}
.pw-wrap input {
  padding-right: 46px !important;
}
.pw-eye {
  appearance: none;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.pw-eye:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.pw-eye.on {
  color: var(--accent);
}
.pw-rules {
  list-style: none;
  margin: -4px 0 0;
  padding: 0;
  display: grid;
  gap: 3px;
  font-size: 12.5px;
  color: var(--muted);
}
.pw-rules li {
  display: flex;
  align-items: center;
  gap: 7px;
}
.pw-rules li::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  flex: none;
}
.pw-rules li.ok {
  color: var(--good);
}
.pw-rules li.ok::before {
  border-color: var(--good);
  background: var(--good)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E")
    center / 9px no-repeat;
}
.checks {
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  background: transparent;
}
.check {
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}
.check input {
  width: 17px;
  height: 17px;
  margin: 0;
  flex: none;
}
.check-all {
  font-weight: 700;
  font-size: 14.5px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.account-links.centered {
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.code-input {
  font-size: 26px !important;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  height: 60px !important;
}

/* Sign-in with Google, Kakao, Naver: each in its provider's own colours */
.social {
  display: grid;
  gap: 8px;
}
.social-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 46px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.12s, box-shadow 0.12s;
}
.social-btn svg {
  position: absolute;
  left: 16px;
  width: 20px;
  height: 20px;
}
.social-btn:hover {
  filter: brightness(0.96);
}
.social-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.social-btn.google {
  background: #fff;
  color: #1f1f1f;
  border-color: #dadce0;
}
.social-btn.kakao {
  background: #fee500;
  color: rgb(0 0 0 / 0.85);
}
.social-btn.naver {
  background: #03c75a;
  color: #fff;
}
.social-btn.naver svg {
  width: 16px;
  height: 16px;
  left: 18px;
}
.social-note {
  position: absolute;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
}
.social-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 2px;
  font-size: 12.5px;
  color: var(--muted);
}
.social-divider::before,
.social-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- "are you sure?" box ---------- */

.confirm-dialog {
  width: min(400px, calc(100vw - 32px));
}
.confirm-dialog h2 {
  font-size: 19px;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.btn.danger-fill {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}
.btn.danger-fill:hover:not(:disabled) {
  filter: brightness(0.94);
}

/* ---------- language switch ---------- */

.lang-switch {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.lang-switch:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.lang-switch:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.lang-switch .icon {
  color: var(--accent);
}

/* ---------- formulas ---------- */

.katex {
  font-size: 1.08em;
}
.katex-display {
  margin: 0.7em 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.md .katex-display > .katex {
  white-space: nowrap;
}

/* ---------- more credit amounts ---------- */

.packs {
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
}
.pack-custom {
  display: grid;
  gap: 6px;
}
.pack-custom input {
  flex: 1;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

/* ---------- closed-site password screen ---------- */

.gate-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate {
  width: min(380px, 100%);
  padding: 30px 26px;
  display: grid;
  gap: 14px;
  justify-items: stretch;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.gate .brand-mark {
  justify-self: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
}
.gate h1 {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
}
.gate p {
  margin: 0;
}
.gate input {
  height: 46px;
  border-radius: 12px;
  text-align: center;
}
.gate .btn {
  justify-content: center;
}

/* ---------- action bars never cut a label off ---------- */

.action {
  white-space: nowrap;
}

/* ---------- graphs in answers ---------- */

.graph {
  margin: 10px 0;
  padding: 8px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.graph-svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font);
}
.graph-grid line {
  stroke: var(--line);
  stroke-width: 1;
}
.graph-axes line {
  stroke: var(--muted);
  stroke-width: 1.4;
}
.graph-tick {
  fill: var(--muted);
  font-size: 11px;
}
.graph-title {
  fill: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
.graph-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.graph-c0 { stroke: #5a5af0; background: #5a5af0; }
.graph-c1 { stroke: #e0603a; background: #e0603a; }
.graph-c2 { stroke: #1a9b6b; background: #1a9b6b; }
.graph-c3 { stroke: #b45cd6; background: #b45cd6; }
.graph-c4 { stroke: #c79a12; background: #c79a12; }
.graph-point {
  fill: #e0364f;
  stroke: var(--surface);
  stroke-width: 2;
}
.graph-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
}
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 6px 8px 2px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.graph-swatch {
  width: 16px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}
.graph-swatch.dashed {
  background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important;
}
.graph-note {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
}

/* ---------- handwriting pad ---------- */

.pad-btn {
  white-space: nowrap;
}
.pad-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(10 10 20 / 0.45);
  backdrop-filter: blur(3px);
}
.pad-sheet {
  width: min(900px, 100%);
  height: min(620px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.pad-head,
.pad-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.pad-head {
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.pad-foot {
  border-top: 1px solid var(--line);
}
.pad-area {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #fff;
  background-image: linear-gradient(#eef0f6 1px, transparent 1px);
  background-size: 100% 32px;
}
.pad-canvas {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}
.pad-tool {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.pad-tool.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ---------- notes panel ---------- */

.side.notes-open > :not(.notes-panel) {
  display: none !important;
}
.notes-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.notes-panel[hidden] {
  display: none;
}
.notes-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.notes-status {
  min-width: 0;
}
.notes-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 10px;
}
.notes-block {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.notes-block:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.notes-text {
  display: block;
  width: 100%;
  min-height: 84px;
  border: 0 !important;
  box-shadow: none !important;
  resize: none;
  padding: 12px 40px 12px 14px !important;
  line-height: 1.65;
  background: transparent !important;
}
.notes-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity 0.12s;
}
.notes-block:hover .notes-remove,
.notes-block:focus-within .notes-remove {
  opacity: 1;
}
.notes-block.ink .notes-remove {
  position: static;
  opacity: 1;
}
.notes-ink-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-bottom: 1px solid var(--line);
}
.notes-ink-bar .pad-tool {
  width: 32px;
  height: 32px;
}
.notes-ink {
  display: block;
  width: 100%;
  background: #fff;
  background-image: linear-gradient(#eef0f6 1px, transparent 1px);
  background-size: 100% 28px;
  border-radius: 0 0 12px 12px;
  touch-action: none;
  cursor: crosshair;
}
.notes-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* ---------- dragging the document in empty space ---------- */

.pdf-container {
  cursor: grab;
}
.pdf-container .textLayer span {
  cursor: text;
}
.pdf-container.panning,
.pdf-container.panning * {
  cursor: grabbing !important;
  user-select: none;
}

/* ---------- phones and tablets ---------- */

.brand,
.lang-switch,
.account-chip-text,
.account-chip-login {
  white-space: nowrap;
}
.lib-nav {
  gap: 10px;
}
.pack > span:not(.tag) {
  white-space: nowrap;
}
.pad-head > .muted {
  min-width: 0;
}
.pad-tool {
  flex: none;
}
.composer-bar {
  flex-wrap: nowrap;
}
.composer-bar > .send-btn,
.composer-bar > .pad-btn {
  flex: none;
}
.composer-pickers {
  flex: 0 1 auto;
}
.composer-pickers .dd {
  flex: 0 1 auto;
}
.top-info {
  min-width: 120px;
}
.top-status > * {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.pad-canvas {
  width: 100%;
  height: 100%;
}
.app-dialog {
  max-height: min(calc(100vh - 48px), calc(100dvh - 24px));
}
.gate-wrap {
  min-height: 100dvh;
}

@media (max-width: 860px) {
  /* Stacked: the document on top, the panel below, with a bar between to drag. */
  .resizer {
    display: block;
    width: auto;
    height: 16px;
    cursor: row-resize;
    position: relative;
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .resizer::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--line-strong);
    transform: translate(-50%, -50%);
  }
  .resizer:hover {
    background: var(--surface);
  }
  .side {
    height: var(--side-h, 58%);
    min-height: 140px;
    max-height: calc(100% - 110px);
  }
  .dock.open {
    height: 50%;
    min-height: min(220px, 100%);
  }
  /* Question numbers on one row that slides sideways, so the questions keep their room. */
  .qnav {
    flex-wrap: nowrap;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .qnav::-webkit-scrollbar {
    display: none;
  }
  .qgroup {
    flex: none;
  }
  .side-head {
    padding: 8px 10px;
  }
}

@media (max-width: 560px) {
  .library {
    padding: 14px 16px 72px;
  }
  .lib-nav {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 22px;
  }
  .brand {
    gap: 8px;
    font-size: 15px;
  }
  .lib-actions {
    gap: 6px;
    margin-left: auto;
  }
  /* Settings becomes an icon */
  .lib-actions > .btn.ghost {
    font-size: 0;
    gap: 0;
    width: 34px;
    padding: 0;
    justify-content: center;
  }
  .account-chip {
    padding: 0 10px;
  }
  .account-chip > .icon,
  .lang-switch > .icon {
    display: none;
  }
  .hero p {
    font-size: 15px;
  }
  .upload-submit input,
  .upload-submit .btn {
    flex: 1 1 100%;
    justify-content: center;
  }
  .packs {
    grid-template-columns: repeat(2, 1fr);
  }
  .dialog-body {
    padding: 20px 18px;
  }
  .dialog-actions {
    bottom: -20px;
    margin: 4px -18px -20px;
    padding: 12px 18px;
  }
  /* Study screen: buttons with words become icons, and "fit width" gives way (pinch zooms). */
  .topbar .btn.small {
    font-size: 0;
    gap: 0;
    width: 34px;
    padding: 0;
    justify-content: center;
  }
  .zoom .icon-btn:nth-child(2) {
    display: none;
  }
  .top-status .muted {
    display: none;
  }
  .composer-bar > .pad-btn {
    font-size: 0;
    gap: 0;
    width: 34px;
    height: 30px;
    padding: 0;
    justify-content: center;
  }
  .pad-backdrop {
    padding: 8px;
  }
  .pad-head > .muted {
    display: none;
  }
  .pad-foot {
    flex-wrap: wrap;
    gap: 6px;
  }
  .pad-foot > .btn.ghost {
    display: none; /* the X above closes it */
  }
  .pad-foot > .btn.primary {
    padding-inline: 12px;
  }
  .account-email {
    flex: 1 1 0;
    flex-wrap: wrap;
    gap: 2px 8px;
  }
  .account-email > strong {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .account-email > .muted {
    flex: 1 1 100%;
  }
  .action {
    padding: 8px 7px;
    gap: 4px;
    font-size: 12.5px;
  }
  .pack {
    padding: 10px;
  }
  .pack > span:not(.tag) {
    font-size: 12px;
  }
  .pad-head,
  .pad-foot {
    padding: 8px 10px;
  }
}

/* Phones zoom the whole page when a field's text is smaller than 16px; this keeps it still. */
@media (pointer: coarse) and (max-width: 860px) {
  input:not([type="checkbox"], [type="radio"]),
  textarea,
  select {
    font-size: 16px !important;
  }
}


/* ---------- chat without a document ---------- */


/* (the frame, the left panel and the tabs are styled at the end of this file) */

/* ---------- a chat with no document: the left side folded to a strip that takes a PDF ---------- */

.study.no-doc .top-tools,
.study.no-doc .mode-pick,
.study.no-doc .key-btn,
.study.no-doc .top-back,
.study.no-doc .zoom,
.study.no-doc .resizer {
  display: none;
}
.study.no-doc .pane {
  flex: none;
  width: 84px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.study.no-doc .side {
  flex: 1;
  width: auto !important;
  max-width: none;
  height: auto;
  max-height: none;
}
.study.no-doc .dock.full {
  width: min(860px, 100%);
  margin-inline: auto;
  border-inline: 1px solid var(--line);
}
.doc-rail {
  height: 100%;
  padding: 10px 8px;
}
.rail-btn {
  appearance: none;
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 14px 4px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.rail-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.rail-btn:disabled {
  cursor: progress;
  opacity: 0.7;
}
.rail-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.rail-btn.busy .rail-icon {
  animation: pulse 1.2s ease-in-out infinite;
}
.rail-hint {
  display: none;
}
@media (max-width: 860px) {
  /* Stacked: the strip lies across the top; a PDF opens the document above the chat. */
  .study.no-doc .pane {
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .study.no-doc .dock.full {
    border-inline: 0;
  }
  .doc-rail {
    height: auto;
    padding: 8px 10px;
  }
  .rail-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 6px 10px;
    text-align: left;
  }
  .rail-icon {
    width: 30px;
    height: 30px;
    flex: none;
  }
  .rail-label {
    flex: none;
  }
  .rail-hint {
    display: block;
    min-width: 0;
    font-weight: 500;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
@media (max-width: 560px) {
  /* Home page on a phone: the name gives way so the menu, mark and account fit on one row. */
  .lib-nav .brand:has(.side-toggle) > span:not(.brand-mark) {
    display: none;
  }
}

/* ---------- pen colour and size ---------- */

.pen-style {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.pen-color {
  appearance: none;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}
.pen-color.active {
  box-shadow: 0 0 0 2px var(--accent);
}
.pen-size {
  appearance: none;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.pen-size.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.pen-size i {
  display: block;
  border-radius: 50%;
}
.pen-sep {
  width: 1px;
  height: 18px;
  margin: 0 3px;
  background: var(--line-strong);
}
.notes-pen {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
}
.notes-pen[hidden] {
  display: none;
}
.pad-foot .pen-style {
  margin-left: 6px;
}

/* ---------- notes in a chat without a document: beside the chat on wide screens ---------- */

@media (min-width: 861px) {
  .study.no-doc .side.notes-open {
    flex-direction: row;
  }
  .study.no-doc .side.notes-open > .dock {
    display: flex !important;
    flex: 1;
    min-width: 0;
    width: auto;
    margin: 0;
    border-inline: 0;
  }
  .study.no-doc .side.notes-open > .notes-panel {
    flex: 0 0 min(460px, 42%);
    border-left: 1px solid var(--line);
  }
}

/* ====================================================================================
   The frame: left panel (rail / open), fixed tabs, and the stage the screens slide on
   ==================================================================================== */

#app {
  --rail: 56px;
  --panel: 320px; /* (the open left panel; was 268 px) */
}
.shell-body {
  position: relative;
  height: 100%;
  margin-left: var(--rail);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.22s ease;
}
#app.side-open.side-push .shell-body {
  margin-left: var(--panel);
}
.shell-main {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.page {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: var(--bg);
}
.study {
  container: study / inline-size;
}

/* ---------- the tabs: one place on every screen ---------- */

.shell-tabs {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
}
.shell-menu {
  position: absolute;
  top: 12px;
  left: 8px;
  z-index: 30;
  display: none; /* phones only: the rail is always there on wider screens */
}
a.seg-btn {
  text-decoration: none;
}
.mode-tabs {
  box-shadow: 0 0 0 1px var(--line);
}
.tabs-space {
  flex: none;
  width: var(--tabs-w, 150px);
  height: 36px;
}
.page-top {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 56px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
}
.library {
  padding-top: 6px;
}
#app[data-view="plain"] .shell-tabs,
#app[data-view="plain"] .shell-side,
#app[data-view="plain"] .shell-backdrop {
  display: none;
}
#app[data-view="plain"] .shell-body {
  margin-left: 0;
}

/* ---------- the left panel ---------- */

.shell-side {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: var(--rail);
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transition: width 0.22s ease, transform 0.22s ease, box-shadow 0.22s ease;
}
#app.side-open .shell-side {
  width: var(--panel);
}
#app.side-open:not(.side-push) .shell-side {
  box-shadow: var(--shadow-lg);
}
.shell-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 59;
  background: rgb(10 10 20 / 0.3);
}
#app.side-open:not(.side-push) .shell-backdrop {
  display: block;
}
.panel-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  margin-bottom: 8px;
}
.side-switch {
  appearance: none;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.side-switch:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.side-switch:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.side-brand {
  flex: 1;
  min-width: 0;
  font-weight: 750;
  font-size: 15px;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* (the name is the way home, sidebar.js: a link that looks like the name) */
a.side-brand {
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
}
a.side-brand:hover {
  color: var(--accent);
}
a.side-brand:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.side-nav {
  flex: none;
  display: grid;
  gap: 2px;
}
.side-nav-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  text-decoration: none;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.side-nav-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.side-nav-item .icon {
  flex: none;
}
.side-list {
  flex: 1;
  min-height: 0;
  margin-top: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 1px;
}
.side-label {
  margin: 10px 10px 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.side-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 6px 0 10px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
}
.side-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.side-item > .icon {
  flex: none;
  color: var(--muted);
}
.side-item.current {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.side-item.current > .icon {
  color: var(--accent);
}
.side-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-item-more {
  flex: none;
  width: 28px;
  height: 28px;
  opacity: 0;
}
.side-item:hover .side-item-more,
.side-item:focus-within .side-item-more {
  opacity: 1;
}
@media (hover: none) {
  .side-item-more {
    opacity: 0.6; /* no hover on touch screens, so it is always there */
  }
}
.side-empty {
  padding: 8px 10px;
  margin: 0;
}
.side-foot {
  flex: none;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.side-account {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.side-account:hover,
.side-account[aria-expanded="true"] {
  background: var(--surface-2);
}
.side-account > .icon {
  flex: none;
  margin-right: 4px;
  color: var(--muted);
  transform: rotate(180deg);
}
.side-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 750;
  font-size: 14px;
}
.side-account:hover .side-avatar:not(.on) {
  background: var(--surface-3);
}
.side-avatar.on {
  background: var(--grad);
  color: #fff;
}
.side-account-text {
  flex: 1;
  min-width: 0;
  display: grid;
  line-height: 1.3;
}
.side-account-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-account-text strong {
  font-size: 13.5px;
  font-weight: 650;
}
.side-menu {
  position: absolute;
  left: 8px;
  bottom: 62px;
  z-index: 2;
  width: calc(var(--panel) - 16px);
  display: grid;
  gap: 1px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s ease-out;
}
.side-menu[hidden] {
  display: none;
}
.side-menu-who {
  display: grid;
  padding: 6px 10px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
  line-height: 1.35;
}
.side-menu-who > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-menu-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
}
.side-menu-item:hover {
  background: var(--surface-2);
}
.side-menu-item .icon {
  flex: none;
  color: var(--muted);
}
.side-menu-item.danger,
.side-menu-item.danger .icon {
  color: var(--bad);
}
.side-menu-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 6px 10px 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
}
.side-menu-link {
  font-size: 12.5px;
  color: var(--muted);
}

/* Folded to a rail: icons only. */
#app:not(.side-open) .side-brand,
#app:not(.side-open) .side-nav-label,
#app:not(.side-open) .side-list,
#app:not(.side-open) .side-account-text,
#app:not(.side-open) .side-account > .icon {
  display: none;
}
#app:not(.side-open) .side-nav {
  flex: 1;
  align-content: start;
}
#app.side-open .rail-only {
  display: none;
}

/* Phones: no rail. The panel slides in over the page from a button beside the tabs. */
@media (max-width: 860px) {
  .shell-body,
  #app.side-open.side-push .shell-body {
    margin-left: 0;
  }
  .shell-side {
    width: min(var(--panel), 86vw) !important;
    transform: translateX(-102%);
  }
  #app.side-open .shell-side {
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  #app.side-open .shell-backdrop {
    display: block;
  }
  .shell-menu {
    display: block;
  }
  .side-menu {
    width: calc(min(var(--panel), 86vw) - 16px);
  }
  /* (never the rail on a phone: an open panel shows everything) */
  #app:not(.side-open) .side-brand,
  #app:not(.side-open) .side-nav-label,
  #app:not(.side-open) .side-account-text {
    display: revert;
  }
}
@media (max-width: 560px) {
  .shell-tabs .mode-tabs .seg-btn {
    padding: 6px 9px;
  }
  .shell-tabs .mode-tabs .seg-btn .icon {
    display: none;
  }
  .page-top {
    height: 52px;
  }
}

/* ---------- search ---------- */

.search-dialog {
  width: min(620px, calc(100vw - 24px));
  margin-top: min(14vh, 120px);
  padding: 0;
  overflow: hidden;
}
.search-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.search-input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  font-size: 16px !important;
}
.search-results {
  max-height: min(56vh, 460px);
  overflow-y: auto;
  padding: 6px;
  display: grid;
  gap: 1px;
}
.search-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
}
.search-item > .icon {
  flex: none;
  margin-top: 3px;
  color: var(--muted);
}
.search-item:hover,
.search-item.active {
  background: var(--surface-2);
}
.search-item-text {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.search-item-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-item-text strong {
  font-size: 14px;
  font-weight: 600;
}
.search-item mark {
  background: rgb(255 208 60 / 0.5);
  color: inherit;
  border-radius: 3px;
}
.search-empty {
  padding: 18px 12px;
  margin: 0;
  text-align: center;
}

/* ---------- home: recent documents ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 40px 0 14px;
}
.section-head[hidden] {
  display: none;
}
.section-head .section-title {
  margin: 0;
}

/* ====================================================================================
   The study screen's bar, built around the tabs in the middle of the top
   ==================================================================================== */

/* Wide: one row. Both sides get the same width, so the gap for the tabs is dead centre. */
.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px 12px;
}
.top-left,
.top-right,
.top-id {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.top-id {
  flex: 0 1 auto;
}
.top-left > .top-tools {
  margin-left: 4px;
}
.top-right {
  justify-content: flex-end;
}
.top-balance {
  display: none;
}

/* Less room: the tabs keep the middle of the first row with the title beside them, and
   the tools and buttons take a second row. */
@container study (max-width: 820px) {
  .topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 10px;
  }
  .top-left {
    display: contents;
  }
  .top-id,
  .top-balance {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    order: 0;
  }
  .tabs-space {
    order: 0;
  }
  .topbar::after {
    content: "";
    order: 1;
    flex-basis: 100%;
    height: 0;
    margin-top: -6px; /* the break itself takes no room */
  }
  .top-tools,
  .top-right {
    order: 2;
  }
  .top-left > .top-tools {
    margin-left: 0;
  }
  .top-right {
    flex: 1 1 auto;
  }
  .tool-label {
    display: none;
  }
  .tool {
    padding: 8px 10px;
  }
  /* A chat has no tools: its one button (notes) takes the right of the first row. */
  .study.no-doc .topbar::after,
  .study.no-doc .top-balance {
    display: none;
  }
  .study.no-doc .top-right {
    flex: 1 1 0;
    order: 0;
  }
}

/* Phones: the tabs have the first row to themselves, the title the second, tools the third. */
@container study (max-width: 640px) {
  .tabs-space {
    flex: 1 1 100%;
    order: -1;
  }
  .top-balance {
    display: none;
  }
  .top-id {
    flex: 1 1 100%;
  }
  .top-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  .top-title {
    flex: 0 1 auto;
    min-width: 0;
  }
  .top-status {
    flex: none;
  }
  .topbar::after {
    display: none;
  }
  .study.no-doc .top-id {
    flex: 1 1 0;
  }
  .study.no-doc .top-right {
    flex: none;
  }
}

/* Where the panel's button shows (no rail), the first row of the bar leaves it room. */
@media (max-width: 860px) {
  .top-id {
    padding-left: 38px;
  }
  .top-balance {
    padding-right: 38px; /* the same on the other side, so the gap for the tabs stays in the middle */
  }
}
@container study (max-width: 640px) {
  .top-id {
    padding-left: 0; /* on phones the button shares the tabs' row, above the title */
  }
}

/* ---------- fixes from the screen audit ---------- */

/* The account dialog: a long name keeps to one line, with the e-mail address under it. */
.account-email {
  flex: 1 1 0;
  flex-wrap: wrap;
  gap: 2px 8px;
}
.account-email > strong {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-email > .muted {
  flex: 1 1 100%;
}
/* The smallest phones: the bar over a selection drops its icons so all four words fit. */
@media (max-width: 360px) {
  .action {
    padding: 8px 6px;
    gap: 0;
  }
  .action .icon {
    display: none;
  }
}

/* ---------- files attached to chat messages ---------- */

.attach-btn {
  flex: none;
  width: 34px;
  height: 30px;
  padding: 0;
  justify-content: center;
}
.chat-files,
.msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 30px;
  padding: 3px 6px 3px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
}
.file-chip > .icon {
  flex: none;
  color: var(--accent);
}
.file-chip-name {
  min-width: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-chip .muted {
  flex: none;
  white-space: nowrap;
}
.file-chip .icon-btn {
  flex: none;
  width: 22px;
  height: 22px;
}
.file-chip.busy {
  border-style: dashed;
}
.msg.user .file-chip {
  padding-right: 9px;
  border-color: transparent;
  background: rgb(255 255 255 / 0.14);
  color: inherit;
}
.msg.user .file-chip > .icon {
  color: inherit;
}

/* ---------- a chat with nothing in it yet starts in the middle of the screen ---------- */

.study.no-doc .dock.is-empty {
  justify-content: center;
  border-inline-color: transparent;
  background: transparent;
}
.study.no-doc .dock.is-empty > .dock-head {
  display: none;
}
.study.no-doc .dock.is-empty > .chat-list {
  flex: 0 0 auto;
  overflow: visible;
  padding-bottom: 4px;
}
.study.no-doc .dock.is-empty .chat-empty {
  margin: 0;
  padding: 0 12px 10px;
}
.study.no-doc .dock.is-empty .chat-empty strong {
  font-size: clamp(22px, 3.2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.study.no-doc .dock.is-empty > .chat-compose {
  width: min(720px, 100%);
  margin: 0 auto;
  padding-bottom: 12vh; /* a little above the exact middle, where the eye rests */
}
.study.no-doc .dock.is-empty .composer {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}
.study.no-doc .side {
  background: var(--bg);
}

/* the phone's panel button: the same one as at the top of the panel */
.shell-menu {
  top: 8px;
  left: 6px;
}

/* ---------- dragging files onto the study screen: each area shows what a drop there does ---------- */

.dock {
  position: relative;
}
.drop-zone {
  position: absolute;
  inset: 8px;
  z-index: 20;
  display: none;
  place-items: center;
  border: 2px dashed var(--line-strong);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(2px);
  pointer-events: none; /* the drop lands on the chat underneath */
}
.study.dropping .drop-zone {
  display: grid;
}
.study.drop-chat .drop-zone {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 90%, transparent);
}
.drop-zone-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 16px;
  text-align: center;
  color: var(--muted);
}
.study.drop-chat .drop-zone-card {
  color: var(--accent-text);
}
.drop-zone-card strong {
  color: var(--ink);
  font-size: 16px;
}
.drop-zone-card span {
  font-size: 13px;
  color: var(--muted);
}
/* A chat's folded document side widens into a target of its own while a file is held. */
.rail-drop {
  display: none;
}
.study.no-doc .pane {
  transition: width 0.15s ease;
}
.study.no-doc.dropping .pane {
  width: 232px;
}
.study.no-doc.dropping .doc-rail,
.study.no-doc.dropping .rail-btn {
  height: 100%;
}
.study.no-doc.dropping .rail-btn {
  align-content: center;
}
.study.no-doc.dropping .rail-label,
.study.no-doc.dropping .rail-hint {
  display: none;
}
.study.no-doc.dropping .rail-drop {
  display: block;
  font-size: 13.5px;
}
.study.no-doc.drop-doc .rail-btn {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
@media (max-width: 860px) {
  .study.no-doc.dropping .pane {
    width: auto;
  }
  .study.no-doc.dropping .doc-rail,
  .study.no-doc.dropping .rail-btn {
    height: auto;
  }
}

.side {
  position: relative;
}
.drop-zone {
  overflow: hidden;
}
.study.dropping .side > .drop-zone {
  display: grid !important; /* also while notes are open beside the chat */
}

/* ---------- the chat's export menu ---------- */

.chat-menu-wrap {
  position: relative;
  display: flex;
}
.chat-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  display: grid;
  gap: 1px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s ease-out;
  cursor: default;
}
.chat-menu[hidden] {
  display: none;
}
.chat-menu-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.chat-menu-item:hover {
  background: var(--surface-2);
}
.chat-menu-item .icon {
  flex: none;
  color: var(--muted);
}
.chat-menu-item.danger,
.chat-menu-item.danger .icon {
  color: var(--bad);
}
.chat-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--line);
}

/* Printing from the export menu: only the conversation, on plain paper. */
@media print {
  body.print-chat #toasts,
  body.print-chat dialog,
  body.print-chat .shell-side,
  body.print-chat .shell-backdrop,
  body.print-chat .shell-tabs,
  body.print-chat .shell-menu,
  body.print-chat .topbar,
  body.print-chat .pane,
  body.print-chat .resizer,
  body.print-chat .side-head,
  body.print-chat .problems,
  body.print-chat .notes-panel,
  body.print-chat .dock-head,
  body.print-chat .chat-compose,
  body.print-chat .drop-zone {
    display: none !important;
  }
  body.print-chat,
  body.print-chat #app,
  body.print-chat .shell-body,
  body.print-chat .shell-main,
  body.print-chat .page,
  body.print-chat .study,
  body.print-chat .workspace,
  body.print-chat .side,
  body.print-chat .dock,
  body.print-chat .chat-list {
    display: block !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    border: 0 !important;
    box-shadow: none !important;
  }
  html:has(body.print-chat) {
    height: auto;
  }
  body.print-chat .chat-list {
    padding: 0 !important;
  }
  body.print-chat .msg {
    max-width: 100%;
    margin: 0 0 14px;
    break-inside: avoid;
  }
  body.print-chat .msg.user {
    margin-left: 20%;
  }
}

/* ---------- the paper under fingers ---------- */

/* One finger scrolls; two fingers are the app's own pinch zoom (viewer.js), not the browser's. */
.pdf-container {
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
}

/* ====================================================================================
   Smoothness: nothing that makes the page lay itself out again on every frame
   ==================================================================================== */

/* The bar over the document has nothing behind it to blur; a blur there only costs time. */
.topbar {
  background: var(--surface);
  backdrop-filter: none;
}
.drop-zone {
  backdrop-filter: none;
}
/* Phones and tablets: no live blur under the strip that the home page scrolls beneath. */
@media (pointer: coarse) {
  .page-top {
    background: var(--bg);
    backdrop-filter: none;
  }
}
/* Opening the panel beside a document slides it aside as on the home page. The pages fit
   the new width once, when the slide has ended (viewer.js waits for the size to settle);
   meanwhile they are not scrolled sideways (main.js toggleSidebar: side-moving). */
#app.side-moving .pdf-container {
  overflow-x: hidden;
}
/* Fingers: taps act at once (no wait for a double tap), no grey flash, and a list that
   reaches its end does not drag the page behind it along. */
a,
button,
input,
select,
textarea,
label,
.seg-btn,
.side-item,
.file-chip {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pdf-container {
  touch-action: pan-x pan-y; /* (two fingers are the app's own pinch) */
}
.chat-list,
.page,
.side-list,
.problems,
.notes-list,
.search-results,
.app-dialog {
  overscroll-behavior: contain;
}

/* ---------- motion: short, and only things the graphics chip can move by itself ---------- */

.btn,
.icon-btn,
.send-btn,
.seg-btn,
.side-nav-item,
.side-item,
.side-switch,
.rail-btn,
.pack {
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.08s ease, box-shadow 0.14s ease;
}
.btn:active:not(:disabled),
.send-btn:active:not(:disabled),
.side-nav-item:active,
.rail-btn:active:not(:disabled),
.pack:active:not(:disabled) {
  transform: scale(0.97);
}
.icon-btn:active:not(:disabled),
.side-switch:active {
  transform: scale(0.9);
}
/* New messages rise into place. */
.msg.fresh {
  animation: msg-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
/* The panel's contents fade in as it opens. */
#app.side-open .side-brand,
#app.side-open .side-nav-label,
#app.side-open .side-list,
#app.side-open .side-account-text {
  animation: side-in 0.22s ease both;
}
@keyframes side-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
}
.drop-zone {
  animation: page-fade-in 0.12s ease both;
}
.chat-files .file-chip,
.attachments .chat-image {
  animation: msg-in 0.16s ease both;
}
@keyframes page-fade-in {
  from {
    opacity: 0;
  }
}

/* ---------- fixes from the last audit ---------- */

/* Phones and tablets: the panel's own button replaces the one beside the tabs while it is open. */
#app.side-open .shell-menu {
  visibility: hidden;
}
/* A chat's first row: the same room on both sides of the tabs, so the title never runs under them. */
@media (max-width: 860px) {
  .study.no-doc .top-right {
    padding-left: 38px;
  }
}
@container study (max-width: 640px) {
  .study.no-doc .top-right {
    padding-left: 0;
  }
}

/* A phone held sideways: little height, enough width. The document and the panel sit side
   by side (stacked, each would be a sliver), and the bar gives up what it can. */
@media (max-height: 520px) and (min-width: 600px) and (max-width: 960px) {
  .topbar {
    min-height: 0;
    padding: 3px 8px;
    gap: 3px 6px;
  }
  .top-status {
    display: none;
  }
  .shell-tabs {
    top: 4px;
  }
  .shell-menu {
    top: 2px;
  }
  .study:not(.no-doc) .workspace {
    flex-direction: row;
  }
  .study:not(.no-doc) .resizer {
    display: none;
  }
  .study:not(.no-doc) .side {
    width: 50% !important;
    height: auto;
    min-height: 0;
    max-height: none;
  }
  .dock.open {
    height: 62%;
    min-height: 0;
  }
  .doc-rail {
    padding: 4px 10px;
  }
  .page-top {
    height: 46px;
  }
}

/* ====================================================================================
   Touch screens
   ==================================================================================== */

/* On the paper the phone's own selection (handles, Copy / Search menu) is off while
   fingers are in use: tools.js selects by press-and-hold instead. */
.pdf-container.touch-input .textLayer,
.pdf-container.touch-input .textLayer * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.pdf-container.touch-input .page {
  -webkit-touch-callout: none;
}
.pdf-container.touch-selecting .pick-strip {
  background: rgb(90 90 240 / 0.3);
}

/* The chat box's top line is a handle for fingers. */
@media (max-width: 860px) {
  .dock-head {
    position: relative;
    touch-action: none; /* a drag on it moves the box, not the page */
    padding-top: 12px;
  }
  .dock-head::before {
    content: "";
    position: absolute;
    top: 5px;
    left: 50%;
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--line-strong);
    transform: translateX(-50%);
  }
  .study:not(.no-doc) .side {
    min-height: 172px;
  }
  .side.settling {
    transition: height 0.24s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  /* (the bar between document and panel is the same handle: one is enough) */
  .study:not(.no-doc) .side.chat-only ~ .resizer,
  .study:not(.no-doc) .resizer:has(+ .side.chat-only) {
    height: 6px;
  }
  .study:not(.no-doc) .resizer:has(+ .side.chat-only)::after {
    display: none;
  }
  .study.no-doc .dock-head::before {
    display: none; /* a chat without a document has nothing above it to uncover */
  }
  .study.no-doc .dock-head {
    padding-top: 6px;
    touch-action: auto;
  }
}

/* Small phones (320 to 380 px wide): the row of tools is tightened so the zoom buttons
   stay on screen. */
@media (max-width: 400px) {
  .topbar {
    padding-inline: 6px;
    column-gap: 4px;
  }
  .top-right {
    gap: 4px;
  }
  .tool {
    padding: 7px 7px;
  }
  .mode-pick .seg-btn {
    padding: 5px 7px;
  }
  .topbar .btn.small {
    width: 30px;
  }
  .zoom .icon-btn {
    width: 26px;
    height: 28px;
  }
}

/* ---------- copy and export under each answer ---------- */

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
}
.msg-meta:empty,
.msg.user .msg-meta {
  display: none;
}
.msg-model:empty {
  display: none;
}
.msg-actions {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
}
.msg-actions[hidden] {
  display: none;
}
.msg-act {
  width: 28px;
  height: 28px;
  color: var(--muted);
}
.msg-act:hover {
  color: var(--ink);
}
.msg-act.ok {
  color: var(--good);
}
/* With a mouse they show when the answer is pointed at; on touch screens they are always there. */
@media (hover: hover) {
  .msg.assistant .msg-actions {
    opacity: 0;
    transition: opacity 0.12s ease;
  }
  .msg.assistant:hover .msg-actions,
  .msg.assistant:focus-within .msg-actions,
  .msg.assistant:last-child .msg-actions {
    opacity: 1;
  }
}
.pop-menu {
  z-index: 80;
}
/* An icon-only action at the end of the bar over a selection. */
.action.action-icon {
  flex: none;
  padding-inline: 9px;
}
@media (max-width: 360px) {
  .action.action-icon .icon {
    display: block;
  }
}
/* Printing one answer: only it and its question. */
@media print {
  body.print-one .msg:not(.print-target),
  body.print-one .msg-actions,
  body.print-one .chat-empty {
    display: none !important;
  }
  body.print-chat .msg-actions {
    display: none !important;
  }
}

/* ====================================================================================
   이동: with the move tool on, the pointer only moves the paper
   ==================================================================================== */

.pane.pan-tool .pdf-container,
.pane.pan-tool .pdf-container * {
  cursor: grab !important;
}
.pane.pan-tool .pdf-container.panning,
.pane.pan-tool .pdf-container.panning * {
  cursor: grabbing !important;
}
.pane.pan-tool .textLayer,
.pane.pan-tool .textLayer * {
  -webkit-user-select: none;
  user-select: none;
}

/* ====================================================================================
   Pen sizes: the dots show in the pen's colour, and black ink stays visible on dark
   ==================================================================================== */

.pen-size i {
  background: var(--dot, var(--ink));
}
@media (prefers-color-scheme: dark) {
  .pen-size i.is-ink {
    background: var(--ink);
  }
  .pen-size:not(.active) i {
    box-shadow: 0 0 0 1px rgb(255 255 255 / 0.18);
  }
  .pen-color.is-ink {
    box-shadow: 0 0 0 1px var(--muted);
  }
  .pen-color.is-ink.active {
    box-shadow: 0 0 0 2px var(--accent);
  }
}

/* ====================================================================================
   Phones held upright (600 px wide or less). A document's screen becomes a chat about
   the PDF, with the document a tap away at the top; the two take turns on the screen.
   Tablets and wider screens keep the side-by-side layout above.
   ==================================================================================== */

.phone-pick {
  display: none;
}

/* (phones and tablets: html.touch-ui, set by js/device.js) */
/* The frame's tabs give way on the study screen: the left panel has 새 채팅 and 내 문서. */
html.touch-ui #app[data-view="study"] .shell-tabs {
  display: none;
}
html.touch-ui #app.side-open .side-nav a.rail-only {
  display: flex;
}

/* ---- the bar: [menu] title ... [문서 | AI 채팅], and the reading tools under it ---- */
html.touch-ui .study .topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
html.touch-ui .study .top-left,
html.touch-ui .study .top-right {
  display: contents;
}
html.touch-ui .study .tabs-space,
html.touch-ui .study .top-balance,
html.touch-ui .study .top-status,
html.touch-ui .study .top-back,
html.touch-ui .study .mode-pick,
html.touch-ui .study .key-btn,
html.touch-ui .study .notes-btn {
  display: none !important;
}
html.touch-ui .study .top-id {
  order: 0;
  flex: 1 1 0;
  min-width: 0;
  margin-left: 40px; /* beside the menu button */
  padding: 0;
}
html.touch-ui .study .top-info {
  display: block;
  min-width: 0;
}
html.touch-ui .study .top-title {
  font-size: 16px;
  font-weight: 750;
}
html.touch-ui .study .phone-pick {
  display: inline-flex;
  order: 0;
  flex: none;
  padding: 3px;
  border-radius: 12px;
}
html.touch-ui .study .phone-pick .seg-btn {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 9px;
}
html.touch-ui .study.no-doc .phone-pick {
  display: none;
}
/* Second row, the document only: the reading tools, then zoom. */
html.touch-ui .study .topbar::after {
  content: "";
  display: block;
  order: 1;
  flex-basis: 100%;
  height: 0;
  margin-top: -8px;
}
html.touch-ui .study .top-tools {
  order: 2;
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
html.touch-ui .study .top-tools::-webkit-scrollbar {
  display: none;
}
html.touch-ui .study .tool-row {
  width: max-content;
}
html.touch-ui .study .tool-label {
  display: inline;
}
html.touch-ui .study .tool {
  padding: 7px 9px;
  font-size: 12.5px;
  gap: 4px;
}
html.touch-ui .study .zoom {
  order: 3;
  flex: none;
}
html.touch-ui .study.phone-chat .top-tools,
html.touch-ui .study.phone-chat .zoom,
html.touch-ui .study.phone-chat .topbar::after,
html.touch-ui .study.no-doc .topbar::after {
  display: none;
}

/* ---- the document and the AI, one at a time, both kept laid out underneath ---- */
html.touch-ui .study:not(.no-doc) .workspace {
  position: relative;
  display: block;
}
html.touch-ui .study:not(.no-doc) .pane,
html.touch-ui .study:not(.no-doc) .side {
  position: absolute;
  inset: 0;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-width: none;
  max-height: none !important;
}
html.touch-ui .study:not(.no-doc) .resizer {
  display: none !important;
}
html.touch-ui .study.phone-chat:not(.no-doc) .side,
html.touch-ui .study.phone-doc:not(.no-doc) .pane {
  z-index: 2;
}
html.touch-ui .study.phone-chat:not(.no-doc) .pane,
html.touch-ui .study.phone-doc:not(.no-doc) .side {
  visibility: hidden;
  pointer-events: none;
}
/* (notes are left out on a phone) */
html.touch-ui .study .notes-panel {
  display: none !important;
}
html.touch-ui .study .side.notes-open > .dock {
  display: flex;
}
html.touch-ui .study:not(.no-doc) .dock.open {
  height: 58%;
  min-height: 0;
}

/* ---- the chat, in the manner of the big chat apps ---- */
html.touch-ui .dock-head::before {
  display: none;
}
html.touch-ui .dock-head {
  touch-action: auto;
  padding: 6px 8px 6px 16px;
}
html.touch-ui .dock,
html.touch-ui .dock.full {
  background: var(--bg);
  border-top: 0;
  box-shadow: none;
}
html.touch-ui .study.no-doc .dock.full {
  border-inline: 0;
}
html.touch-ui .dock.full .dock-head {
  min-height: 42px;
  background: var(--bg);
}
html.touch-ui .dock .chat-list,
html.touch-ui .dock.full .chat-list {
  padding: 18px 16px 10px;
  gap: 22px;
}
html.touch-ui .msg {
  max-width: 100%;
  font-size: 15.5px;
  line-height: 1.72;
}
html.touch-ui .msg.user {
  max-width: 86%;
  background: var(--surface-3);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 22px;
}
html.touch-ui .msg.assistant {
  width: 100%;
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0 2px;
  border-radius: 0;
}
html.touch-ui .msg-meta {
  margin-top: 6px;
}
html.touch-ui .dock .chat-compose,
html.touch-ui .study.no-doc .dock.is-empty > .chat-compose {
  padding: 6px 10px calc(10px + env(safe-area-inset-bottom));
}
html.touch-ui .study.no-doc .dock.is-empty > .chat-compose {
  padding-bottom: 14vh;
}
html.touch-ui .dock .composer,
html.touch-ui .study.no-doc .dock.is-empty .composer {
  padding: 6px 6px 6px 8px;
  border-radius: 26px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
html.touch-ui .dock .composer:focus-within {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong));
  box-shadow: none;
}
html.touch-ui .composer-input,
html.touch-ui .composer-input:focus {
  padding: 8px 10px 4px;
  font-size: 16px;
}
html.touch-ui .composer-bar {
  gap: 2px;
  margin-top: 2px;
}
html.touch-ui .composer-bar > .toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
}
html.touch-ui .composer-bar > .pad-btn {
  font-size: 0;
  gap: 0;
  width: 36px;
  height: 36px;
}
html.touch-ui .composer-pickers .dd {
  background: transparent;
  border-radius: 999px;
}
/* (how hard the model thinks stays in Settings: one picker fits a phone) */
html.touch-ui .composer-pickers > :nth-child(n + 2) {
  display: none;
}
html.touch-ui .composer-bar > .send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
html.touch-ui .chat-empty strong,
html.touch-ui .dock.full .chat-empty strong {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}
html.touch-ui .dock.full .chat-empty {
  padding: 24px 20px;
}
html.touch-ui .dock.full .chat-empty p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}
/* A chat without a document: the strip that takes a PDF is a slim row. */
html.touch-ui .study.no-doc .doc-rail {
  padding: 8px 10px 0;
}

/* ---- the left panel, as in the chat apps: a sheet from the left with large rows ---- */
html.touch-ui .shell-side {
  width: min(420px, 86vw) !important;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-right: 0;
  border-radius: 0 20px 20px 0;
}
html.touch-ui .shell-backdrop {
  background: rgb(0 0 0 / 0.45);
}
html.touch-ui .panel-head {
  height: 44px;
  margin-bottom: 6px;
}
html.touch-ui .side-brand {
  font-size: 17px;
}
/* (the name, a link home: as tall as the row, for a thumb) */
html.touch-ui a.side-brand {
  line-height: 44px;
}
html.touch-ui .side-nav-item {
  height: 46px;
  padding: 0 12px;
  gap: 12px;
  border-radius: 12px;
  font-size: 15px;
  color: var(--ink);
}
html.touch-ui .side-list {
  margin-top: 4px;
  gap: 2px;
}
html.touch-ui .side-label {
  margin: 18px 12px 6px;
  font-size: 12.5px;
}
html.touch-ui .side-item {
  min-height: 44px;
  padding: 0 4px 0 12px;
  border-radius: 12px;
  font-size: 15px;
}
html.touch-ui .side-item > .icon {
  display: none;
}
html.touch-ui .side-item-more {
  width: 36px;
  height: 36px;
}
html.touch-ui .side-foot {
  padding-top: 10px;
}
html.touch-ui .side-account {
  padding: 8px;
  border-radius: 12px;
}

/* ====================================================================================
   Touch screens and phones: how the chat box and the left panel behave
   ==================================================================================== */

/* No bin beside every saved chat where there is no hover: a row is pressed and held for
   its menu instead (sidebar.js). */
/* (phones and tablets: html.touch-ui, set by js/device.js) */
html.touch-ui .side-item-more {
  display: none;
}
html.touch-ui .side-item {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.side-fab,
.plus-btn {
  display: none;
}

/* (phones and tablets: html.touch-ui, set by js/device.js) */
/* 새 채팅 moves from the top of the panel to a button at its bottom right. */
html.touch-ui .side-nav > a[href="#/chat"] {
  display: none;
}
html.touch-ui .side-foot {
  display: flex;
  align-items: center;
  gap: 8px;
}
html.touch-ui .side-foot > .side-account {
  flex: 1;
  min-width: 0;
}
html.touch-ui .side-fab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 44px;
  padding: 0 16px 0 13px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
}
html.touch-ui .side-fab:active {
  transform: translateY(1px);
}

/* One "+" (camera, photos, files, handwriting) in place of the attach and pen buttons. */
html.touch-ui .composer-bar > .attach-btn,
html.touch-ui .composer-bar > .pad-btn {
  display: none;
}
html.touch-ui .composer-bar > .plus-btn {
  display: inline-flex;
}

/* ====================================================================================
   Pull down to refresh (pull.js): a round arrow that comes down from the top
   ==================================================================================== */

.pull-refresh {
  position: fixed;
  top: env(safe-area-inset-top, 0px);
  left: 50%;
  z-index: 95;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, -48px);
  pointer-events: none;
  will-change: transform;
}
.pull-refresh.settling {
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.pull-refresh.ready {
  color: var(--accent);
}
.pull-refresh.loading {
  color: var(--accent);
  opacity: 1;
  transition: transform 0.15s ease;
}
.pull-refresh.loading .icon {
  animation: pull-spin 0.8s linear infinite;
}
@keyframes pull-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ====================================================================================
   Phones: a new chat's message box waits at the bottom, as in the chat apps (not in the
   middle of the screen), with the greeting in the space above it
   ==================================================================================== */

/* (phones and tablets: html.touch-ui, set by js/device.js) */
html.touch-ui .study.no-doc .dock.is-empty {
  justify-content: flex-end;
}
html.touch-ui .study.no-doc .dock.is-empty > .chat-list {
  flex: 1 1 auto;
  display: flex;
  overflow: auto;
}
html.touch-ui .study.no-doc .dock.is-empty .chat-empty {
  margin: auto 0;
}
html.touch-ui .study.no-doc .dock.is-empty > .chat-compose {
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
}

/* Phones have no home page (main.js opens a new chat instead), so the panel's link to it goes. */
/* (phones and tablets: html.touch-ui, set by js/device.js) */
html.touch-ui #app .side-nav a[href="#/"] {
  display: none !important;
}
html.touch-ui #app .shell-tabs {
  display: none;
}
/* ====================================================================================
   Phones: no bar over a chat. The panel button floats in the top left corner, as in the
   ChatGPT app; the strip that takes a PDF sits beside it.
   ==================================================================================== */

/* (phones and tablets: html.touch-ui, set by js/device.js) */
html.touch-ui .study.no-doc .topbar {
  display: none;
}
html.touch-ui .shell-menu {
  top: 8px;
  left: 8px;
}
html.touch-ui .shell-menu .side-switch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  color: var(--ink);
}
html.touch-ui .study.no-doc .doc-rail {
  padding: 8px 10px 0 60px;
}
html.touch-ui .study.no-doc .rail-btn {
  min-height: 42px;
}
html.touch-ui .study .top-id {
  margin-left: 46px; /* beside the floating button, on a document's bar */
}
/* ====================================================================================
   Phones and tablets: the app is as tall as what can be seen, keyboard included
   (screen.js sets --app-h; Android also shrinks the page itself, see index.html)
   ==================================================================================== */

/* (phones and tablets: html.touch-ui, set by js/device.js) */
html.touch-ui,
html.touch-ui body {
  height: var(--app-h, 100%);
}

/* Phones: the PDF button is a compact pill at the top right of a chat, level with the
   floating panel button on the left; its long explanation goes (it never fitted). */
/* (phones and tablets: html.touch-ui, set by js/device.js) */
html.touch-ui .study.no-doc .pane {
  border-bottom: 0;
  background: var(--bg);
}
html.touch-ui .study.no-doc .doc-rail {
  display: flex;
  justify-content: flex-end;
  padding: 8px 8px 0 60px;
}
html.touch-ui .study.no-doc .rail-btn {
  width: auto;
  min-height: 42px;
  padding: 0 14px 0 6px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
  white-space: nowrap;
}
html.touch-ui .study.no-doc .rail-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: none;
}
html.touch-ui .study.no-doc .rail-hint {
  display: none;
}
/* ====================================================================================
   Phones: the "+" menu (camera, photos, files, handwriting) as a large rounded card with
   round icons, as in the ChatGPT app
   ==================================================================================== */

.pop-menu.plus-menu {
  right: auto;
  width: min(290px, calc(100vw - 16px));
  padding: 10px;
  gap: 4px;
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
}
.plus-menu .chat-menu-item {
  gap: 16px;
  min-height: 62px;
  padding: 0 8px;
  border-radius: 20px;
  font-size: 16.5px;
  font-weight: 600;
}
.plus-menu .chat-menu-item .icon {
  box-sizing: border-box;
  flex: none;
  width: 48px;
  height: 48px;
  padding: 13px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
}
.plus-menu .chat-menu-item:active {
  background: var(--surface-2);
}

/* ====================================================================================
   Phones: the model slider (modelsheet.js)
   ==================================================================================== */

.model-sheet {
  position: fixed;
  left: 10px;
  right: 10px;
  z-index: 80;
  display: grid;
  gap: 14px;
  padding: 16px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.14s ease-out;
  -webkit-user-select: none;
  user-select: none;
}
.ms-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.ms-title {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.ms-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-note {
  font-size: 13px;
  color: var(--muted);
}
.model-sheet.off .ms-name {
  color: var(--muted);
}
.ms-more {
  appearance: none;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.ms-more .icon {
  transform: rotate(-90deg);
}
.ms-track {
  position: relative;
  height: 56px;
  border-radius: 999px;
  background: var(--surface-3);
  box-shadow: inset 0 0 0 6px var(--surface-2);
  touch-action: none;
  cursor: pointer;
  overflow: hidden;
}
.ms-track:focus-visible {
  outline: none;
  box-shadow: var(--ring), inset 0 0 0 6px var(--surface-2);
}
.ms-fill {
  position: absolute;
  inset: 6px auto 6px 6px;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.12s ease;
}
.model-sheet.off .ms-fill {
  background: var(--muted);
}
.ms-dot {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.7;
}
.ms-dot.passed {
  background: #fff;
  opacity: 0.75;
}
.ms-dot.off:not(.passed) {
  opacity: 0.3;
}
.ms-knob {
  position: absolute;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  transition: left 0.12s ease;
}
.ms-ends {
  display: flex;
  justify-content: space-between;
  padding: 0 6px;
  font-size: 12px;
  color: var(--muted);
}

/* ====================================================================================
   Phones and tablets: the frame of the touch layout at every width. (Narrow computer
   windows keep the computer layout and its own narrow-screen rules above.)
   ==================================================================================== */

/* The left panel lies over the page and slides in from the floating button; no rail. */
html.touch-ui .shell-body,
html.touch-ui #app.side-open.side-push .shell-body {
  margin-left: 0;
}
html.touch-ui .shell-side {
  width: min(420px, 86vw) !important;
  transform: translateX(-102%);
}
html.touch-ui #app.side-open .shell-side {
  transform: none;
  box-shadow: var(--shadow-lg);
}
html.touch-ui #app.side-open .shell-backdrop {
  display: block;
}
html.touch-ui .shell-menu {
  display: block;
}
html.touch-ui .side-menu {
  width: calc(min(420px, 86vw) - 16px);
}
html.touch-ui #app:not(.side-open) .side-brand,
html.touch-ui #app:not(.side-open) .side-nav-label,
html.touch-ui #app:not(.side-open) .side-account-text {
  display: revert;
}
html.touch-ui #app:not(.side-open) .side-list {
  display: grid;
}

/* A chat without a document: the PDF button sits on a row above the chat, not in a column. */
html.touch-ui .study.no-doc .workspace {
  flex-direction: column;
}
html.touch-ui .study.no-doc .pane {
  flex: none;
  width: auto;
  border-right: 0;
}
html.touch-ui .doc-rail {
  height: auto;
}
html.touch-ui .study.no-doc .rail-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
html.touch-ui .study.no-doc .rail-icon {
  flex: none;
}
html.touch-ui .study.no-doc .dock.full {
  width: min(860px, 100%);
}

/* The narrowest phones (under 380 px): the reading tools show their icons only, so all
   four fit beside the zoom buttons. */
@media (max-width: 379px) {
  html.touch-ui .study .tool-label {
    display: none;
  }
  html.touch-ui .study .tool {
    padding: 8px 11px;
  }
}
/* ====================================================================================
   Phones and tablets: the "+" menu and the model slider grow upward out of their buttons
   (util.js riseFrom)
   ==================================================================================== */

.model-sheet,
html.touch-ui .pop-menu.plus-menu {
  right: auto;
  width: min(400px, calc(100vw - 24px));
}
.model-sheet {
  animation: plus-grow 0.16s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* The "+" card at the size of ChatGPT's: about 290 px wide on a phone (theirs, measured from
   a screenshot: ~291 px wide, rows ~66 px apart, 50 px round icons, 17 px labels). */
html.touch-ui .pop-menu.plus-menu {
  width: min(290px, calc(100vw - 24px));
  min-width: 0;
  padding: 12px;
  gap: 2px;
  border-radius: 28px;
}
html.touch-ui .plus-menu .chat-menu-item {
  gap: 14px;
  min-height: 64px;
  padding: 0 6px;
  font-size: 17px;
}
html.touch-ui .plus-menu .chat-menu-item .icon {
  width: 50px;
  height: 50px;
  padding: 14px;
}
/* The "+" card, smaller again, growing upward out of the "+" button (util.js popMenu rise). */
html.touch-ui .pop-menu.plus-menu {
  width: min(220px, calc(100vw - 24px));
  padding: 8px;
  gap: 0;
  border-radius: 22px;
  animation: plus-grow 0.16s cubic-bezier(0.2, 0.8, 0.2, 1);
}
html.touch-ui .plus-menu .chat-menu-item {
  gap: 12px;
  min-height: 50px;
  padding: 0 6px;
  border-radius: 14px;
  font-size: 15.5px;
}
html.touch-ui .plus-menu .chat-menu-item .icon {
  width: 38px;
  height: 38px;
  padding: 10px;
}
@keyframes plus-grow {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}
@media (prefers-reduced-motion: reduce) {
  html.touch-ui .pop-menu.plus-menu,
  .model-sheet {
    animation: none;
  }
}
/* Phones and tablets: no header line over a chat that fills the screen ("AI에게 묻기 · 검색 ·
   보고 있는 쪽과 함께 전달됩니다"). Kept where it has a job: in problem solving, where the
   chat sits under the questions and its button makes it full and small again. */
html.touch-ui .dock.full:has(> .dock-head .dock-full[hidden]) > .dock-head {
  display: none;
}
/* ====================================================================================
   Computers: the model and thinking-depth button under the message box and its menu,
   as in claude.ai (modelmenu.js)
   ==================================================================================== */

.mm-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 8px 6px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.mm-btn:hover,
.mm-btn[aria-expanded="true"] {
  background: var(--surface-2);
}
.mm-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.mm-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.mm-effort {
  color: var(--muted);
  font-weight: 500;
}
.mm-effort:empty {
  display: none;
}
.mm-btn > .icon {
  flex: none;
  color: var(--muted);
}
.mm-menu {
  position: fixed;
  z-index: 200;
  width: 300px;
  max-width: calc(100vw - 16px);
  overflow: auto;
  display: grid;
  gap: 1px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s ease-out;
}
.mm-sub {
  width: 280px;
}
.mm-item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mm-item:hover:not(:disabled),
.mm-item:focus-visible,
.mm-item.open {
  outline: none;
  background: var(--surface-2);
}
.mm-item.on:not(:hover):not(:focus-visible) {
  background: transparent;
}
.mm-item:disabled {
  cursor: default;
  opacity: 0.5;
}
.mm-text {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}
.mm-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mm-note {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.35;
}
.mm-meta {
  flex: none;
  font-size: 12.5px;
  color: var(--muted);
}
.mm-check {
  flex: none;
  width: 16px;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.mm-arrow {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.mm-arrow .icon {
  transform: rotate(-90deg);
}
.mm-sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--line);
}
.mm-group {
  padding: 8px 10px 3px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
}
/* Phones and tablets: no rule under the top bar, and no hint written in the empty message
   box (the box speaks for itself). */
html.touch-ui .study .topbar {
  border-bottom-color: transparent;
}
html.touch-ui .composer-input::placeholder {
  color: transparent;
}
/* Phones and tablets: the "+" and the send button mirror each other in the box: the same
   round 36 px button, the same distance from the box's left and right edges. */
html.touch-ui .dock .composer,
html.touch-ui .study.no-doc .dock.is-empty .composer {
  padding-left: 6px;
  padding-right: 6px;
}
html.touch-ui .composer-bar > .plus-btn {
  background: var(--surface-3);
  border-color: transparent;
  color: var(--ink);
}
/* A popup made shorter (above a phone's keyboard, tools.js keepInView): its head and the
   question row stay whole, the text between them scrolls. */
.popover > .pop-head,
.popover > .pop-foot {
  flex: none;
}
.popover > .pop-body {
  min-height: 0;
  flex: 0 1 auto;
}

/* An attached picture's remove button sits on its corner, half outside it: the row keeps
   room for it, or the scrolling list of attachments would cut it off. */
.attachments .chat-images {
  padding: 7px 7px 0 0;
}
/* ====================================================================================
   Phones and tablets: the ⋯ menu (export, clear, delete; exam.js moreButton) beside the
   zoom buttons on the 문서 view, at the end of the top row on the AI 채팅 view, and beside
   the PDF button of a chat without a document. Computers have these elsewhere.
   ==================================================================================== */

.more-btn {
  display: none;
}
html.touch-ui .study .more-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  order: 3; /* 문서: after the zoom buttons, on the row of tools */
}
html.touch-ui .study.phone-chat .more-btn {
  order: 0; /* AI 채팅: the end of the top row, after the switch */
}
html.touch-ui .study.no-doc .doc-rail {
  gap: 8px;
  align-items: center;
}
html.touch-ui .study.no-doc .doc-rail .more-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}/* (a picture of text, as captured from the document, reads from its start) */
.attachments .chat-image img {
  object-position: left center;
}
/* Phones and tablets: the ⋯ menu sits at the top right on both views (문서 and AI 채팅),
   after the switch. */
html.touch-ui .study .more-btn,
html.touch-ui .study.phone-chat .more-btn {
  order: 0;
}
/* Phones and tablets: answers in larger type, easier to read and to select with a finger. */
html.touch-ui .msg.assistant {
  font-size: 17px;
  line-height: 1.78;
}
html.touch-ui .msg.user {
  font-size: 16px;
}
/* Phones and tablets: the conversation is selected with our own selection, not the phone's
   (textselect.js): no phone menu, handles or magnifier on it. */
html.touch-ui .chat-list .msg {
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.sel-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.sel-mark {
  position: absolute;
  background: color-mix(in srgb, var(--accent) 34%, transparent);
}
/* The two round handles, as on the phones: a drop hanging under each end. */
.sel-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  background: var(--accent);
  pointer-events: auto;
  touch-action: none;
}
.sel-handle.start {
  translate: -100% 0;
  border-radius: 50% 0 50% 50%;
}
.sel-handle.end {
  border-radius: 0 50% 50% 50%;
}
/* (a larger area to catch the finger than the drop itself) */
.sel-handle::before {
  content: "";
  position: absolute;
  inset: -12px;
}
/* Above the selection, where the phone's own menu would be: 질문에 추가 · 복사. */
.sel-menu {
  position: fixed;
  z-index: 250;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  animation: pop-in 0.12s ease-out;
  -webkit-user-select: none;
  user-select: none;
}
.sel-menu[hidden] {
  display: none;
}
.sel-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.sel-menu-btn:active {
  background: var(--surface-3);
}
.sel-menu-btn + .sel-menu-btn {
  box-shadow: -1px 0 0 var(--line);
}

/* Phones and tablets: under 무엇이든 물어보세요, one short line on what can be done. */
html.touch-ui .chat-empty p {
  max-width: 320px;
  margin: 0 auto;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

/* Phones and tablets: the ⋯ menus (the one at the top right, and those under answers and in
   뜻 풀이) in larger type with taller rows, easy to press with a finger. */
html.touch-ui .pop-menu:not(.plus-menu) {
  min-width: 248px;
  padding: 8px;
  gap: 2px;
  border-radius: 20px;
}
html.touch-ui .pop-menu:not(.plus-menu) .chat-menu-item {
  gap: 14px;
  min-height: 52px;
  padding: 0 14px;
  border-radius: 13px;
  font-size: 16.5px;
}
html.touch-ui .pop-menu:not(.plus-menu) .chat-menu-item .icon {
  width: 20px;
  height: 20px;
}
html.touch-ui .pop-menu:not(.plus-menu) .chat-menu-item:active {
  background: var(--surface-2);
}
html.touch-ui .pop-menu:not(.plus-menu) .chat-menu-sep {
  margin: 6px 10px;
}

/* Wide tablets: the conversation and the message box keep to a centred column (at most
   760 px wide) instead of stretching across the screen; phones are narrower than that. */
html.touch-ui .dock .chat-compose,
html.touch-ui .study.no-doc .dock.is-empty > .chat-compose {
  padding-left: max(10px, calc((100% - 760px) / 2));
  padding-right: max(10px, calc((100% - 760px) / 2));
}
html.touch-ui .dock .chat-list,
html.touch-ui .dock.full .chat-list,
html.touch-ui .study.no-doc .dock.is-empty > .chat-list {
  padding-left: max(16px, calc((100% - 744px) / 2));
  padding-right: max(16px, calc((100% - 744px) / 2));
}
/* Phones and tablets: copy and ⋯ under an answer, large enough to press. */
html.touch-ui .msg-meta {
  min-height: 40px;
}
html.touch-ui .msg-actions {
  gap: 6px;
  margin-right: -8px;
}
html.touch-ui .msg-act {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}
html.touch-ui .msg-act .icon {
  width: 20px;
  height: 20px;
}
html.touch-ui .msg-act:active {
  background: var(--surface-2);
}

/* Phones and tablets: search sits at the top and ends above the keyboard (--app-h is the
   visible height, keyboard left out, see screen.js); the results scroll inside it. */
html.touch-ui .search-dialog {
  margin: max(12px, env(safe-area-inset-top)) auto auto;
  max-height: calc(var(--app-h, 100dvh) - 24px);
}
html.touch-ui .search-dialog[open] {
  display: flex;
  flex-direction: column;
}
html.touch-ui .search-top {
  flex: none;
}
html.touch-ui .search-results {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

/* After a capture: the picture, laid exactly over the spot it was taken from with the
   rest of the screen dimmed, and 복사 · 질문 beside it (tools.js showCapture). */
.capture-result {
  position: fixed;
  inset: 0;
  z-index: 60;
}
.capture-dim {
  position: absolute;
  inset: 0;
  background: rgb(10 10 20 / 0.45);
  animation: page-fade-in 0.12s ease-out;
}
.capture-shot {
  position: fixed;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--shadow-lg);
}
.capture-bar {
  position: fixed;
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  animation: pop-in 0.14s ease-out;
}
.capture-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 96px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.capture-btn:hover,
.capture-btn:active {
  background: var(--surface-2);
}
.capture-btn .icon {
  color: var(--accent-text);
}
html.touch-ui .capture-btn {
  min-width: 118px;
  min-height: 48px;
  font-size: 16px;
}
/* (while the picture is being made, the box stays and nothing else can be drawn) */
.capture-layer.busy {
  cursor: progress;
}

/* Tablets (and phones on their side; 700 px and wider): one row, so the document keeps the
   height, in three parts: the title on the left, the reading tools in the middle of the
   row, and zoom, the 문서 / AI 채팅 switch and ⋯ on the right (⋯ always last).
     문서:    [menu] title ......  ✧ ✎ ⌗ ✋  ......  − ⛶ +  [문서 | AI 채팅]  ⋯
     AI 채팅: [menu] title ..................................  [문서 | AI 채팅]  ⋯ */
@media (min-width: 700px) {
  html.touch-ui .study .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(max-content, 1fr);
    align-items: center;
    column-gap: 12px;
  }
  html.touch-ui .study .topbar::after {
    display: none;
  }
  html.touch-ui .study .top-id {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    max-width: none;
  }
  html.touch-ui .study .top-tools {
    grid-column: 2;
    grid-row: 1;
    min-width: max-content; /* (never cut off: the title gives way, ending in "…") */
  }
  html.touch-ui .study .top-right {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }
  html.touch-ui .study .zoom {
    order: 1;
  }
  html.touch-ui .study .phone-pick {
    order: 2;
  }
  html.touch-ui .study .more-btn,
  html.touch-ui .study.phone-chat .more-btn {
    order: 3;
  }
}
/* Narrower tablets: the tools show their icons only, so the whole row fits. */
@media (min-width: 700px) and (max-width: 999px) {
  html.touch-ui .study .tool-label {
    display: none;
  }
  html.touch-ui .study .tool {
    padding: 8px 11px;
  }
}

/* ⋯ menus of chats and documents (sessionmenu.js): a small pin marks pinned ones, which
   are listed first; on hover the ⋯ takes the pin's place. */
.side-item-pin {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 20px;
  color: var(--muted);
}
.side-item:hover .side-item-pin,
.side-item:focus-within .side-item-pin {
  display: none;
}
html.touch-ui .side-item-pin {
  width: 28px;
}
.exam-pin {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
}
.exam-more {
  color: var(--muted);
}
.exam-more:hover {
  color: var(--ink);
}
.prompt-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

/* A picture shown large (lightbox.js). */
img.zoomable {
  cursor: zoom-in;
}
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(8 8 14 / 0.92);
  color: #fff;
}
.lightbox::backdrop {
  background: transparent;
}
.lightbox[open] {
  animation: page-fade-in 0.14s ease-out;
}
.lightbox-stage {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  padding: 56px 16px 24px;
}
.lightbox-img {
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}
.lightbox.zoomed .lightbox-stage {
  overflow: auto;
  cursor: grab;
}
.lightbox.zoomed .lightbox-img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
.lightbox-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  z-index: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.14);
  color: #fff;
}
.lightbox-close:hover {
  background: rgb(255 255 255 / 0.24);
  color: #fff;
}

/* 공유: the link dialog (sessionmenu.js). */
.share-dialog {
  width: min(520px, calc(100vw - 32px));
}
.share-url {
  font-size: 14px;
  color: var(--ink-2);
}
.share-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.share-actions .spacer {
  flex: 1;
}
.btn.danger-text {
  color: var(--bad);
}

/* A shared conversation, read only (shared.js): one centred column, as in the chat. */
.shared-page {
  max-width: 820px;
}
.shared-head {
  margin: 8px 0 22px;
}
.shared-head h1 {
  margin: 0 0 6px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.02em;
}
.shared-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 48px;
}
.shared-list .msg {
  font-size: 15.5px;
}
.shared-list .msg.user {
  max-width: 86%;
}
.shared-list .msg-image {
  display: block;
  max-width: min(100%, 360px);
  margin-bottom: 8px;
}
.shared-loading {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shared-missing {
  margin: 48px 0;
  text-align: center;
}

/* A photo in the message box while it is still being made small enough to send. */
.chat-image.busy img {
  opacity: 0.6;
}
.chat-image-busy {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

/* The menu that opens from the account row at the bottom of the left panel (sidebar.js):
   taller rows and larger type, easy to press. Larger still on phones and tablets. */
.side-menu {
  gap: 2px;
  padding: 8px;
  border-radius: 18px;
}
.side-menu-who {
  padding: 8px 12px 10px;
  margin-bottom: 6px;
  font-size: 15px;
}
.side-menu-item {
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 11px;
  font-size: 15px;
}
.side-menu-item .icon {
  width: 18px;
  height: 18px;
}
.side-menu-links {
  gap: 4px 16px;
  padding: 8px 12px 4px;
  margin-top: 6px;
}
.side-menu-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 13.5px;
}
html.touch-ui .side-menu {
  bottom: calc(70px + env(safe-area-inset-bottom));
  padding: 10px;
  border-radius: 22px;
}
html.touch-ui .side-menu-who {
  font-size: 16px;
}
html.touch-ui .side-menu-item {
  gap: 14px;
  min-height: 54px;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 16.5px;
}
html.touch-ui .side-menu-item .icon {
  width: 21px;
  height: 21px;
}
html.touch-ui .side-menu-item:active {
  background: var(--surface-2);
}
html.touch-ui .side-menu-link {
  min-height: 40px;
  font-size: 14.5px;
}
/* (never taller than the screen above the account row: on a short screen it scrolls) */
.side-menu {
  max-height: calc(var(--app-h, 100dvh) - 90px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* 필기: writing on the pages (tools.js). The paper takes the pen, finger or mouse instead
   of selecting text; two fingers still pinch and slide it. Once a pen has been used,
   fingers scroll again (pen-only) and only the pen writes. */
.ink-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}
.pane.inking .pdf-container {
  touch-action: none;
  cursor: crosshair;
}
/* (with a pen, a finger moves the paper, by hand in tools.js watchInk, never by the
   browser, which would let the pen scroll it as well) */
.pane.inking .textLayer,
.pane.inking .textLayer * {
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
/* The pen palette, floating at the bottom of the paper while 필기 is on. */
.ink-bar {
  position: absolute;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.14s ease-out;
}
.ink-bar[hidden] {
  display: none;
}
.ink-bar .pen-style {
  flex-wrap: nowrap;
  gap: 6px;
}
.ink-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.ink-btn:hover {
  background: var(--surface-2);
}
.ink-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.ink-btn.ink-done {
  background: var(--accent);
  color: var(--accent-ink);
}
html.touch-ui .ink-bar {
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
html.touch-ui .ink-bar .pen-color {
  width: 30px;
  height: 30px;
}
html.touch-ui .ink-bar .pen-size {
  width: 34px;
  height: 34px;
}
html.touch-ui .ink-btn {
  width: 44px;
  height: 44px;
}
/* Phones and narrow tablets: the pen palette in two rows (pens, then 손가락 · 지우개 ·
   선택 · 되돌리기 · 끝내기), all in view. */
@media (max-width: 740px) {
  html.touch-ui .ink-bar {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
    width: max-content;
    border-radius: 24px;
    overflow: visible;
  }
  html.touch-ui .ink-bar > .pen-sep {
    display: none;
  }
  html.touch-ui .ink-bar > .pen-style {
    flex-basis: 100%;
    justify-content: center;
  }
}

/* Computers: the conversation in larger type, easier to read (phones and tablets already
   have it: 17 px answers, 16 px questions). */
html:not(.touch-ui) .msg.assistant {
  font-size: 17px;
  line-height: 1.75;
}
html:not(.touch-ui) .msg.user {
  font-size: 16px;
}
html:not(.touch-ui) .msg-quote {
  font-size: 14px;
}

/* Computers, side by side: the chat panel starts at 42% of the screen and can be dragged
   narrower, never wider, so the document always keeps the larger part. */
@media (min-width: 861px) {
  html:not(.touch-ui) .study:not(.no-doc) .side {
    max-width: 42%;
  }
  html:not(.touch-ui) .study:not(.no-doc) .side:not([style*="width"]) {
    width: 42%;
  }
}

/* Computers: the conversation blends into the page, as in the chat apps. A new chat is
   one colour from edge to edge (no column with borders on a different background), an
   answer sits on the page with no card around it, and a question is a soft bubble. */
html:not(.touch-ui) .study.no-doc .pane,
html:not(.touch-ui) .study.no-doc .side,
html:not(.touch-ui) .study.no-doc .dock,
html:not(.touch-ui) .study.no-doc .dock.full {
  background: var(--surface);
}
html:not(.touch-ui) .study.no-doc .dock.full {
  border-inline: 0;
  box-shadow: none;
}
html:not(.touch-ui) .study.no-doc .dock-head {
  background: var(--surface);
  border-bottom-color: transparent;
}
html:not(.touch-ui) .msg.assistant {
  align-self: stretch;
  max-width: 100%;
  padding: 0 2px;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
html:not(.touch-ui) .msg.user {
  max-width: 80%;
  padding: 10px 16px;
  background: var(--surface-3);
  color: var(--ink);
  border-radius: 20px;
}
html:not(.touch-ui) .chat-list {
  gap: 22px;
}
/* (files attached to a question, on the light bubble) */
html:not(.touch-ui) .msg.user .file-chip,
html.touch-ui .msg.user .file-chip {
  background: var(--surface);
  border-color: var(--line);
}
/* Computers: the chat page's column (conversation and message box) a little narrower. */
html:not(.touch-ui) .study.no-doc .dock.full {
  width: min(760px, 100%);
}
/* The conversation scrolls with the wheel, the trackpad or a finger, with no scroll bar
   showing beside it, as in the chat apps. */
.chat-list {
  scrollbar-width: none;
}
.chat-list::-webkit-scrollbar {
  display: none;
}

/* 뜻 풀이 (the explanation popup) on computers: its text the size of an answer in the chat
   (17 px, the same line spacing). Phones and tablets keep their own size. */
html:not(.touch-ui) .popover .pop-body.md {
  font-size: 17px;
  line-height: 1.75;
}
/* The card that shows a saved 뜻 풀이 when the pointer rests on it: on computers in the
   size of the chat's answers, like the 뜻 풀이 popup. */
html:not(.touch-ui) .note-tip {
  padding: 12px 16px;
  font-size: 17px;
  line-height: 1.7;
}

/* The colours in the menu of a highlighter mark (tap a mark to recolour it). */
.action-bar .mark-colors {
  align-self: center;
  padding: 0 8px 0 6px;
  border-right: 1px solid var(--line);
  margin-right: 2px;
}
.action-bar .mark-colors .swatch {
  width: 22px;
  height: 22px;
}
html.touch-ui .action-bar .mark-colors {
  gap: 8px;
}
html.touch-ui .action-bar .mark-colors .swatch {
  width: 28px;
  height: 28px;
}
/* The chat page needs no "AI 채팅" label over the conversation; only its ⋯ stays, at the
   right. */
html:not(.touch-ui) .study.no-doc .dock-title {
  display: none;
}
html:not(.touch-ui) .study.no-doc .dock-head {
  min-height: 0;
  padding-block: 6px;
}
/* The selection menu's buttons light up under the pointer (computers). */
.sel-menu-btn {
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.sel-menu-btn .icon {
  transition: color 0.12s ease;
}
.sel-menu-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.sel-menu-btn:hover .icon {
  color: var(--accent-text);
}
.sel-menu-btn:active {
  background: var(--surface-3);
}

/* Selected words waiting in the message box: small cards side by side (chat.js). */
.attachments .chat-quotes {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 8px 2px 0; /* (room for each card's corner X) */
  scrollbar-width: none;
}
.attachments .chat-quotes::-webkit-scrollbar {
  display: none;
}
.quote-card {
  position: relative;
  flex: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  width: 168px;
  height: 108px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  animation: msg-in 0.16s ease both;
}
.quote-card-text {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  word-break: break-word;
}
.quote-card-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.quote-card-label .icon {
  color: var(--accent-text);
}
.quote-card > .icon-btn {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
}
@media (hover: hover) {
  .quote-card > .icon-btn {
    opacity: 0;
    transition: opacity 0.12s ease;
  }
  .quote-card:hover > .icon-btn,
  .quote-card:focus-within > .icon-btn {
    opacity: 1;
  }
}
html.touch-ui .quote-card {
  width: 156px;
  height: 104px;
}
/* A selected-text card under the pointer: an accent edge and a lighter fill (computers). */
.quote-card {
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
@media (hover: hover) {
  .quote-card:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    background: var(--accent-soft);
    box-shadow: var(--shadow-sm);
  }
  .quote-card:hover .quote-card-text {
    color: var(--ink);
  }
}

/* What waits above the message box: one row of tiles in the order they were added
   (chat.js renderAttachments): pictures as thumbnails, selected words as cards, files as
   small cards; all the same height, each with an X on its corner. */
.attachments {
  display: block;
  max-height: none;
  overflow: visible;
  padding: 0 2px 4px;
}
.attach-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 8px 4px 0; /* (room for the corner X) */
  scrollbar-width: none;
}
.attach-row::-webkit-scrollbar {
  display: none;
}
.attach-tile {
  position: relative;
  flex: none;
  height: 108px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  animation: msg-in 0.16s ease both;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.attach-image {
  min-width: 72px;
  max-width: 180px;
  background: #fff;
}
.attach-image img {
  display: block;
  height: 100%;
  width: auto;
  max-width: 178px;
  min-width: 70px;
  object-fit: cover;
  border-radius: 13px;
  cursor: zoom-in;
}
.attach-image.busy img {
  opacity: 0.6;
}
.file-card {
  width: 168px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
}
.file-card-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.file-card-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-all;
}
.file-card-meta {
  margin-top: auto;
}
.attach-tile > .tile-x {
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
}
@media (hover: hover) {
  .attach-tile > .tile-x {
    opacity: 0;
    transition: opacity 0.12s ease;
  }
  .attach-tile:hover > .tile-x,
  .attach-tile:focus-within > .tile-x {
    opacity: 1;
  }
  .attach-tile:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    box-shadow: var(--shadow-sm);
  }
  .quote-card:hover,
  .file-card:hover {
    background: var(--accent-soft);
  }
}
html.touch-ui .attach-tile {
  height: 104px;
}
html.touch-ui .quote-card,
html.touch-ui .file-card {
  width: 156px;
}

/* PC: the home page (and the other pages that are not a document) is white like the chat,
   not the gray under it. Phones and tablets keep the gray, which their chat uses too. */
html:not(.touch-ui) .page:not(.study) {
  background: var(--surface);
}
html:not(.touch-ui) .page:not(.study) .page-top {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

/* What waits above the message box (selected-text cards, pictures, files) is not text to
   select: dragging over it selects nothing. */
.attachments,
.attachments * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* PC: a "+" at the left of the message box opens 카메라, 사진, 파일 (in place of the clip);
   손글씨 stays as its own button beside it. The menu is a compact list that rises from it. */
html:not(.touch-ui) .composer-bar > .attach-btn {
  display: none;
}
html:not(.touch-ui) .composer-bar > .plus-btn {
  display: inline-flex;
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}
html:not(.touch-ui) .pop-menu.plus-menu {
  width: 210px;
  padding: 6px;
  gap: 2px;
  border-radius: 16px;
}
html:not(.touch-ui) .plus-menu .chat-menu-item {
  gap: 12px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
}
html:not(.touch-ui) .plus-menu .chat-menu-item .icon {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 0;
  background: none;
}
html:not(.touch-ui) .plus-menu .chat-menu-item:hover {
  background: var(--surface-2);
}

/* PC 카메라: the webcam over everything, with a round shutter button under it (webcam.js). */
.webcam-stage {
  align-items: center;
  justify-content: center;
  padding: 64px 24px 120px;
}
.webcam-video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 14px;
  background: #000;
}
.webcam-shoot {
  position: absolute;
  bottom: 28px;
  left: 50%;
  width: 68px;
  height: 68px;
  translate: -50% 0;
  padding: 0;
  border: 4px solid #fff;
  border-radius: 50%;
  background: rgb(255 255 255 / 0.28);
  box-shadow: inset 0 0 0 4px rgb(8 8 14 / 0.6);
  cursor: pointer;
}
.webcam-shoot:hover {
  background: rgb(255 255 255 / 0.55);
}
.webcam-shoot:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* PC: the "+" (and 손글씨 beside it) light up under the mouse, and the "+" stays lit while
   its menu is open. */
@media (hover: hover) {
  html:not(.touch-ui) .composer-bar > .plus-btn:hover,
  html:not(.touch-ui) .composer-bar > .pad-btn:hover {
    background: var(--surface-3);
    color: var(--ink);
  }
}
html:not(.touch-ui) body:has(.plus-menu) .composer-bar > .plus-btn {
  background: var(--surface-3);
  color: var(--ink);
}
html:not(.touch-ui) .composer-bar > .plus-btn,
html:not(.touch-ui) .composer-bar > .pad-btn {
  transition: background-color 0.12s, color 0.12s;
}

/* PC: a document's top bar has no name in it (it is in the side panel and the browser tab):
   the reading tools show their words (뜻 풀이, 형광펜 ...) again, wherever they have the room.
   Only a state worth seeing stays where the name was: reading the document, or a failure
   with its 다시 시도. */
html:not(.touch-ui) .study:not(.no-doc) .top-info:not(:has(.tag.bad, .tag.live, button)) {
  display: none;
}
html:not(.touch-ui) .study:not(.no-doc) .top-title,
html:not(.touch-ui) .study:not(.no-doc) .top-status > .muted {
  display: none;
}
@container study (min-width: 960px) {
  html:not(.touch-ui) .study .tool-label {
    display: inline;
  }
  html:not(.touch-ui) .study .tool {
    padding: 7px 12px;
  }
}

/* 분석: the AI solved a question itself and is sure the answer key is wrong there (exam.js). */
.key-doubt {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.key-doubt strong {
  color: var(--warn);
  font-size: 13px;
}
.key-doubt p {
  margin: 4px 0 0;
}
.key-doubt p b {
  font-weight: 650;
}

/* Home page, 분석: which AI writes the explanations, chosen before uploading (library.js). */
.upload-model {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.upload-model[hidden] {
  display: none;
}
.upload-pickers {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* ====================================================================================
   Home page: the chat-like box the PDF goes in (library.js uploadCard). It is the chat's
   message box (.composer, the "+", the file tiles, the send button), a little roomier.
   ==================================================================================== */
.home-ask {
  margin: 4px 0 30px;
}
.home-box {
  padding: 10px 10px 8px;
  border-radius: 22px;
}
.home-box .composer-input {
  width: 100%;
  min-height: 64px;
  font-size: 16px;
}
.home-box.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--ring), var(--shadow);
}
.home-box .composer-bar {
  gap: 8px;
}
.home-box .home-mode .seg-btn {
  padding: 5px 11px;
  font-size: 13px;
}
.home-box .send-btn:disabled {
  opacity: 0.45;
}
.home-note {
  margin: 10px 8px 0;
  line-height: 1.6;
}

/* ====================================================================================
   Moving between the home page, a chat and 작업 on a computer (main.js route, and app.smoothly
   when a work's studio takes the place of 작업's start page): the screens fade into each other
   and the message box glides from its place on one to its place on the other, growing or
   shrinking on the way, as one box. (View Transitions; browsers without them just switch, as
   before.)
   ==================================================================================== */
html:not(.touch-ui) .home-box,
html:not(.touch-ui) .study.no-doc .composer,
html:not(.touch-ui) .work-home .work-bar-box {
  view-transition-name: ask-box;
}
::view-transition-group(ask-box) {
  animation-duration: 0.34s;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}
::view-transition-old(ask-box),
::view-transition-new(ask-box) {
  animation-duration: 0.24s; /* the box's two looks fade into each other as it moves */
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.22s;
  animation-timing-function: ease;
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* An empty chat's greeting ("무엇이든 물어보세요" and the line under it) is not text to select. */
.chat-empty,
.chat-empty * {
  -webkit-user-select: none;
  user-select: none;
}

/* ====================================================================================
   Computers, a chat (exam.js startChat): no name or lines at the top and no strip on the
   left; PDF 올리기 is a button in the middle under the message box.
   ==================================================================================== */
html:not(.touch-ui) .study.no-doc .top-id {
  display: none;
}
html:not(.touch-ui) .study.no-doc .topbar {
  border-bottom-color: transparent;
}
html:not(.touch-ui) .study.no-doc .pane {
  display: none;
}
.pdf-under {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.pdf-under .rail-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 7px 16px 7px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: none;
}
.pdf-under .rail-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: none;
}
.pdf-under .rail-hint,
.pdf-under .rail-drop {
  display: none;
}
@media (hover: hover) {
  .pdf-under .rail-btn:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    background: var(--accent-soft);
    color: var(--accent-text);
  }
}
/* A PDF held over it: it says it opens the PDF as this chat's document. */
.study.no-doc.drop-doc .pdf-under .rail-btn {
  border-style: dashed;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.study.no-doc.drop-doc .pdf-under .rail-label {
  display: none;
}
.study.no-doc.drop-doc .pdf-under .rail-drop {
  display: inline;
}

/* ====================================================================================
   Computers, a document being read (the 채팅 tab): as on a phone, 문서 and AI 채팅 take
   turns on the screen, switched at the top right; both stay laid out underneath. The
   frame's 분석 tab turns the document into the side-by-side 분석 page, so the 읽기 / 분석
   switch is not needed on a computer any more.
   ==================================================================================== */
html:not(.touch-ui) .study .mode-pick {
  display: none !important;
}
html:not(.touch-ui) .study.pc-split .phone-pick {
  display: inline-flex;
  flex: none;
}
html:not(.touch-ui) .study.pc-split .workspace {
  position: relative;
  display: block;
}
html:not(.touch-ui) .study.pc-split .pane,
html:not(.touch-ui) .study.pc-split .side {
  position: absolute;
  inset: 0;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
}
html:not(.touch-ui) .study.pc-split .resizer {
  display: none !important;
}
html:not(.touch-ui) .study.pc-split.phone-chat .side,
html:not(.touch-ui) .study.pc-split.phone-doc .pane {
  z-index: 2;
}
html:not(.touch-ui) .study.pc-split.phone-chat .pane,
html:not(.touch-ui) .study.pc-split.phone-doc .side {
  visibility: hidden;
  pointer-events: none;
}
/* the AI's side, alone on the screen: the conversation keeps to the chat page's column */
html:not(.touch-ui) .study.pc-split .side {
  background: var(--surface);
}
html:not(.touch-ui) .study.pc-split .dock.full {
  width: min(760px, 100%);
  margin-inline: auto;
}
/* the reading tools and zoom belong to the document: hidden while the AI is showing */
html:not(.touch-ui) .study.pc-split.phone-chat .top-tools,
html:not(.touch-ui) .study.pc-split.phone-chat .zoom {
  visibility: hidden;
}

/* 분석 page: the API-key notice's place, kept empty where it is not needed (library.js). */
.banner.banner-space {
  visibility: hidden;
}

/* ====================================================================================
   공부 page (library.js): under the box, the exam PDF, its answer key and the AI, each in a
   slot of its own. A file slot is clicked or has a file dropped on it.
   ==================================================================================== */
.study-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.study-slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}
.file-slot {
  border-style: dashed;
  border-color: var(--line-strong);
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}
@media (hover: hover) {
  .file-slot:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--line-strong));
    background: var(--accent-soft);
  }
}
.file-slot.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.file-slot.has-file {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft);
}
.slot-icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent);
}
.has-file .slot-icon {
  background: var(--surface);
}
.slot-text {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.slot-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
}
.slot-value {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-slot:not(.has-file) .slot-value {
  font-weight: 500;
  color: var(--ink-2);
}
.slot-meta {
  font-size: 12px;
  color: var(--muted);
}
.slot-x {
  flex: none;
  margin-left: auto;
  width: 26px;
  height: 26px;
}
.slot-pickers {
  margin-left: -6px;
}
@media (max-width: 760px) {
  .study-slots {
    grid-template-columns: 1fr;
  }
}

/* Computers: a document's AI box has no rule under its heading and no line of explanation
   beside it ("보고 있는 쪽과 함께 전달됩니다"), as the chat page has none. */
html:not(.touch-ui) .dock .dock-head {
  border-bottom-color: transparent;
}
html:not(.touch-ui) .dock .dock-scope {
  display: none;
}

/* Computers, beside a document: a line on asking about the PDF straight from it (chat.js). */
.dock-tip {
  display: none;
}
html:not(.touch-ui) .dock:has(.dock-tip) > .dock-head {
  flex-wrap: wrap;
  row-gap: 2px;
}
/* (a line of its own under the heading, so it is never cut short in a narrow panel) */
html:not(.touch-ui) .dock .dock-tip {
  display: block;
  order: 10;
  flex-basis: 100%;
  min-width: 0;
  padding-left: 23px; /* under the heading's words, past its icon */
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}

/* 필기 palette: the finger switch, 손가락 이동 / 손가락 쓰기 (tools.js initInk). */
.ink-btn.ink-finger {
  display: inline-flex;
  gap: 5px;
  width: auto;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
}
.ink-btn.ink-finger:hover {
  background: var(--surface-3);
}

/* (touch screens: the finger switch is as wide as its words, not one of the round 44 px
   buttons, so its words do not spill over the 지우개 beside it) */
html.touch-ui .ink-btn.ink-finger {
  width: auto;
  height: 44px;
  padding: 0 14px;
  font-size: 13px;
}

/* ====================================================================================
   필기 · 선택 (tools.js pickInk): a loop is drawn around handwriting; what is picked gets a
   box that is dragged to move it, with a handle on each corner to resize it.
   ==================================================================================== */
.pane.inking.ink-selecting .pdf-container {
  cursor: default;
}
.ink-lasso {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}
.ink-lasso polyline {
  fill: color-mix(in srgb, var(--accent) 10%, transparent);
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  stroke-linejoin: round;
}
.ink-select {
  position: absolute;
  z-index: 5;
  box-sizing: border-box;
  border: 1.5px dashed var(--accent);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  cursor: move;
  touch-action: none;
}
.ink-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  touch-action: none;
}
/* (a larger area to catch than the dot that shows) */
.ink-handle::after {
  content: "";
  position: absolute;
  inset: -12px;
}
.ink-handle.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.ink-handle.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.ink-handle.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.ink-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.ink-select-del {
  position: absolute;
  left: 50%;
  top: -44px;
  translate: -50% 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--bad);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: none;
}
html.touch-ui .ink-handle {
  width: 18px;
  height: 18px;
}
html.touch-ui .ink-handle.nw { left: -10px; top: -10px; }
html.touch-ui .ink-handle.ne { right: -10px; top: -10px; }
html.touch-ui .ink-handle.sw { left: -10px; bottom: -10px; }
html.touch-ui .ink-handle.se { right: -10px; bottom: -10px; }
html.touch-ui .ink-select-del {
  width: 42px;
  height: 42px;
  top: -54px;
}

/* 필기: the layer the end of a line being written is drawn on (tools.js watchInk). */
.ink-live {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}

/* 필기 palette: it has grown (finger switch, eraser mode, select, redo), so wherever it does
   not fit on one row it goes onto two, on computers and tablets alike, all of it in view. */
.ink-bar,
html.touch-ui .ink-bar {
  flex-wrap: wrap;
  justify-content: center;
  row-gap: 6px;
  width: max-content;
  border-radius: 28px;
  overflow: visible;
}
.ink-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.ink-btn:disabled:hover {
  background: transparent;
}
.ink-btn[hidden] {
  display: none !important;
}
.ink-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
html.touch-ui .ink-tools {
  gap: 8px;
}
/* Phones: the finger switch shows its icon only (a hand: moves the paper; a pen: writes),
   so the tools fit on one row under the pens. */
@media (max-width: 520px) {
  html.touch-ui .ink-btn.ink-finger:not(.ink-erase-mode) {
    width: 44px;
    padding: 0;
  }
  html.touch-ui .ink-finger:not(.ink-erase-mode) .ink-finger-label {
    display: none;
  }
}

/* ====================================================================================
   공부, a document without questions (lecture slides, a paper, a chapter): its overview and
   each section's summary, points to remember and questions to check oneself (exam.js).
   ==================================================================================== */
.overview-card {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
}
.overview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.overview-card p {
  margin: 0;
  line-height: 1.7;
}
/* Which model wrote the guide (or that the chosen one is writing it again), at the right of the heading. */
.guide-by {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.section-summary {
  margin: 0 0 4px;
  line-height: 1.7;
}
.section-part {
  margin-top: 14px;
}
.section-part > strong {
  display: block;
  font-size: 13px;
  color: var(--accent-text);
  margin-bottom: 4px;
}
.section-part > p {
  margin: 0 0 8px;
}
.section-points {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  line-height: 1.6;
}
.section-checks {
  display: grid;
  gap: 6px;
}
.check-ask {
  appearance: none;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}
.check-ask .icon {
  flex: none;
  margin-top: 3px;
  color: var(--accent);
}
@media (hover: hover) {
  .check-ask:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
    background: var(--accent-soft);
  }
}
.section-card .section-asks {
  margin-top: 14px;
}

/* ====================================================================================
   A place in the document an answer points to: a page button in the answer (util.js
   renderMarkdown) and, on the paper, the words it quotes (tools.js showFound).
   ==================================================================================== */
.cite-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0 2px;
  padding: 1px 8px 1px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.82em;
  font-weight: 650;
  line-height: 1.5;
  vertical-align: 0.06em;
  white-space: nowrap;
  cursor: pointer;
}
.cite-chip::before {
  content: "↗";
  font-size: 0.9em;
}
@media (hover: hover) {
  .cite-chip:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
  }
}
html.touch-ui .cite-chip {
  padding: 3px 11px 3px 9px;
}
.found-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.found-strip {
  position: absolute;
  margin: -2px -3px;
  padding: 2px 3px;
  box-sizing: content-box;
  border-radius: 4px;
  background: rgb(255 170 0 / 0.38);
  box-shadow: 0 0 0 2px rgb(255 150 0 / 0.75);
  mix-blend-mode: multiply;
  animation: found-pulse 0.9s ease-out 2;
}
@keyframes found-pulse {
  from {
    box-shadow: 0 0 0 10px rgb(255 150 0 / 0.35);
  }
}
@media (prefers-reduced-motion: reduce) {
  .found-strip {
    animation: none;
  }
}

/* ====================================================================================
   Getting around the document (docnav.js): a pill over the bottom of the paper with the
   page number, the table of contents and the search; the search bar at the top.
   ==================================================================================== */
.doc-nav {
  position: absolute;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 24px);
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.doc-nav[hidden],
.doc-find[hidden],
.toc-pop[hidden] {
  display: none;
}
/* (while writing on the paper or cutting a piece out of it, the bottom belongs to that tool) */
.pane.inking .doc-nav,
.pane.inking .toc-pop {
  display: none;
}
.doc-nav .icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
}
.doc-nav .icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.page-at {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px 0 4px;
  white-space: nowrap;
}
.doc-nav .page-input {
  box-sizing: content-box;
  min-width: 1.6ch;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-align: right;
}
.doc-nav .page-input:hover {
  background: var(--surface-2);
}
.doc-nav .page-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}
.nav-back {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  padding: 5px 10px 5px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.nav-back:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.toc-pop {
  position: absolute;
  left: 50%;
  bottom: calc(58px + env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 17;
  width: min(380px, calc(100% - 24px));
  max-height: min(62%, 520px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.toc-item {
  appearance: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.toc-item:hover {
  background: var(--surface-2);
}
.toc-item.l2 {
  padding-left: 24px;
  color: var(--ink-2);
}
.toc-item.l3 {
  padding-left: 38px;
  color: var(--ink-2);
  font-size: 13px;
}
.toc-item.current {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.toc-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-page {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.doc-find {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 2px;
  width: min(360px, calc(100% - 24px));
  padding: 4px 5px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--muted);
}
.doc-find > svg {
  flex: none;
}
.doc-find .find-input {
  flex: 1;
  min-width: 0;
  box-shadow: none;
  padding: 6px 6px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  appearance: none;
}
.find-input::-webkit-search-cancel-button {
  display: none;
}
.find-count {
  padding: 0 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.doc-find.none .find-count {
  color: var(--bad);
}
.doc-find .icon-btn {
  width: 28px;
  height: 28px;
}
.doc-find .icon-btn.flip svg {
  rotate: 180deg;
}
/* Fingers: larger things to press, and a box the phone does not zoom into when it is tapped. */
html.touch-ui .doc-nav .icon-btn,
html.touch-ui .doc-find .icon-btn {
  width: 36px;
  height: 36px;
}
html.touch-ui .doc-nav {
  font-size: 14px;
}
html.touch-ui .page-input,
html.touch-ui .find-input {
  font-size: 16px;
}
html.touch-ui .toc-item {
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Links in the PDF. With a tool on (형광펜, 필기, 캡처, 이동 …) a press on the paper is for the
   tool, so links are out of the way; a link is never dragged about as a thing of its own. */
.pane.tool-on .annotationLayer,
.pane.tool-on .annotationLayer * {
  pointer-events: none !important;
}
.pdfViewer .annotationLayer a {
  -webkit-user-drag: none;
}
.pdfViewer .annotationLayer .linkAnnotation > a:hover {
  background: rgb(90 90 240 / 0.12);
  box-shadow: none;
  opacity: 1;
}

/* ====================================================================================
   A written answer (exam.js answerForm, markedParts): typed, written by hand or
   photographed, then marked by the AI.
   ==================================================================================== */
.answer-form {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}
.answer-form .answer-input {
  display: block;
  width: 100%;
  min-height: 76px;
  resize: vertical;
  padding: 10px 12px;
  line-height: 1.6;
}
.answer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.answer-actions .spacer {
  flex: 1;
}
.answer-pics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.answer-pics[hidden] {
  display: none;
}
.answer-pic {
  position: relative;
  display: inline-block;
}
.answer-pic img {
  display: block;
  height: 84px;
  max-width: 180px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}
.pic-x {
  appearance: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.pic-x:hover {
  background: var(--surface-2);
}
.my-answer {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.my-answer strong {
  font-size: 13px;
  color: var(--muted);
}
.my-answer p {
  margin: 2px 0 0;
  line-height: 1.65;
}
.my-answer .answer-pics {
  margin-top: 8px;
}
.verdict.partly {
  background: var(--warn-soft);
  color: var(--warn);
}
.verdict.unclear {
  background: var(--surface-2);
  color: var(--ink-2);
}
.qchip.partly {
  background: var(--warn-soft);
  color: var(--warn);
}
.mark-list {
  margin-top: 12px;
}
.mark-list strong {
  font-size: 13px;
}
.mark-list.good strong {
  color: var(--good);
}
.mark-list.fix strong {
  color: var(--bad);
}
.mark-list ul {
  margin: 4px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  line-height: 1.65;
}
.model-answer > :not(summary):first-of-type {
  margin-top: 6px;
}
.read-back {
  margin: 6px 0 0;
  color: var(--ink-2);
}

/* ====================================================================================
   Picking pages of the document to show the AI together (pagepick.js)
   ==================================================================================== */
.app-dialog.page-picker {
  width: min(860px, calc(100vw - 24px));
  height: min(760px, calc(100vh - 32px));
  max-height: none;
  overflow: hidden;
}
.pick-body {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pick-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 16px 10px 22px;
}
.pick-head > div {
  flex: 1;
  min-width: 0;
}
.pick-head h2 {
  font-size: 18px;
  font-weight: 800;
}
.pick-head p {
  margin: 4px 0 0;
}
.pick-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px 12px;
}
.pick-tools .pick-range {
  width: 170px;
  padding: 7px 10px;
}
.pick-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  align-content: start;
  gap: 14px 12px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.pick-page {
  appearance: none;
  position: relative;
  display: grid;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.pick-paper {
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  outline: 1px solid var(--line-strong);
  outline-offset: 0;
  transition: outline-color 0.12s, box-shadow 0.12s;
}
.pick-paper:has(.pick-canvas) {
  aspect-ratio: auto;
}
.pick-canvas {
  display: block;
  width: 100%;
  height: auto;
}
.pick-page:hover .pick-paper {
  outline-color: var(--accent);
}
.pick-page:focus-visible {
  outline: none;
}
.pick-page:focus-visible .pick-paper {
  box-shadow: var(--ring);
}
.pick-page.picked .pick-paper {
  outline: 3px solid var(--accent);
}
.pick-page.picked {
  color: var(--accent-text);
  font-weight: 700;
}
.pick-mark {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: none;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.pick-page.picked .pick-mark {
  display: grid;
}
.pick-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 14px 22px;
}
.pick-foot .spacer {
  flex: 1;
}
.pick-count {
  color: var(--muted);
  font-size: 13px;
}
.pick-count.full {
  color: var(--warn);
  font-weight: 600;
}
.pick-count.nudge {
  animation: pick-nudge 0.3s ease-out;
}
@keyframes pick-nudge {
  30% {
    translate: 5px 0;
  }
  60% {
    translate: -4px 0;
  }
}
.pages-card {
  cursor: pointer;
}
@media (max-width: 560px) {
  .pick-grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    padding: 12px 14px 14px;
    gap: 12px 10px;
  }
  .pick-head {
    padding: 14px 10px 8px 16px;
  }
  .pick-tools {
    padding: 0 16px 10px;
  }
  .pick-tools .pick-range {
    flex: 1;
    width: auto;
    min-width: 0;
  }
  .pick-foot {
    padding: 10px 12px 12px 16px;
    flex-wrap: wrap;
  }
}
html.touch-ui .pick-tools .pick-range {
  font-size: 16px;
}

/* ====================================================================================
   Several documents read together (chat.js linked bar, docpick.js)
   ==================================================================================== */
.linked-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 2px 8px;
  font-size: 12.5px;
}
.linked-bar[hidden] {
  display: none;
}
.linked-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.linked-chip {
  display: inline-flex;
  align-items: center;
  max-width: min(240px, 100%);
  padding: 2px 3px 2px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
}
.linked-chip.waiting {
  border-style: dashed;
  opacity: 0.7;
}
.linked-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 550;
  text-decoration: none;
}
.linked-name:hover {
  text-decoration: underline;
}
.linked-bar .icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}
.linked-add {
  border: 1px dashed var(--line-strong) !important;
}
html.touch-ui .linked-bar .icon-btn {
  width: 30px;
  height: 30px;
}
.cite-chip.other-doc {
  max-width: 100%;
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink-2);
}

.app-dialog.doc-picker {
  width: min(520px, calc(100vw - 24px));
  max-height: min(680px, calc(100vh - 32px));
  overflow: hidden;
}
.doc-picker .pick-body {
  max-height: min(680px, calc(100vh - 32px));
}
.doc-rows {
  flex: 1;
  min-height: 120px;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.doc-rows-empty {
  margin: 0;
  padding: 24px 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.doc-row {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.doc-row:hover:not(:disabled) {
  background: var(--surface-2);
}
.doc-row:disabled {
  cursor: default;
  opacity: 0.55;
}
.doc-row-box {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  color: transparent;
}
.doc-row.picked .doc-row-box {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.doc-row-icon {
  flex: none;
  display: grid;
  color: var(--muted);
}
.doc-row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 550;
}
.doc-row-meta {
  flex: none;
  white-space: nowrap;
}

/* Several PDFs chosen on the 공부 page: each by name under the slots (library.js). */
.study-files {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.study-files[hidden] {
  display: none;
}
.study-files .file-chip {
  padding-right: 3px;
}
.file-chip-x {
  width: 22px !important;
  height: 22px !important;
  border-radius: 50%;
}
.study-files-note {
  flex-basis: 100%;
  margin-top: 2px;
}
.study-slot.off {
  opacity: 0.55;
}

/* Dialogs on phones: the browser's own bars come and go, and "100vh" is the height with
   them hidden, so a dialog sized by it had its bottom (and its buttons) cut off. */
@supports (height: 100dvh) {
  .app-dialog {
    max-height: calc(100dvh - 48px);
  }
  .app-dialog.page-picker {
    height: min(760px, calc(100dvh - 32px));
    max-height: none;
  }
  .app-dialog.doc-picker,
  .doc-picker .pick-body {
    max-height: min(680px, calc(100dvh - 32px));
  }
}
.pick-body {
  min-width: 0;
}
.pick-tools {
  flex-wrap: wrap;
}
@media (max-width: 560px) {
  .app-dialog.page-picker,
  .app-dialog.doc-picker {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    margin: auto;
  }
  .app-dialog.page-picker {
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
  }
  .pick-head h2 {
    font-size: 17px;
  }
  .pick-foot .btn.primary {
    flex: 1 0 auto;
  }
}

/* ====================================================================================
   Documents that are read together: one block in the list on the left (sidebar.js), and a
   row of tabs over the open document (exam.js renderSet).
   ==================================================================================== */
.side-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin: 3px 0;
  padding: 3px 0 3px 8px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 2px;
}
.side-group-head {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px 3px 4px;
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-group .side-item {
  padding-left: 6px;
}

.doc-set {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.doc-set[hidden] {
  display: none;
}
.doc-set::-webkit-scrollbar {
  display: none;
}
.doc-set-label {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-right: 6px;
  padding-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.doc-tab {
  flex: 0 1 220px;
  min-width: 96px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 7px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.doc-tab-name {
  flex: 1 1 auto; /* (takes the room left, so the X keeps to the tab's right edge) */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
a.doc-tab:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.doc-tab.current {
  margin-bottom: -1px;
  border-color: var(--line);
  background: var(--pdf-bg);
  color: var(--ink);
  font-weight: 700;
}
html.touch-ui .doc-tab {
  padding-top: 9px;
  padding-bottom: 10px;
  font-size: 13px;
}

/* ====================================================================================
   Sizing fixes, and groups of connected documents as folders
   ==================================================================================== */

/* The "+" menu: as wide as its longest line needs (a fixed width cut "Read other documents"). */
html:not(.touch-ui) .pop-menu.plus-menu,
html.touch-ui .pop-menu.plus-menu {
  width: max-content;
  min-width: 210px;
  max-width: calc(100vw - 24px);
}
.plus-menu .chat-menu-item {
  white-space: nowrap;
}
.plus-menu .chat-menu-item > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The list of documents to connect: long titles are cut with "…", never scrolled sideways. */
.doc-rows {
  grid-template-columns: minmax(0, 1fr);
  overflow-x: hidden;
}
.doc-row {
  min-width: 0;
}
.doc-picker .pick-body {
  min-width: 0;
  overflow: hidden;
}
.group-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.group-name-row[hidden] {
  display: none;
}
.group-name-row > span {
  flex: none;
}
.group-name-row .group-name {
  flex: 1;
  min-width: 0;
  width: auto;
  padding: 7px 10px;
  font-weight: 500;
}
.study-files .group-name-row {
  flex-basis: 100%;
  padding: 4px 0 0;
  max-width: 420px;
}
html.touch-ui .group-name-row .group-name {
  font-size: 16px;
}

/* A document's card: its title takes two lines at most, whatever height the row gives the card. */
.exam-card {
  align-content: start;
  min-width: 0;
}
.exam-title {
  line-height: 1.4;
  max-height: 2.8em;
  overflow-wrap: anywhere;
}
.exam-card > .muted {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* A folder on the 공부 page, and the documents inside it when it is unfolded. */
.folder-card {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.folder-card .exam-icon {
  background: var(--warn-soft);
  color: var(--warn);
}
.folder-card.open {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.folder-chevron {
  display: grid;
  color: var(--muted);
  transition: rotate 0.15s;
}
.folder-card.open .folder-chevron {
  rotate: 180deg;
}
.folder-meta {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.folder-open {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  padding: 12px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: var(--r-lg);
  background: var(--surface-2);
}

/* A group in the list on the left: one entry with the group's name that unfolds. */
.side-group {
  margin: 1px 0;
  padding: 0;
  border-left: 0;
}
.side-group.open {
  margin-bottom: 4px;
}
.side-group-head {
  appearance: none;
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.side-group-head:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.side-group-head > .icon:first-child {
  flex: none;
  color: var(--muted);
  rotate: -90deg;
  transition: rotate 0.15s;
}
.side-group.open .side-group-head > .icon:first-child {
  rotate: 0deg;
}
.side-group-head > .icon:nth-child(2) {
  flex: none;
  color: var(--warn);
}
.side-group-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-group-count {
  flex: none;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.side-group .side-item {
  margin-left: 14px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
  border-radius: 0 10px 10px 0;
}
html.touch-ui .side-group-head {
  min-height: 44px;
  font-size: 15px;
}

/* A group's row in the list on the left: the part that unfolds it, and its ⋯ (as on a document's row). */
.side-group-head {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 36px;
  padding: 0 6px 0 0;
  border-radius: 10px;
  cursor: default;
}
.side-group-head:hover,
.side-group-head:focus-within {
  background: var(--surface-2);
}
.side-group-toggle {
  appearance: none;
  flex: 1;
  min-width: 0;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 4px 0 6px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.side-group-head:hover .side-group-toggle {
  color: var(--ink);
}
.side-group-toggle > .icon:first-child {
  flex: none;
  color: var(--muted);
  rotate: -90deg;
  transition: rotate 0.15s;
}
.side-group.open .side-group-toggle > .icon:first-child {
  rotate: 0deg;
}
.side-group-toggle > .icon:nth-child(2) {
  flex: none;
  color: var(--warn);
}
.side-group-head:hover .side-item-more,
.side-group-head:focus-within .side-item-more {
  opacity: 1;
}
html.touch-ui .side-group-toggle {
  min-height: 44px;
  font-size: 15px;
}
/* A folder on the 공부 page is a card that is pressed, with a menu button of its own inside. */
.section-head.folder-head {
  margin-top: 28px; /* (the row of folders under the documents on the 공부 page) */
}
.folder-card:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

/* ====================================================================================
   A folder's documents in a sheet over the page (library.js showFolder), and tabs that
   can be moved (exam.js renderSet).
   ==================================================================================== */
.folder-pop-back {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(10 10 20 / 0.5);
  backdrop-filter: blur(3px);
  animation: fade-in 0.14s ease-out;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.folder-pop {
  width: min(760px, 100%);
  max-height: min(680px, calc(100vh - 32px));
  max-height: min(680px, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.folder-pop-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px 12px 18px;
  border-bottom: 1px solid var(--line);
}
.folder-pop-head .exam-icon {
  background: var(--warn-soft);
  color: var(--warn);
}
.folder-pop-head .spacer {
  flex: 1;
}
.folder-pop-title {
  min-width: 0;
  display: grid;
}
.folder-pop-title strong {
  font-size: 17px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-pop-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  align-content: start;
  gap: 12px;
  padding: 16px;
  background: var(--surface-2);
}
.folder-card.open {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.doc-tab[draggable="true"] {
  cursor: grab;
  -webkit-user-drag: element;
  user-select: none;
}
a.doc-tab[draggable="true"] {
  cursor: pointer;
}
.doc-tab.dragging {
  opacity: 0.45;
}
.doc-tab.drop-before {
  box-shadow: inset 3px 0 0 var(--accent);
}
.doc-tab.drop-after {
  box-shadow: inset -3px 0 0 var(--accent);
}

/* The bar of connected documents over the message box stays on one line: on a phone a long
   title pushed the "+" onto a line of its own. Names are cut with "…"; several documents
   scroll sideways; on a narrow screen the label is just its picture. */
.linked-bar {
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.linked-bar::-webkit-scrollbar {
  display: none;
}
.linked-label,
.linked-add {
  flex: none;
}
.linked-chip {
  flex: 0 1 auto;
  min-width: 84px;
  max-width: 220px;
}
.linked-chip .linked-x {
  flex: none;
}
@media (max-width: 560px) {
  .linked-label {
    gap: 0;
    font-size: 0; /* (the picture stays; the words would take a third of the line) */
  }
  .linked-chip {
    max-width: none;
  }
}

/* ====================================================================================
   The message box, a little larger, and its round button in its several roles
   (send, ask by voice, stop an answer, stop listening or reading aloud)
   ==================================================================================== */
.dock .composer {
  padding: 10px 10px 9px;
  border-radius: 18px;
}
.dock .composer .composer-input {
  min-height: 3.3em; /* two lines to write in, where there was one */
  font-size: 15.5px;
  line-height: 1.55;
}
.dock .send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}
html.touch-ui .dock .composer .composer-input {
  min-height: 2.9em;
  font-size: 16px;
}
/* Stop (an answer is being written, or read aloud): the same colour as the microphone
   button, with a white square and a ring that breathes while the work goes on. */
.send-btn.is-stop,
.send-btn.is-speaking {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 0 0 0 rgb(90 80 240 / 0.45);
  animation: stop-pulse 1.6s ease-out infinite;
}
@keyframes stop-pulse {
  to {
    box-shadow: 0 0 0 12px rgb(90 80 240 / 0);
  }
}
.send-btn.is-stop .icon,
.send-btn.is-speaking .icon {
  color: #fff;
}
.send-btn.is-listening {
  background: var(--bad);
  box-shadow: 0 0 0 0 rgb(207 62 86 / 0.5);
  animation: mic-pulse 1.3s ease-out infinite;
}
@keyframes mic-pulse {
  to {
    box-shadow: 0 0 0 12px rgb(207 62 86 / 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .send-btn.is-listening {
    animation: none;
  }
}
.stopped-note {
  margin-top: 4px;
}

/* The 공부 page, lifted: the heading, the box, the documents and the row of folders are on
   one screen without scrolling. (The empty strip that once held a notice over the heading
   is gone, and the gaps between the parts are tighter.) */
.library .banner-space {
  display: none;
}
.library .analysis-hero {
  margin-bottom: 20px;
}
.library .analysis-hero h1 {
  font-size: 38px;
}
.library .home-ask {
  margin-bottom: 0;
}
.library .home-box .composer-input {
  min-height: 56px;
}
.library .section-head {
  margin: 24px 0 12px;
}
.library .section-head.folder-head {
  margin-top: 18px;
}

/* The 공부 page stands in the middle of the screen's height. On a tall window everything
   sat at the top with the empty space under it. The free space is now shared, so the
   page moves down into it: as much above the heading as there is under the last row.
   Two empty flex items hold the space, one before everything and one after the last row.
   They take the page's own top and bottom spacing as their least height (6px and 96px),
   so a window that the page fills looks exactly as before and nothing moves. */
.library:has(.analysis-hero) {
  box-sizing: border-box;
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  display: flex;
  flex-direction: column;
  padding-top: 0;
  padding-bottom: 0;
}
.library:has(.analysis-hero)::before,
.library:has(.analysis-hero)::after {
  content: "";
  flex: 1 1 0px;
}
.library:has(.analysis-hero)::before {
  min-height: 6px;
}
.library:has(.analysis-hero)::after {
  min-height: 96px;
  order: 1;
}
/* With the site's footer: the space goes between the last row and the footer (never less
   than the footer's usual 72px), and the footer keeps the foot of the page. */
.library:has(.site-footer):has(.analysis-hero) {
  padding-bottom: 96px;
}
.library:has(.site-footer):has(.analysis-hero)::after {
  min-height: 72px;
}
.library:has(.analysis-hero) > .site-footer {
  order: 2;
  margin-top: 0;
}
/* (as a flex item the heading's inner margins no longer fold into the gap under it) */
.library:has(.analysis-hero) > .analysis-hero {
  margin-bottom: 6px;
}

/* The 공부 page's cards (내 문서, 폴더), more compact: smaller padding, picture, title and
   lines. (Cards in a folder's sheet are the same cards and shrink with them.) */
.library .exam-grid,
.folder-pop-list {
  gap: 12px;
}
.library .exam-card,
.folder-pop .exam-card {
  gap: 3px;
  padding: 12px 14px;
  border-radius: 14px;
}
.library .exam-top,
.folder-pop .exam-top {
  gap: 7px;
  margin-bottom: 4px;
}
.library .exam-icon,
.folder-pop .exam-card .exam-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.library .exam-icon .icon,
.folder-pop .exam-card .exam-icon .icon {
  width: 15px;
  height: 15px;
}
.library .exam-card .tag,
.folder-pop .exam-card .tag {
  font-size: 11.5px;
  padding: 1px 8px;
}
.library .exam-card .exam-more,
.folder-pop .exam-card .exam-more {
  width: 26px;
  height: 26px;
}
.library .exam-title,
.folder-pop .exam-title {
  font-size: 14.5px;
}
.library .exam-card > .muted.small,
.folder-pop .exam-card > .muted.small {
  font-size: 12px;
}
.library .exam-progress,
.folder-pop .exam-progress {
  gap: 4px;
  margin-top: 4px;
}
.library .exam-progress .bar,
.folder-pop .exam-progress .bar {
  height: 4px;
}
.library .exam-progress .muted,
.folder-pop .exam-progress .muted {
  font-size: 12px;
}
/* Less held back under the last row (it was 96px), so the page moves down into what the
   smaller cards free up and still fits one screen down to the folders. */
.library:has(.analysis-hero):not(:has(.site-footer))::after {
  min-height: 28px;
}

/* Pushed further down: the free space goes three parts above the heading to one under the
   last row (it was shared evenly), and the cards are trimmed a little more to make room. */
.library:has(.analysis-hero)::before {
  flex-grow: 3;
}
.library:has(.analysis-hero):not(:has(.site-footer))::after {
  flex-grow: 1;
  min-height: 16px;
}
.library .exam-card {
  padding: 10px 13px;
  gap: 2px;
}
.library .exam-top {
  margin-bottom: 2px;
}
.library .exam-card .exam-title {
  -webkit-line-clamp: 1;
  max-height: 1.4em;
}
.library .folder-meta {
  -webkit-line-clamp: 1;
}
.library .exam-progress {
  margin-top: 2px;
}
.library .section-head {
  margin: 18px 0 9px;
}
.library .section-head.folder-head {
  margin-top: 14px;
}

/* With the site's footer (the live site): the first screen is laid out as without it, so
   the page moves down the same way, and the footer follows below the fold. The page is
   one screen tall plus the footer (--foot, measured in library.js) and its 96px under it;
   the space between the last row and the footer is the same as under the last row on a
   page without a footer. */
.library:has(.site-footer):has(.analysis-hero) {
  min-height: calc(100vh - 56px + var(--foot, 0px) + 96px);
  min-height: calc(100dvh - 56px + var(--foot, 0px) + 96px);
}
.library:has(.site-footer):has(.analysis-hero)::after {
  flex-grow: 1;
  min-height: 16px;
}

/* Not so far down: of the free space, one part goes above the heading and two under the
   last row (it was three above to one under), which puts the heading near the top third. */
.library:has(.analysis-hero)::before {
  flex-grow: 1;
}
.library:has(.analysis-hero)::after,
.library:has(.analysis-hero):not(:has(.site-footer))::after,
.library:has(.site-footer):has(.analysis-hero)::after {
  flex-grow: 2;
}

/* The footer comes up onto the first screen, smaller: the page is one screen tall again
   (not one screen plus the footer), with little under the footer, and the footer's lines
   are smaller and closer together. */
.library:has(.site-footer):has(.analysis-hero) {
  min-height: calc(100vh - 56px);
  min-height: calc(100dvh - 56px);
  padding-bottom: 14px;
}
.library:has(.site-footer):has(.analysis-hero)::after {
  min-height: 24px;
}
.library:has(.analysis-hero) > .site-footer {
  gap: 3px;
  padding-top: 10px;
  font-size: 11px;
  line-height: 1.5;
}
.library:has(.analysis-hero) > .site-footer .footer-links {
  gap: 12px;
}
.library:has(.analysis-hero) > .site-footer .footer-info {
  gap: 2px 10px;
}

/* Phones: the 필기 tools on one row under the pens, also with the eraser on (its 부분 /
   획 지우기 switch made the row spill onto a third line). The round buttons are a little
   smaller and closer, the palette reaches nearer the screen's edges, and the eraser's
   switch is a compact pill. A very narrow phone still wraps, with everything in view. */
@media (max-width: 520px) {
  html.touch-ui .ink-bar {
    max-width: calc(100% - 12px);
    padding: 8px;
    gap: 6px;
  }
  html.touch-ui .ink-tools {
    gap: 4px;
    flex-wrap: nowrap;
  }
  html.touch-ui .ink-tools .ink-btn {
    width: 38px;
    height: 38px;
    flex: none;
  }
  html.touch-ui .ink-tools .ink-btn.ink-finger.ink-erase-mode {
    width: auto;
    height: 38px;
    padding: 0 9px;
    font-size: 12px;
  }
  html.touch-ui .ink-bar .pen-style {
    gap: 5px;
  }
}
@media (max-width: 340px) {
  html.touch-ui .ink-tools {
    flex-wrap: wrap;
  }
}

/* Touch screens: the 필기 tools hold still.
   - The finger switch's picture is centred in its button (it is a row of a picture and
     words, and on phones the words are hidden, which left the picture at the left edge).
   - The eraser's 부분 / 획 지우기 switch keeps its place in the row while the eraser is
     off (it is just not shown), and is the same width whichever it says: the row no
     longer grows and shrinks, and everything in it no longer slides about, as the eraser
     is turned on and off or switched. */
html.touch-ui .ink-btn.ink-finger {
  justify-content: center;
}
html.touch-ui .ink-btn.ink-erase-mode {
  width: 92px;
  padding: 0 6px;
}
html.touch-ui .ink-btn.ink-erase-mode[hidden] {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}
@media (max-width: 520px) {
  html.touch-ui .ink-tools .ink-btn.ink-finger:not(.ink-erase-mode) {
    width: 38px;
    padding: 0;
    background: var(--surface-2);
  }
  html.touch-ui .ink-tools .ink-btn.ink-finger.ink-erase-mode {
    width: 74px;
    padding: 0 4px;
  }
}
@media (max-width: 352px) {
  html.touch-ui .ink-tools .ink-btn {
    width: 34px;
    height: 34px;
  }
  html.touch-ui .ink-tools .ink-btn.ink-finger.ink-erase-mode {
    width: 68px;
    height: 34px;
    font-size: 11.5px;
  }
}
/* (computers and tablets without touch too: the eraser's switch keeps its place) */
.ink-btn.ink-finger.ink-erase-mode {
  width: 92px;
  padding: 0 6px;
  justify-content: center;
}
.ink-btn.ink-erase-mode[hidden] {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}

/* An empty slot's description takes a second line rather than being cut with "…" (a file's
   name, once one is chosen, still stays on one line). */
.file-slot:not(.has-file) .slot-value {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

/* ====================================================================================
   공부 page: material of any kind. A slot for files (PDFs, Word and PowerPoint files,
   photos, recordings, videos), one for links and pasted text, the answer key and the AI
   stand in one row on a wide window and two by two on a narrower one (library.js).
   ==================================================================================== */
.study-slots {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 1080px) {
  .study-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .study-slots {
    grid-template-columns: 1fr;
  }
}
/* What a document was made from, on its card: a web page, a video, a recording. */
.exam-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  color: var(--muted);
}
.exam-source > .icon {
  flex: none;
}

/* The box for a link or pasted text (linkbox.js). */
.link-dialog {
  width: min(520px, calc(100vw - 32px));
}
.link-dialog .dialog-body {
  display: grid;
  gap: 12px;
}
.link-dialog .link-text {
  height: auto;
  min-height: 66px;
  max-height: 38vh;
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  resize: vertical;
}
.link-dialog .link-help {
  margin: -4px 0 0;
  line-height: 1.55;
}
.link-dialog .link-error {
  margin: 0;
  color: var(--bad);
  font-weight: 600;
}
.link-dialog .link-error[hidden] {
  display: none;
}

/* ====================================================================================
   A document that is not a PDF, shown as what it is in the document's pane (sourceview.js).
   ==================================================================================== */
/* A video or a recording: the player takes the top of the pane; under it stands the
   transcript as lines with their times (or, switched, the pages of text). */
.pane.has-media .pdf-container {
  top: var(--media-h, 0px);
}
.source-media {
  position: absolute;
  inset: 0 0 auto 0;
  height: var(--media-h, 0px);
  z-index: 3;
  display: flex;
  flex-direction: column;
  background: #0b0b10;
  border-bottom: 1px solid var(--line);
}
.media-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  background: #000;
}
.media-frame,
.media-el {
  width: 100%;
  max-width: var(--media-max, 960px);
  height: 100%;
  border: 0;
  background: #000;
}
.source-media.audio .media-stage {
  align-items: center;
  background: var(--surface);
  padding: 0 10px;
}
.source-media.audio .media-el {
  height: 40px;
  background: transparent;
}
.media-caption {
  flex: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 14px;
  background: var(--surface);
}
.media-now {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 13.5px;
}
.media-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--accent);
}
button.media-time {
  appearance: none;
  margin: -4px -6px;
  padding: 4px 6px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button.media-time:hover,
button.media-time:focus-visible {
  background: var(--accent-soft);
}
.media-line {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-side {
  flex: none;
  white-space: nowrap;
}
/* The transcript: a line for each paragraph, with its time. The one being said is lit. */
.media-script {
  position: absolute;
  inset: var(--media-h, 0px) 0 0 0;
  z-index: 2;
  overflow-y: auto;
  /* (rows that grow as translations arrive do not make the browser move the box by itself) */
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 6px 0 96px;
  background: var(--surface);
}
.media-script:focus {
  outline: none;
}
.pane.script-off .media-script {
  display: none;
}
.script-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  column-gap: 12px;
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 18px 10px 15px;
  border-left: 3px solid transparent;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.65;
  cursor: pointer;
  overflow-wrap: anywhere;
}
@media (hover: hover) {
  .script-row:hover {
    background: var(--surface-2);
  }
}
.script-row.now {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.script-row.found {
  animation: script-found 2.6s ease;
}
@keyframes script-found {
  0%,
  60% {
    box-shadow: inset 0 0 0 2px var(--accent);
  }
  100% {
    box-shadow: inset 0 0 0 2px transparent;
  }
}
.script-time {
  padding-top: 2px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.script-row.on-screen .script-text {
  color: var(--muted);
}
.script-tag {
  display: inline-block;
  margin-right: 7px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.6;
  vertical-align: 1px;
}
/* (while the lines are shown, the page counter of the pages underneath is out of sight) */
.pane.has-script:not(.script-off) > .doc-nav,
.pane.has-script:not(.script-off) > .toc-pop,
.pane.has-script:not(.script-off) > .doc-find {
  display: none;
}
@media (max-width: 600px) {
  .script-row {
    grid-template-columns: 46px minmax(0, 1fr);
    column-gap: 8px;
    padding: 9px 14px 9px 11px;
    font-size: 15px;
  }
  .media-caption {
    padding-left: 12px;
  }
  .media-now {
    gap: 8px;
    font-size: 13px;
  }
}
/* A time in an answer: a button that plays from there. */
.time-chip {
  display: inline-flex;
  align-items: center;
  margin: 0 1px;
  padding: 0 7px;
  height: 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: inherit;
  font-size: 0.9em;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  vertical-align: baseline;
}
.time-chip::before {
  content: "▶";
  font-size: 0.62em;
  margin-right: 4px;
}
.time-chip:hover {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
}

/* A web page or a file: it fills the pane under a bar that holds the switch to its text. */
.source-bar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 46px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.source-bar .seg {
  flex: none;
}
.source-from {
  flex: 1;
  min-width: 0;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.source-open {
  flex: none;
  width: 32px;
  height: 32px;
}
.pane.has-cover .pdf-container {
  top: 46px;
}
.source-cover {
  position: absolute;
  inset: 46px 0 0 0;
  z-index: 3;
  overflow: auto;
  background: var(--surface);
}
.pane.cover-off .source-cover {
  display: none;
}
.source-cover.live {
  overflow: hidden;
  background: #fff;
}
.source-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.source-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding: 24px;
  text-align: center;
}
/* The app's own reading view of an article. */
.reader {
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 28px 96px;
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.reader-site {
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
.reader h1 {
  margin: 6px 0 22px;
  font-size: 28px;
  line-height: 1.3;
}
.reader-body img,
.reader-body video {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}
.reader-body figure {
  margin: 20px 0;
}
.reader-body figcaption {
  font-size: 13px;
  color: var(--muted);
}
.reader-body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
}
.reader-body pre {
  max-width: 100%;
  overflow-x: auto;
}
.reader-foot {
  margin-top: 40px;
}
@media (max-width: 600px) {
  .reader {
    padding: 22px 18px 96px;
    font-size: 16px;
  }
  .reader h1 {
    margin-bottom: 16px;
    font-size: 23px;
  }
  .source-from {
    font-size: 12px;
  }
}
/* A Word file, as its pages (made smaller to fit a narrow pane); a PowerPoint file, as its slides. */
.docx-host,
.pptx-host {
  min-height: 100%;
  padding: 16px 0 40px;
  background: var(--pdf-bg);
}
.docx-host .docx-wrapper {
  background: transparent;
  padding: 0;
}
.docx-host .docx-wrapper > section.docx {
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgb(20 20 40 / 0.12), 0 10px 30px rgb(20 20 40 / 0.1);
}
.pptx-host {
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* An Excel file: a grid with its letters and numbers, a tab for each sheet. */
.sheet-host {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.sheet-grid {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
}
.sheet-grid table {
  border-collapse: collapse;
  font-size: 13px;
  color: var(--ink);
}
.sheet-grid th,
.sheet-grid td {
  border: 1px solid var(--line);
  padding: 5px 10px;
  white-space: nowrap;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}
.sheet-grid td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.sheet-grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  min-width: 40px;
}
.sheet-grid tbody th {
  left: 0;
  top: auto;
  z-index: 0;
}
.sheet-tabs {
  flex: none;
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.sheet-tab {
  padding: 6px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.sheet-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.12);
}

/* A PowerPoint file's slides (pptxview.js): each a stage of the slide's own size, scaled to the pane. */
.pptx-host {
  --pp-font: "Pretendard Variable", Pretendard, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  gap: 0;
}
.pp-slide {
  position: relative;
  flex: none;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgb(20 20 40 / 0.12), 0 10px 30px rgb(20 20 40 / 0.1);
}
.pp-stage {
  position: absolute;
  inset: 0 auto auto 0;
  transform-origin: 0 0;
  overflow: hidden;
  color: #000;
  font-family: var(--pp-font);
}
.pp-no {
  margin: 6px 0 18px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pp-shape {
  position: absolute;
  box-sizing: border-box;
}
.pp-shape img {
  display: block;
  width: 100%;
  height: 100%;
}
.pp-text {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
  word-break: keep-all;
  user-select: text;
}
.pp-p {
  margin: 0;
  min-height: 1em;
  white-space: pre-wrap;
}
.pp-bullet {
  display: inline-block;
  text-align: left;
}
.pp-other {
  display: grid;
  place-items: center;
  border: 1.5px dashed #9aa3b5;
  border-radius: 8px;
  background: #f3f5fa;
  color: #5b6475;
  font-size: 15pt;
}
.pp-table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.pp-table td {
  border: 1px solid rgb(0 0 0 / 0.28);
  padding: 4px 8px;
  vertical-align: top;
  overflow: hidden;
}
.pp-failed {
  display: grid;
  place-items: center;
  color: #5b6475;
  font-size: 20pt;
}
/* While a page or a file covers the pane, the page counter of the text underneath is out of sight. */
.pane.has-cover:not(.cover-off) > .doc-nav,
.pane.has-cover:not(.cover-off) > .toc-pop,
.pane.has-cover:not(.cover-off) > .doc-find {
  display: none;
}

/* A chat's "자료 올리기" button while it works ("AI가 영상을 보는 중… 20분부터"): one line, cut where the button ends. */
.rail-btn.busy .rail-label {
  max-width: min(46vw, 260px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* (a formula in a transcript's line sits in the line) */
.script-text > p {
  display: inline;
  margin: 0;
}
/* Slides and Word pages made larger than the pane are reached by scrolling sideways, from their left edge. */
.pptx-host {
  align-items: safe center;
}
.docx-host {
  overflow-x: auto;
}

/* A low, wide pane (a phone held sideways): the video stands beside its lines, not over them. */
.pane.media-beside .source-media {
  inset: 0 auto 0 0;
  width: var(--media-w, 50%);
  height: auto;
  border-bottom: 0;
  border-right: 1px solid var(--line);
}
.pane.media-beside .media-script,
.pane.media-beside.has-media .pdf-container {
  top: 0;
  left: var(--media-w, 50%);
}
.pane.media-beside .media-script {
  inset: 0 0 0 var(--media-w, 50%);
}

/* A time in another document of the group names that document: "강의 영상 · 13:32". */
.time-chip.other-doc {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- the level picker: 낮음 · 보통 · 높음 · 최고 · 직접 고르기 (levelpicker.js) ---------- */
.level-picker {
  display: flex;
  align-items: center;
  min-width: 0;
}
/* The button: the level, then the model it comes to ("보통 · Sonnet 5.5"), no icon. */
.level-dd {
  gap: 6px;
  min-width: 0;
}
.level-dd .dd-name {
  flex: none;
  font-weight: 700;
}
.level-model {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-weight: 550;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.level-model::before {
  content: "·";
  margin-right: 6px;
}
/* The card: the phone's model slider (.model-sheet above), with a stop for each level,
   their names under the track, and 직접 고르기 beside the title. */
.level-sheet .ms-name {
  font-size: 18px;
}
.ls-stops {
  position: relative;
  height: 22px;
  margin-top: -6px;
}
.ls-stop {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  padding: 2px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.ls-stop:hover {
  color: var(--ink);
}
.ls-stop.on {
  color: var(--accent-text);
  font-weight: 800;
}
.ms-more.ls-custom {
  padding: 0 12px;
}
.ms-more.ls-custom.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.ms-knob[hidden] {
  display: none;
}
.level-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.level-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.level-opt:hover {
  background: var(--surface-2);
}
.level-opt[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.level-opt:disabled {
  opacity: 0.5;
  cursor: default;
}
.level-opt b {
  font-size: 14px;
}
.level-opt span {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--muted);
}
.level-mix {
  margin: 0 0 12px;
}
@media (max-width: 560px) {
  .level-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* A slide or paragraph a part of the study guide begins with, marked for a moment (sourceview.js showPlace). */
.pp-slide.place-found {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.docx-wrapper .place-found,
.reader .place-found {
  background: var(--mark);
  color: var(--mark-ink);
  transition: background 0.3s;
}

/* ---------- the link box: several links, a smaller box for pasted text (linkbox.js) ---------- */
.link-rows {
  display: grid;
  gap: 6px;
}
.link-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.link-row .prompt-input {
  flex: 1;
  min-width: 0;
}
.link-rows.one .link-row-x {
  display: none;
}
.link-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  /* (only as wide as its words, in a grid or a column alike: a press beside it is not a press on it) */
  align-self: flex-start;
  justify-self: start;
  width: max-content;
  max-width: 100%;
}
.level-menu .chat-menu-item {
  white-space: nowrap;
}

/* ---------- 공부: the screen shown while what was chosen is made ready (library.js uploadProgress) ---------- */
.upload-progress {
  width: min(480px, calc(100vw - 32px));
  padding: 22px 22px 18px;
}
.upload-progress::backdrop {
  background: rgb(10 10 20 / 0.55);
  backdrop-filter: blur(3px);
}
.up-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.up-head h2 {
  flex: 1;
  margin: 0;
  font-size: 17px;
}
.up-bar {
  height: 6px;
  margin: 14px 0 12px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.up-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--grad);
  transition: width 0.4s ease;
}
.up-list {
  display: grid;
  gap: 6px;
  max-height: min(46vh, 340px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.up-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.up-row.waiting {
  opacity: 0.6;
}
.up-row.working {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.up-icon,
.up-mark {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
}
.up-text {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 1px;
}
.up-name {
  overflow: hidden;
  font-weight: 600;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.up-state {
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.up-row.done .up-mark {
  color: var(--good);
}
.up-row.failed .up-mark,
.up-row.failed .up-state {
  color: var(--bad);
}
.up-stage {
  margin: 12px 0 0;
  line-height: 1.5;
}
.up-stage.live {
  color: var(--accent-text);
  font-weight: 600;
}

/* ---------- the row of tabs over a document: one page each, and a + to add more (exam.js renderSet) ---------- */
.doc-tab {
  position: relative;
}
.doc-tab-x {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0 -6px 0 0;
  border-radius: 6px;
  opacity: 0;
}
.doc-tab:hover .doc-tab-x,
.doc-tab-x:focus-visible,
html.touch-ui .doc-tab-x {
  opacity: 0.75;
}
.doc-tab-x:hover {
  opacity: 1;
  background: var(--surface-3);
}
.doc-tab-add {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 30px;
  height: 28px;
  margin: 0 0 4px 2px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.doc-tab-add:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.doc-tab-add.busy {
  color: var(--accent-text);
  cursor: progress;
}
.doc-tab-add.busy .icon {
  animation: spin 0.9s linear infinite;
}
.doc-tab-add-label:empty {
  display: none;
}


/* ---------- 형광펜 on slides, Word pages and the reading view (sourceview.js paintMarks) ---------- */
::highlight(study-yellow) {
  background-color: rgb(255 224 74 / 0.6);
}
::highlight(study-green) {
  background-color: rgb(134 224 154 / 0.6);
}
::highlight(study-pink) {
  background-color: rgb(255 158 196 / 0.6);
}
.pane.marking .source-cover {
  cursor: text;
}

/* ---------- the app's own small browser (webbrowse.js) ---------- */
.app-dialog.web-browser {
  width: min(1180px, calc(100vw - 24px));
  max-width: none;
  height: min(860px, calc(100dvh - 24px));
  max-height: none;
  padding: 0;
  overflow: hidden;
}
.app-dialog.web-browser[open] {
  display: flex;
  flex-direction: column;
}
.wb-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.wb-form {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wb-address {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  font-size: 14px;
}
.wb-go {
  flex: none;
  gap: 5px;
}
.wb-side {
  flex: none;
  white-space: nowrap;
}
.wb-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.wb-view {
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: var(--surface);
}
.wb-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.wb-note {
  display: grid;
  gap: 8px;
  max-width: 560px;
  margin: 12vh auto 0;
  padding: 0 24px;
  line-height: 1.6;
  text-align: center;
  justify-items: center;
}
.wb-note p {
  margin: 0;
}
/* The start page's search box, in the middle as on a search site (webbrowse.js). */
.wb-home-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(100%, 520px);
  margin: 10px 0 14px;
  padding: 6px 6px 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.12);
}
.wb-home-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.wb-home-icon {
  display: inline-flex;
  color: var(--muted);
}
.wb-home-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 16px;
  box-shadow: none;
  outline: none;
}
.wb-home-input:focus {
  box-shadow: none;
  outline: none;
}
.wb-home-go {
  flex: none;
  border-radius: 999px;
  padding-inline: 18px;
}
.wb-video {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px;
}
.wb-video iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 10px;
  background: #000;
}
.wb-video h2 {
  margin: 14px 0 4px;
  font-size: 18px;
}
.wb-video p {
  margin: 0 0 4px;
}
.wb-links {
  flex: none;
  width: 280px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--surface-2);
}
.wb-links[hidden] {
  display: none;
}
.wb-links-head {
  flex: none;
  display: grid;
  gap: 6px;
  padding: 10px 10px 8px;
  font-size: 12.5px;
}
.wb-filter {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
}
.wb-links-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 6px 10px;
}
.wb-link {
  display: grid;
  gap: 1px;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}
.wb-link:hover {
  background: var(--surface-3);
}
.wb-link-text {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.wb-link-site {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wb-none {
  padding: 8px;
}
.source-browse {
  flex: none;
  white-space: nowrap;
}
@media (max-width: 760px) {
  .app-dialog.web-browser {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
  }
  /* Buttons on one line with the close button, the address on the line under them. */
  .wb-bar {
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
  }
  .wb-form {
    order: 5;
    flex-basis: 100%;
  }
  .wb-side {
    padding-inline: 8px;
  }
  .wb-side .wb-side-label {
    display: none;
  }
  .wb-go {
    margin-left: auto;
  }
  .wb-body {
    flex-direction: column;
  }
  .wb-links {
    width: auto;
    max-height: 34vh;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}


/* ---------- the level slider's motion (levelpicker.js) ---------- */
/* The knob settles on a stop with a small spring; the colour behind it follows the same way. */
.level-sheet .ms-knob {
  transition:
    left 0.36s cubic-bezier(0.34, 1.4, 0.5, 1),
    transform 0.16s ease,
    box-shadow 0.16s ease;
}
.level-sheet .ms-fill {
  transition:
    width 0.36s cubic-bezier(0.34, 1.4, 0.5, 1),
    background-color 0.2s ease;
}
/* Held: the knob grows a little. Dragged: it stays under the finger, without easing. */
.level-sheet.pressing .ms-knob {
  transform: scale(1.08);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.28);
}
.level-sheet.dragging .ms-knob {
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease;
}
.level-sheet.dragging .ms-fill {
  transition: background-color 0.2s ease;
}
.level-sheet .ms-dot {
  transition:
    background-color 0.25s ease,
    opacity 0.25s ease;
}
.level-sheet .ls-stop {
  transition:
    color 0.2s ease,
    transform 0.2s ease;
}
.level-sheet .ls-stop.on,
.level-sheet .ls-stop.near {
  transform: translateX(-50%) scale(1.08);
}
.level-sheet .ls-stop.near {
  color: var(--ink);
}
/* The level's name, when it changes: the new words slide in. */
.level-sheet .ms-name.swap {
  animation: level-swap 0.24s ease-out;
}
@keyframes level-swap {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}
/* Opening under its button: it drops down out of it. Closing: a short fade. */
.level-sheet.from-below {
  animation: level-drop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes level-drop {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
}
.level-sheet.closing {
  animation: level-out 0.14s ease-in forwards;
  pointer-events: none;
}
@keyframes level-out {
  to {
    opacity: 0;
    transform: scale(0.96);
  }
}
@media (prefers-reduced-motion: reduce) {
  .level-sheet,
  .level-sheet * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- pictures from the web in an answer (util.js webPictures) ---------- */
.web-pictures {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
}
.web-pictures.one {
  grid-template-columns: minmax(0, 340px);
}
.web-pictures figure {
  display: grid;
  gap: 4px;
  margin: 0;
  min-width: 0;
}
.web-pictures img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--surface-2);
  cursor: zoom-in;
}
.web-pictures.one img {
  object-fit: contain;
  max-height: 320px;
}
.web-pictures figcaption {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.web-pictures figcaption a {
  color: inherit;
  font-weight: 650;
}
.web-picture-wait {
  height: 130px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: picture-wait 1.2s ease-in-out infinite;
}
@keyframes picture-wait {
  to {
    background-position: -200% 0;
  }
}
.web-pictures-none {
  margin: 0;
}

/* (several pictures: an even grid of the same shape; one picture: as it is) */
.web-pictures:not(.one) img {
  aspect-ratio: 4 / 3 !important;
  height: auto;
  max-height: none;
}
.web-pictures:not(.one) {
  grid-template-columns: repeat(auto-fill, minmax(140px, 180px));
}

/* The level button lights up under the mouse and while its slider is open, as the "+" and
   손글씨 beside it do (the box's own rules gave it a plain background that hid the hover). */
.composer-pickers .level-dd,
.slot-pickers .level-dd {
  transition:
    background-color 0.12s,
    color 0.12s;
}
@media (hover: hover) {
  html:not(.touch-ui) .composer-pickers .level-dd:hover {
    background: var(--surface-3);
    color: var(--ink);
  }
}
html:not(.touch-ui) .composer-pickers .level-dd[aria-expanded="true"] {
  background: var(--surface-3);
  color: var(--ink);
}

/* ---------- tester links in the operator's account panel (account.js testerCard) ---------- */
.tester-make {
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tester-make .tester-name {
  flex: 1;
  min-width: 140px;
}
.tester-make .tester-tries {
  width: 64px;
}
.tester-make input {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}
.tester-list {
  margin-top: 10px;
}
.tester-actions {
  display: inline-flex;
  gap: 10px;
  flex: none;
}

/* The title and its status ("문서 파악 중…") keep room beside the reading tools on a wide
   screen: when the tools with their names would crowd them out, the tools show icons only
   (they are named in their tips). */
.top-left {
  container: topleft / inline-size;
}
/* (the tools with their names need up to about 560px in English with the highlighter's
   colours showing, and the title 180px beside them. The
   selectors are long so that they win over "names shown on a wide screen" above.) */
@container topleft (max-width: 760px) {
  html:not(.touch-ui) .study .top-left > .top-tools .tool-label {
    display: none;
  }
  html:not(.touch-ui) .study .top-left > .top-tools .tool {
    padding: 8px 10px;
  }
}
.top-left > .top-id {
  min-width: 170px;
}

/* The web search switch in the message box's bar, while it is on (chat.js webBtn). */
.composer-bar > .web-btn {
  gap: 5px;
  white-space: nowrap;
}
.composer-bar > .web-btn[hidden] {
  display: none;
}
html.touch-ui .composer-bar > .web-btn {
  width: auto;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
}

.media-save {
  flex: none;
  gap: 5px;
  white-space: nowrap;
}
@media (max-width: 520px) {
  .media-save .icon + * {
    display: none;
  }
}

/* ---------- the small player, as YouTube's (miniplayer.js) ---------- */
.mini-player {
  position: fixed;
  z-index: 70;
  user-select: none;
  -webkit-user-select: none;
}
.mini-stage {
  position: absolute;
  inset: 0;
  background: #000;
}
.mini-stage .media-frame,
.mini-stage .media-el {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  border: 0;
  background: #000;
}
.mini-player.audio .mini-stage .media-el {
  display: none; /* (a recording shows nothing: its controls are the player) */
}

/* Computers: a floating player, 16:9 with the title under it, in the lower right corner. */
.mini-player.pc {
  width: 400px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.38), 0 0 0 1px rgb(255 255 255 / 0.06);
  overflow: hidden;
}
.mini-player.pc .mini-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}
.mini-player.pc.audio .mini-screen {
  aspect-ratio: auto;
  height: 96px;
  background: var(--surface-3);
}
.mini-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  cursor: grab;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0.45), rgb(0 0 0 / 0) 34%, rgb(0 0 0 / 0) 60%, rgb(0 0 0 / 0.62));
  opacity: 0;
  transition: opacity 0.15s ease;
}
.mini-player.pc:not(.touch):hover .mini-layer,
.mini-player.pc.moving .mini-layer,
.mini-player.pc.audio .mini-layer,
.mini-player.pc:not(.touch) .mini-layer:focus-within {
  opacity: 1;
}
.mini-player.moving,
.mini-player.moving .mini-layer {
  cursor: grabbing;
}
.mini-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.42);
  color: #fff;
  cursor: pointer;
}
.mini-round:hover {
  background: rgb(0 0 0 / 0.62);
}
.mini-layer .mini-expand {
  position: absolute;
  top: 8px;
  left: 8px;
}
.mini-layer .mini-close {
  position: absolute;
  top: 8px;
  right: 8px;
}
.mini-layer .mini-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
}
.mini-bottom {
  position: absolute;
  inset: auto 8px 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
}
.mini-skip {
  flex: none;
  padding: 2px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.mini-skip:hover {
  background: rgb(255 255 255 / 0.18);
}
.mini-seek {
  flex: 1;
  min-width: 0;
  height: 14px;
  accent-color: #f00;
  cursor: pointer;
}
.mini-time {
  flex: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mini-corner {
  position: absolute;
  z-index: 2;
  width: 16px;
  height: 16px;
}
.mini-corner.nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}
.mini-corner.se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}
.mini-corner.ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}
.mini-corner.sw {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
}
.mini-info {
  display: grid;
  gap: 1px;
  padding: 8px 12px 10px;
}
.mini-info .mini-title {
  overflow: hidden;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.mini-info .mini-title:hover {
  text-decoration: underline;
}
.mini-sub {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Phones and tablets: the same player, made for fingers: a tap shows the controls for a moment
   (.show), larger buttons, going back and forth beside play, and the size button by the time line.
   The title under it is left out (the picture says what it is), and dragging it never scrolls the page. */
.mini-player.touch {
  touch-action: none;
}
.mini-player.touch .mini-screen {
  container-type: inline-size;
}
.mini-player.touch.video .mini-info {
  display: none;
}
.mini-player.touch.audio .mini-screen {
  height: 136px;
}
.mini-player.touch.show .mini-layer {
  opacity: 1;
}
/* (hidden controls cannot be pressed: the first tap only shows them; nor can they while a finger
   holds the picture, so a second finger that lands on one makes it larger or smaller) */
.mini-player.touch:not(.show):not(.audio) .mini-layer > *,
.mini-player.touch.held .mini-layer > * {
  pointer-events: none;
}
/* (a YouTube player that had to load again and waits for a tap on its own play button: the
   picture is YouTube's until it plays; back and ✕ stay) */
.mini-player.needs-tap .mini-layer {
  pointer-events: none;
  background: none;
  opacity: 1;
}
.mini-player.needs-tap .mini-layer > * {
  visibility: hidden;
}
/* (as specific as the phone rules above that turn the controls off, and after them, so it wins) */
.mini-player.pc.needs-tap:not(.held) .mini-layer > .mini-expand,
.mini-player.pc.needs-tap:not(.held) .mini-layer > .mini-close {
  visibility: visible;
  pointer-events: auto;
}
/* (the side panel opened on a phone goes over it) */
html.touch-ui #app.side-open ~ .mini-player {
  z-index: 59;
}
.mini-player.touch .mini-round {
  width: 36px;
  height: 36px;
}
.mini-player.touch .mini-layer .mini-expand {
  top: 6px;
  left: 6px;
}
.mini-player.touch .mini-layer .mini-close {
  top: 6px;
  right: 6px;
}
.mini-middle {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 14px;
  transform: translate(-50%, -50%);
}
.mini-player.touch .mini-middle .mini-play {
  position: static;
  width: 48px;
  height: 48px;
  transform: none;
}
.mini-player.touch .mini-skip {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.42);
  font-size: 12px;
}
.mini-player.touch .mini-bottom {
  inset: auto 6px 4px 8px;
  gap: 8px;
}
.mini-player.touch .mini-seek {
  height: 24px;
}
.mini-player.touch .mini-size {
  width: 30px;
  height: 30px;
}
/* (a small player keeps only play, the time line and its size) */
@container (max-width: 259px) {
  .mini-player.touch .mini-skip,
  .mini-player.touch .mini-time {
    display: none;
  }
  .mini-player.touch .mini-middle .mini-play {
    width: 42px;
    height: 42px;
  }
}

/* Settings: one block for each job with a level of its own (main.js openSettings). */
.ai-blocks {
  display: grid;
  gap: 18px;
  margin-bottom: 10px;
}
.ai-block {
  display: grid;
  gap: 8px;
}
.ai-block .level-row,
.ai-block .level-mix {
  margin: 0;
}

/* The app's browser: results of the site's own search (webbrowse.js). */
.wb-results {
  display: grid;
  gap: 4px;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 20px 40px;
}
.wb-result {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}
.wb-result:hover {
  background: var(--surface-2);
}
.wb-result-title {
  color: var(--accent);
  font-size: 15px;
}
.wb-result-text {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}

/* A dialog's buttons (취소 · 저장) keep to the bottom edge of the dialog while it scrolls,
   in full: the dialog itself is what scrolls, so a negative offset left part of them out of sight. */
.dialog-actions {
  bottom: 0;
}
@media (max-width: 760px) {
  .dialog-actions {
    bottom: 0;
  }
}

/* Settings on a phone: each AI level is one row of five short buttons (the line under the row
   says what the chosen level is), so the dialog is not three screens long. */
@media (max-width: 560px) {
  .level-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }
  .level-opt {
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 6px 2px;
    text-align: center;
  }
  .level-opt b {
    font-size: 13px;
    line-height: 1.25;
    word-break: keep-all;
  }
  .level-opt span {
    display: none;
  }
}

/* A document's tab just pressed: shown as the open one while its screen gets ready (exam.js renderSet). */
.doc-tab.opening {
  color: var(--ink);
  background: var(--surface-2);
}

/* A web page, video or file shown as itself: the pages of text under it are kept out of sight
   until it is in place, so switching to its tab does not flash them first (exam.js). */
.pane.cover-pending .pdf-container {
  visibility: hidden;
}

/* 번역: a transcript line's translation under it, and under the line being said (sourceview.js). */
.media-translate {
  flex: none;
  gap: 5px;
  white-space: nowrap;
}
.media-translate.on {
  color: var(--accent);
  background: var(--accent-soft);
}
.script-tr {
  grid-column: 2;
  margin-top: 4px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
}
/* (with translations on, the line it translates steps back a little) */
.media-script.translating .script-row .script-text {
  color: var(--muted);
  font-size: 14px;
}
.media-script:not(.translating) .script-tr {
  display: none;
}
.script-tr.waiting {
  opacity: 0.5;
}
@media (max-width: 520px) {
  .media-translate span {
    display: none;
  }
}

/* The in-app browser's saved pages: ☆ in its bar, and the list on its start page (webbrowse.js). */
.wb-save[aria-pressed="true"] {
  color: #f5b300;
}
.wb-save[aria-pressed="true"] svg {
  fill: currentColor;
}
/* The start page's shortcuts, as on a search site's: round tiles with the site's letter and
   its name under it, four to a row, two rows at most, + at the end (webbrowse.js). */
.wb-saved {
  width: min(100%, 520px);
  margin: 4px 0 14px;
}
.wb-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 4px;
}
.wb-tile {
  position: relative;
  min-width: 0;
}
.wb-tile-open {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 4px 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.wb-tile-open:hover,
.wb-tile-open:focus-visible {
  background: var(--surface-2);
}
.wb-tile-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: hsl(var(--tile-hue, 250) 55% 92%);
  color: hsl(var(--tile-hue, 250) 60% 34%);
  font-size: 18px;
  font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  .wb-tile-mark {
    background: hsl(var(--tile-hue, 250) 30% 24%);
    color: hsl(var(--tile-hue, 250) 80% 80%);
  }
}
.wb-tile-add .wb-tile-mark {
  background: var(--surface-2);
  color: var(--ink);
}
.wb-tile-name {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12.5px;
}
.wb-tile-x {
  position: absolute;
  top: 2px;
  right: 6px;
  width: 22px;
  height: 22px;
  opacity: 0;
}
.wb-tile:hover .wb-tile-x,
.wb-tile-x:focus-visible,
html.touch-ui .wb-tile-x {
  opacity: 1;
}
.wb-add {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.wb-add .prompt-input {
  height: 38px;
  padding: 0 12px;
  font-size: 14px;
}
.wb-add-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
/* The search box over the results, to search again. */
.wb-home-search.compact {
  width: 100%;
  max-width: none;
  margin: 0 0 16px;
}

/* 음성: the translations read aloud (dub.js). */
.media-dub {
  flex: none;
  gap: 5px;
  white-space: nowrap;
}
.media-dub.on {
  color: var(--accent);
  background: var(--accent-soft);
}
@media (max-width: 520px) {
  .media-dub span {
    display: none;
  }
}

/* 음성's loudness, beside it while it is on (sourceview.js). */
.media-dub-volume {
  flex: none;
  width: 76px;
  accent-color: var(--accent);
  cursor: pointer;
}
.media-dub-volume[hidden] {
  display: none;
}
@media (max-width: 520px) {
  .media-dub-volume {
    width: 54px;
  }
}

/* 자료 찾기: what the AI found for a request on the 공부 page, to pick from (library.js). */
.find-btn {
  gap: 5px;
}
.find-btn[hidden] {
  display: none;
}
.find-results {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  text-align: left;
}
.find-results[hidden] {
  display: none;
}
.find-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.find-for {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.find-close {
  margin-left: auto;
}
.find-ask,
.find-none {
  margin: 8px 0 4px;
}
.find-list {
  display: grid;
  gap: 2px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.find-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 6px;
  border-radius: 10px;
}
.find-item:hover {
  background: var(--surface-2);
}
.find-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding-top: 2px;
  cursor: pointer;
}
.find-check {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}
.find-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 54px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.find-kind.pdf {
  color: #e0574f;
}
.find-kind.video {
  color: #d64545;
}
.find-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.find-title {
  color: var(--accent-text);
  font-weight: 600;
  overflow-wrap: anywhere;
  text-decoration: none;
}
.find-title:hover {
  text-decoration: underline;
}
.find-why {
  color: var(--ink-2);
}
.find-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* 음성: a woman's voice or a man's (sourceview.js), beside it while it is on. */
.media-dub-kind {
  flex: none;
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.media-dub-kind[hidden] {
  display: none;
}
.media-dub-kind button {
  appearance: none;
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.media-dub-kind button[aria-checked="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

/* 음성 getting the first line's voice ready, the video waiting a moment for it (dub.js hold). */
.media-dub.waiting {
  animation: dub-waiting 1s ease-in-out infinite alternate;
}
@keyframes dub-waiting {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.45;
  }
}

/* A PDF looked through in the app's browser before it is chosen (webbrowse.js showPdf). */
.wb-pdf {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 12px;
}
.wb-pdf-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  width: 100%;
  max-width: 900px;
}
.wb-pdf-page {
  display: block;
  max-width: 100%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(20 20 40 / 0.18);
}
/* A page shown as it is, with a way out to a new tab above it when it does not show well (webbrowse.js). */
.wb-live {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.wb-live .wb-frame {
  flex: 1;
  min-height: 0;
  height: auto;
}
.wb-hint {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}

/* The line over a page that shows next to nothing here, pointing to the reading view (webbrowse.js). */
.wb-hint.broken {
  gap: 8px 10px;
  padding: 10px 12px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 13.5px;
}
.wb-hint.broken > span {
  flex: 1 1 260px;
}
.wb-side.nudge {
  animation: wb-nudge 1.1s ease-in-out 4;
  box-shadow: 0 0 0 2px var(--accent);
}
@keyframes wb-nudge {
  50% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent);
  }
}

/* The 공부 page's AI로 자료 찾기 card: lit while the box is set to look for material (library.js). */
.study-slot.find-slot.on {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}
.study-slot.find-slot.off {
  opacity: 0.5;
}

/* The 공부 page's box before there is material or a search: it takes no typing (library.js). */
.home-box.locked .composer-input {
  cursor: default;
}
.home-box.locked {
  opacity: 0.85;
}
.study-slot.call {
  animation: slot-call 1.2s ease;
}
@keyframes slot-call {
  20%,
  60% {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
  }
}

/* 음성 for an account without credits: the button says it is locked, the menu why (sourceview.js). */
.media-dub.locked {
  opacity: 0.7;
}
.pop-menu.dub-locked {
  max-width: 280px;
}
.pop-menu .pop-note {
  padding: 8px 12px 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}
/* Why the translations or the voice stopped, above the lines until closed (sourceview.js). */
.script-notice {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 860px;
  margin: 0 auto 8px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-size: 14px;
}
.script-notice-text {
  flex: 1;
  min-width: 0;
}
.script-notice .btn {
  flex: none;
}
.script-notice-x {
  flex: none;
}

/* 번역 that stopped asking (free uses or credits ran out, or the AI could not be reached): pressed, it asks again. */
.media-translate.on.stopped {
  opacity: 0.75;
  border-style: dashed;
}

/* 번역 as subtitles: a YouTube video's line over it, a video file's own track (sourceview.js). */
.media-stage {
  position: relative;
}
.media-sub {
  position: absolute;
  left: 50%;
  bottom: 48px;
  z-index: 2;
  transform: translateX(-50%);
  /* (as wide as its words, up to most of the video: a sentence or two, two lines at most) */
  width: max-content;
  max-width: min(84%, 760px);
  padding: 2px 10px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: clamp(13px, 1.15vw, 17px);
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  pointer-events: none;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.media-sub[hidden] {
  display: none;
}
.media-el::cue {
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 80%;
}
.media-stage:fullscreen {
  background: #000;
}
.media-stage:fullscreen .media-frame,
.media-stage:fullscreen .media-el {
  max-width: none;
}
.media-stage:fullscreen .media-sub {
  bottom: 64px;
  max-width: min(80%, 1100px);
  font-size: clamp(16px, 1.6vw, 28px);
}
.media-fs {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}
.media-stage:hover .media-fs,
.media-fs:focus-visible {
  opacity: 1;
}
@media (hover: none) {
  .media-fs {
    opacity: 0.85;
  }
}
/* 번역만 보기: a line's original hidden once its translation is there. */
.media-script.translating.tr-only .script-row:has(.script-tr:not(.waiting)) .script-text {
  display: none;
}
.media-script.translating.tr-only .script-tr {
  margin-top: 0;
}
/* On a phone the bar keeps 음성 and 번역 as buttons: the voice and its loudness are in 음성's menu. */
@media (max-width: 600px) {
  .media-caption .media-dub-kind,
  .media-caption .media-dub-volume {
    display: none;
  }
  .media-caption {
    gap: 4px;
  }
}
.pop-menu.dub-menu {
  min-width: 220px;
}
.dub-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px 10px;
}
.dub-controls .media-dub-volume {
  width: 100%;
}

/* 다시 분석, over the sections of the panel beside the document (exam.js). */
.side-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.side-tools[hidden] {
  display: none;
}
.side-analysed {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.redo-btn {
  flex: none;
  gap: 5px;
}
.pop-menu.redo-menu {
  width: min(340px, calc(100vw - 24px));
}
.redo-card {
  display: grid;
  gap: 6px;
}
.redo-card .seg {
  display: flex;
}
.redo-card .seg .seg-btn {
  flex: 1;
}
.redo-cost {
  margin: 4px 0 0;
  line-height: 1.45;
}
/* 자료 찾기: 다른 자료 찾기 in the card's head. */
.find-head .find-more {
  margin-left: auto;
  gap: 5px;
}
.find-head .find-more + .find-close {
  margin-left: 0;
}

/* A web page shown as itself: back, forward, again, and the way back to the analysed page (sourceview.js). */
.source-nav {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.source-nav[hidden] {
  display: none;
}
.source-nav .icon-btn:disabled {
  opacity: 0.35;
}
.source-from.away {
  opacity: 0.6;
  text-decoration: line-through;
}
.source-home {
  flex: none;
  gap: 5px;
  white-space: nowrap;
}
.source-home[hidden] {
  display: none;
}
@media (max-width: 600px) {
  .source-home span,
  .source-home .icon + * {
    display: none;
  }
  .source-nav .icon-btn {
    width: 30px;
  }
}

/* The level slider, small, inside a card (다시 분석: levelpicker.js levelSlider). */
.level-mini .ms-track {
  height: 32px;
  box-shadow: inset 0 0 0 4px var(--surface-2);
}
.level-mini .ms-fill {
  inset: 4px auto 4px 4px;
}
.level-mini .ms-knob {
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
}
.level-mini .ms-dot {
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
}
.level-mini .ls-stops {
  height: 20px;
  margin-top: 2px;
}
.level-mini .ls-stop {
  padding: 1px 4px;
  font-size: 12px;
}

/* 자료 찾기: the language a result is in (library.js). */
.find-lang {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 18px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
}

/* 단원별로 나누기: the card in the panel beside the document (exam.js). */
.split-card {
  display: grid;
  gap: 10px;
}
.split-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.split-card p {
  margin: 0;
  line-height: 1.55;
}
.split-wait {
  display: flex;
  align-items: center;
  gap: 8px;
}
.split-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.split-part {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.split-part:hover {
  background: var(--surface-2);
}
.split-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.split-pages {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.split-remove {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
}
.split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.split-actions .btn {
  gap: 6px;
}

/* 자료 찾기: a PDF too large to add, offered to be read in a browser (library.js). */
.find-big {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

/* The 공부 page's own words (its heading, description, the cards under the box, the list of
   documents) are not for selecting or copying. What is typed in the box is, and so is the
   footer with the site's terms and business details. (library.js) */
.library {
  -webkit-user-select: none;
  user-select: none;
}
.library input,
.library textarea,
.library [contenteditable="true"],
.library .site-footer {
  -webkit-user-select: text;
  user-select: text;
}

/* A large video with something drawn over it (the translation's subtitle line, the full-screen
   button) makes Chrome on Windows flash the whole screen: it keeps handing the video to the
   graphics card as a plane of its own and taking it back. A frame that is not fully opaque is
   never handed over, so it never switches (99.9% shows no difference). (sourceview.js) */
.media-stage .media-frame,
.media-stage .media-el {
  opacity: 0.999;
}
.media-sub,
.media-fs {
  will-change: transform;
}

/* A phone with translations on: the bar under the player says the line in the translation. */
.media-line.translated {
  color: var(--ink);
  font-weight: 600;
}

/* Each line of the transcript is in pieces of a sentence or two, each on a line of its own with
   the time it is said at, and the piece being said is marked: read as subtitles are (sourceview.js
   piecesOf). With the original shown too, each piece of the translation stands under the piece of
   the original said at about the same time (their order in the line is by time). */
.script-row.pieced {
  grid-template-columns: minmax(0, 1fr);
  padding-left: 9px;
}
.script-row.pieced > .script-time {
  display: none;
}
.script-row.pieced > .script-tr {
  grid-column: 1;
}
.piece {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  column-gap: 12px;
  margin: 0 -6px;
  padding: 2px 6px;
  border-radius: 6px;
}
/* (a line with a formula is typeset as a paragraph: it stays in its line, after the 화면 tag) */
.piece-text > p {
  display: inline;
  margin: 0;
}
.piece-time {
  padding-top: 2px;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}
.script-row.pieced.now {
  background: none;
  color: var(--ink-2);
}
.script-row.pieced.now .piece.now {
  background: var(--accent-soft);
  color: var(--ink);
}
.script-row.pieced.now .piece.now .piece-time {
  opacity: 1;
}
@media (max-width: 600px) {
  .piece {
    grid-template-columns: 44px minmax(0, 1fr);
    column-gap: 8px;
  }
}
.media-script.translating:not(.tr-only) .script-row.pieced > .script-text,
.media-script.translating:not(.tr-only) .script-row.pieced > .script-tr {
  display: contents;
}
.media-script.translating:not(.tr-only) .script-tr.pieced .piece {
  margin-bottom: 6px;
}
.media-script.translating:not(.tr-only) .script-tr.pieced .piece-time {
  visibility: hidden;
}

/* On a phone the bar under the player keeps its buttons only (the line being said is in the
   lines under it), and 음성 and 번역 are large, with their names, to be pressed easily;
   내려받기 is its icon alone. */
@media (max-width: 600px) {
  .media-caption {
    min-height: 54px;
    gap: 6px;
    padding: 0 8px;
  }
  .media-caption .media-now {
    display: none;
  }
  .media-caption .media-dub,
  .media-caption .media-translate {
    min-height: 42px;
    padding: 0 14px;
    gap: 6px;
    font-size: 14.5px;
    font-weight: 650;
  }
  .media-caption .media-dub > span {
    display: inline;
  }
  .media-caption .media-translate > .swap {
    display: inline-grid;
  }
  .media-caption .media-translate .swap > span {
    display: block;
  }
  .media-caption .media-dub .icon,
  .media-caption .media-translate .icon {
    width: 18px;
    height: 18px;
  }
  .media-caption .media-save {
    min-height: 42px;
    padding: 0 11px;
    gap: 0;
    font-size: 0;
  }
  .media-caption .media-save .icon {
    width: 18px;
    height: 18px;
  }
  .media-caption .media-side {
    min-height: 42px;
  }
}

/* A button whose name changes keeps one width: all its names stand in one place, the others
   unseen (sourceview.js swapLabel), so the buttons beside it never move when it is pressed. */
.swap {
  display: inline-grid;
}
.swap > span {
  grid-area: 1 / 1;
  text-align: center;
}
.swap > .off {
  visibility: hidden;
}
/* 음성's voice and loudness are in its menu, on a computer as on a phone: shown in the bar
   while it is on, they pushed the buttons beside it aside. */
.media-caption .media-dub-kind,
.media-caption .media-dub-volume {
  display: none;
}

/* The reading tools, where they stand on a row of their own or show their icons only (the
   window too narrow for more), stand in the middle: */
/* - a computer's narrower window: the second row of the top bar, between two equal spaces
     (the left one this, the right one the zoom buttons' side) */
@container study (max-width: 820px) {
  html:not(.touch-ui) .study:not(.no-doc) .topbar::before {
    content: "";
    order: 2;
    flex: 1 1 0;
  }
  html:not(.touch-ui) .study:not(.no-doc) .top-right {
    flex: 1 1 0;
  }
}
/* - a computer's wide window: the middle of the room between ← and the 공부/채팅 switch,
     whether the side panel is open or not (the room it keeps for the title and the state of
     the document beside ← is let go while neither is shown) */
html:not(.touch-ui) .study .top-left > .top-tools {
  margin-inline: auto;
}
html:not(.touch-ui) .study:not(.no-doc) .top-left > .top-id:not(:has(.top-info :is(.tag.bad, .tag.live, button))) {
  min-width: 0;
}
/* - a phone or tablet: the middle of their row, beside the zoom buttons (scrolled sideways
     from the left as before when they do not all fit) */
html.touch-ui .study .tool-row {
  margin-inline: auto;
}

/* The AI panel's ⋯ menu opens upward, leftward of ⋯, where there is room above it (chat.js openExport). */
.chat-menu-wrap > .chat-menu.up {
  top: auto;
  bottom: calc(100% + 6px);
}

/* The reading tools show their icons only, at every size (their names are in their tips,
   util.js hoverTip). The long selector wins over the sizes above that once showed names. */
html body .study .tool-row > .tool.tool {
  padding: 8px 10px;
  gap: 0;
}

/* A button's tip (util.js hoverTip): its name, and a line on what it does. */
.hover-tip {
  position: fixed;
  z-index: 400;
  max-width: 240px;
  display: grid;
  gap: 2px;
  padding: 8px 11px 9px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.22);
  font-size: 12.5px;
  line-height: 1.45;
  pointer-events: none;
  animation: tip-in 0.12s ease-out;
}
.hover-tip strong {
  font-size: 13px;
  font-weight: 700;
}
.hover-tip span {
  opacity: 0.78;
}
.hover-tip::before {
  content: "";
  position: absolute;
  top: -4px;
  left: calc(var(--arrow, 50%) - 5px);
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: inherit;
  transform: rotate(45deg);
}
.hover-tip.above::before {
  top: auto;
  bottom: -4px;
}
@keyframes tip-in {
  from {
    opacity: 0;
    transform: translateY(-2px);
  }
}

/* The chat page (a computer reading a document, pc-split): the video, and the bar under it, as
   wide as the column of lines under them (860 px, the transcript's rows), in the middle of the
   wide pane; larger only when made larger with the zoom buttons (sourceview.js: --media-max).
   The study page keeps the video across the whole pane. */
.study.pc-split .source-media {
  background: var(--surface);
}
.study.pc-split .media-stage,
.study.pc-split .source-media > .media-caption {
  width: 100%;
  max-width: var(--media-max, 860px);
  margin-inline: auto;
}
.study.pc-split .pane.media-beside .media-stage,
.study.pc-split .pane.media-beside .source-media > .media-caption {
  max-width: none;
}
/* (on the chat page the lines' scroll bar keeps the same room on both sides, so the column of
   lines stands in the middle exactly as the video over it does) */
.study.pc-split .media-script {
  scrollbar-gutter: stable both-edges;
}

/* The highlighter's colours: a small panel that drops down under its button while it is on
   (tools.js: .tool-drop), instead of standing in the row and pushing the other tools aside. */
.tool-drop {
  position: relative;
  display: inline-flex;
}
.tool-drop > .swatches {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 60;
  translate: -50% 0; /* (apart from transform, which the pop-in animation uses) */
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s ease-out;
}
/* (a phone's row of tools scrolls sideways, which would cut the panel off: while it is
   open the row lets it out; the tools, icons only, fit without scrolling) */
html.touch-ui .study .top-tools:has(.swatches:not([hidden])) {
  overflow: visible;
}

/* On a phone the bar under a video: 쪽으로 보기 / 시간별 글 too shows its icon alone (named for
   screen readers), and the bar is never wider than the screen (in English its names were, and
   the whole page slid sideways). */
@media (max-width: 600px) {
  .media-caption {
    overflow: hidden;
  }
  .media-caption .media-side {
    min-height: 42px;
    padding: 0 11px;
    gap: 0;
  }
  .media-caption .media-side > .swap {
    display: none;
  }
  .media-caption .media-side .icon {
    width: 18px;
    height: 18px;
  }
}
@media (max-width: 380px) {
  .media-caption .media-dub,
  .media-caption .media-translate {
    padding: 0 10px;
  }
}
/* A menu is never wider than the screen: a long choice goes on to a second line. */
.pop-menu {
  max-width: calc(100vw - 16px);
}
.pop-menu .chat-menu-item {
  white-space: normal;
  padding-block: 7px;
}

/* On a phone the buttons under a video stand together in the middle of the bar. */
@media (max-width: 600px) {
  .media-caption {
    justify-content: center;
  }
}

/* Loading. 번역 and 음성 show a spinner in their icon's place while translations, or the voice
   of the line being said, are on their way (the button keeps its size: sourceview.js .btn-spin). */
.btn-spin {
  display: none;
  flex: none;
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.media-translate.busy > .icon,
.media-dub.waiting > .icon {
  display: none;
}
.media-translate.busy > .btn-spin,
.media-dub.waiting > .btn-spin {
  display: inline-block;
}
.media-dub.waiting {
  animation: none;
}
@media (max-width: 600px) {
  .media-caption .btn-spin {
    width: 18px;
    height: 18px;
  }
}
/* A line whose translation is on its way: "번역하는 중…", breathing. */
.script-tr.waiting {
  color: var(--muted);
  font-size: 14px;
  animation: tr-wait 1.1s ease-in-out infinite alternate;
}
@keyframes tr-wait {
  from {
    opacity: 0.4;
  }
  to {
    opacity: 0.9;
  }
}
/* The video stopped a moment for the voice of the line being said (dub.js hold). */
.media-wait {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 3;
  translate: -50% 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.72);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  animation: pop-in 0.15s ease-out;
}
.media-wait .spinner {
  border-color: rgb(255 255 255 / 0.3);
  border-top-color: #fff;
}

/* On a phone the reading tools and zoom stand in a row of their own under the tabs (exam.js
   placeTools), so the tabs stay right under the top bar whether the pages or the AI chat are
   shown; the row goes while the AI chat is shown. */
.tool-strip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.study.phone-chat .tool-strip,
.study.no-doc .tool-strip {
  display: none;
}
@media (max-width: 699px) {
  html.touch-ui .study .topbar::after {
    display: none;
  }
}

/* ====================================================================================
   글상자 (the T tool): typed text on the document
   ==================================================================================== */

.text-layer {
  position: absolute;
  inset: 0;
  z-index: 6; /* over the page's text and marks, under the reading tools' popups */
  pointer-events: none;
  container-type: inline-size; /* (letters are sized as a share of the page's width: they zoom with it) */
}
.pp-slide,
.docx-wrapper > section.docx {
  position: relative;
}
.text-box {
  position: absolute;
  pointer-events: auto;
  font-size: calc(var(--fs, 0.022) * 100cqw);
  line-height: 1.35;
  font-weight: 500;
  font-family: var(--font);
}
.text-box-text {
  min-width: 1.2em;
  min-height: 1.35em;
  padding: 0.1em 0.25em;
  border-radius: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
  cursor: text;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
.text-box:hover .text-box-text {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.text-box.editing .text-box-text {
  background: rgb(255 255 255 / 0.85);
  box-shadow: 0 0 0 1.5px var(--accent);
}
.text-box-text:empty::before {
  content: attr(data-placeholder);
  color: #9a9aa8;
}
/* The small bar over a box while it is written in: move it, delete it. */
.text-box-bar {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  display: none;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.text-box.editing .text-box-bar,
.text-box.moving .text-box-bar {
  display: inline-flex;
}
.text-box-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.text-box-btn:hover {
  background: var(--surface-2);
}
.text-box-grip {
  cursor: grab;
  touch-action: none;
}
.text-box.moving .text-box-grip {
  cursor: grabbing;
}
/* With T on, the pointer says where a box will start. */
.pane.texting .pdfViewer .page,
.pane.texting .pp-slide,
.pane.texting .docx-wrapper > section.docx {
  cursor: text;
}
.pane.texting .textLayer {
  pointer-events: none; /* (a press is for a new box, not for picking the words) */
}
/* Its colours and sizes, dropped down under T like the highlighter's colours. */
.tool-drop > .text-style {
  align-items: center;
}
.text-color {
  appearance: none;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--c);
  box-shadow: 0 0 0 1px var(--line-strong);
  cursor: pointer;
}
.text-color.active {
  box-shadow: 0 0 0 2px var(--accent);
}
.text-size {
  appearance: none;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.text-size.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}
@media print {
  .text-box-bar {
    display: none !important;
  }
  .text-box-text {
    background: none !important;
    box-shadow: none !important;
  }
}

@media (max-width: 400px) {
  .tool-drop > .text-style {
    gap: 5px;
    padding: 7px 8px;
  }
}

/* The smaller and bigger T in the bar over a text box. */
.text-box-size {
  font-family: var(--font);
  font-weight: 700;
  line-height: 1;
}
.text-box-size .t-small {
  font-size: 11px;
}
.text-box-size .t-big {
  font-size: 16px;
}
.text-box-size:disabled {
  opacity: 0.35;
  cursor: default;
}

/* A text box: pressed to move it, pressed twice to write in it. */
.text-box {
  touch-action: none; /* (a finger on a box moves it, not the page) */
  cursor: grab;
}
.text-box.moving {
  cursor: grabbing;
}
.text-box:not(.editing) .text-box-text {
  cursor: inherit;
  -webkit-user-select: none;
  user-select: none;
}
.text-box.selected:not(.editing) .text-box-text {
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 70%, transparent);
  background: rgb(255 255 255 / 0.55);
}
.text-box.selected .text-box-bar {
  display: inline-flex;
}

/* The model's name is not shown under answers. */
.msg-model {
  display: none !important;
}

/* A new material search with other words, beside 다른 자료 찾기. */
.find-again {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 2px 0 8px;
  background: var(--surface);
}
.find-again:focus-within {
  border-color: var(--accent);
}
.find-again-input {
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  width: 150px;
  min-width: 0;
  padding: 5px 0;
}
.find-again-go {
  width: 28px;
  height: 28px;
}
.find-head .find-again + .find-more {
  margin-left: 0;
}
.find-item.added .find-title::after {
  content: " ✓";
  color: var(--good, #16a34a);
}
@media (max-width: 560px) {
  .find-head {
    flex-wrap: wrap;
  }
  .find-again {
    order: 10;
    flex: 1 1 100%;
    margin-left: 0;
  }
  .find-again-input {
    width: auto;
    flex: 1;
  }
}

/* 근거: where in the passage a question's answer comes from, under its explanation. */
.evidence-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 4px;
}
.evidence-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.evidence-chip {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Full view on phones and tablets: only the page, with the tools and zoom over it. */
.zoom .full-btn {
  display: none;
}
html.touch-ui .zoom .full-btn {
  display: inline-grid;
}
.study.doc-full > .topbar,
.study.doc-full .doc-set,
.study.doc-full .workspace > :not(.pane) {
  display: none !important;
}
.study.doc-full .tool-strip {
  display: flex !important;
}
.study.doc-full .workspace > .pane {
  flex: 1 1 auto;
  width: 100% !important;
  max-width: none !important;
  display: flex !important;
}
html.doc-full-on .rail,
html.doc-full-on .app-rail,
html.doc-full-on .side-rail,
html.doc-full-on .mobile-top,
html.doc-full-on .mode-tabs {
  display: none !important;
}

/* Phones: the window that shows material being prepared fills the screen. */
@media (max-width: 640px) {
  .app-dialog.upload-progress {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  }
  .app-dialog.upload-progress .up-list {
    max-height: 45dvh;
    overflow: auto;
  }
}

/* 쪽 넣기: where, then what (a blank page, pictures, another PDF's pages). */
.add-pages .pages-where-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
}
.add-pages .pages-where {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}
.add-pages-kinds {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.add-pages-kind {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: center;
}
.add-pages-kind:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
@media (max-width: 420px) {
  .add-pages-kinds {
    grid-template-columns: 1fr;
  }
  .add-pages-kind {
    flex-direction: row;
    justify-content: flex-start;
    padding: 11px 12px;
  }
}

/* A table in an answer, with its "Excel로 저장" button. */
.table-wrap {
  position: relative;
  max-width: 100%;
  overflow-x: auto;
  margin: 8px 0 12px;
}
.table-wrap > table {
  margin: 0;
}
.table-excel {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.table-excel::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: #1d7a45;
  -webkit-mask: linear-gradient(#000 0 0) top / 100% 30%, linear-gradient(#000 0 0) bottom / 100% 60%;
  -webkit-mask-repeat: no-repeat;
}
.table-excel:hover {
  color: var(--text);
  border-color: #1d7a45;
}

/* Phones: the tool row has a lock now, so its buttons are a little narrower to keep the zoom in reach. */
@media (max-width: 420px) {
  .tool-strip .tool-row .tool {
    width: 31px;
    min-width: 31px;
  }
  .tool-strip .zoom .icon-btn {
    width: 25px;
    min-width: 25px;
  }
}
@media (max-width: 345px) {
  .tool-strip .tool-row .tool {
    width: 28px;
    min-width: 28px;
  }
  .tool-strip .zoom .icon-btn {
    width: 22px;
    min-width: 22px;
  }
}
html.doc-full-on .side-switch {
  display: none !important;
}

/* A smaller computer screen (study area 821–1100px): the bar stays one row, the reading tools
   left of the 공부/채팅 switch. The title steps aside (the document's tab under the bar names
   it); a state worth seeing (being analysed, a failure) still shows. */
@container study (max-width: 1100px) {
  html:not(.touch-ui) .study:not(.no-doc) .top-title {
    display: none;
  }
  html:not(.touch-ui) .study:not(.no-doc) .top-left > .top-id {
    min-width: 0;
    flex: 0 1 auto;
  }
  html:not(.touch-ui) .study:not(.no-doc) .top-left {
    gap: 4px;
  }
  html:not(.touch-ui) .study .top-left > .top-tools .tool {
    padding: 8px 9px;
  }
  html:not(.touch-ui) .study:not(.no-doc) .top-right {
    gap: 6px;
  }
}

/* 잠금 on each text box: the first button of its bar, and a small lock on a locked box. */
.text-box-lock[aria-pressed="true"] {
  color: var(--accent);
}
.text-box-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.text-box.locked {
  cursor: default;
}
.text-box-badge {
  display: none;
  position: absolute;
  top: -7px;
  right: -7px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 0 0 1px var(--line);
  pointer-events: none;
}
.text-box.locked:not(.selected) .text-box-badge {
  display: grid;
}

/* A page put into a slide or Word view (쪽 넣기), shown after the slide or page it follows. */
.added-page {
  position: relative;
  margin: 12px auto;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.18), 0 0 0 1px rgb(0 0 0 / 0.06);
  max-width: 100%;
  container-type: inline-size;
}
.added-page-art {
  display: block;
  width: 100%;
  height: 100%;
}

/* 필기 on a page put into a slide or Word view: the pen writes there, the page does not scroll. */
.pane.inking .added-page {
  touch-action: none;
  cursor: crosshair;
}

/* "+ 쪽 넣기" at the bottom edge of the page under the pointer (exam.js watchPageAdder). */
.page-adder {
  position: fixed;
  z-index: 40;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px 5px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-text, var(--accent));
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.12);
  cursor: pointer;
}
.page-adder[hidden] {
  display: none;
}
.page-adder:hover {
  background: var(--accent-soft);
}

/* ====================================================================================
   AI 도우미: the helper that floats at the bottom left (agent.js)
   ==================================================================================== */
.agent {
  position: fixed;
  left: 10px;
  bottom: 72px;
  z-index: 70;
  font-size: 14px;
}
#app[data-view="plain"] ~ .agent,
html.doc-full-on .agent {
  display: none;
}
html.touch-ui .agent {
  bottom: calc(96px + env(safe-area-inset-bottom));
}
.agent-fab {
  appearance: none;
  position: relative;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgb(90 80 240 / 0.38), 0 1px 3px rgb(0 0 0 / 0.2);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.agent-fab:hover {
  transform: translateY(-1px) scale(1.04);
}
.agent-fab::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgb(120 110 250 / 0.55);
  opacity: 0;
  transform: scale(calc(1 + var(--agent-level, 0) * 0.35));
  transition: transform 0.08s linear, opacity 0.15s;
  pointer-events: none;
}
.agent-fab.live::after,
.agent.speaking .agent-fab::after {
  opacity: 1;
}
.agent-fab.busy .icon {
  animation: agent-think 1.1s ease-in-out infinite;
}
.agent.speaking .agent-fab::after {
  animation: agent-speak 1s ease-in-out infinite;
}
@keyframes agent-think {
  50% {
    transform: scale(0.78) rotate(40deg);
    opacity: 0.75;
  }
}
@keyframes agent-speak {
  50% {
    transform: scale(1.18);
    opacity: 0.4;
  }
}
.agent-panel {
  position: absolute;
  left: 0;
  bottom: 56px;
  width: min(380px, calc(100vw - 20px));
  height: min(540px, calc(100dvh - 150px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.22), 0 2px 8px rgb(0 0 0 / 0.1);
  overflow: hidden;
}
.agent-panel[hidden] {
  display: none;
}
.agent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
}
.agent-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-text, var(--accent));
}
.agent-title strong {
  color: var(--text);
  font-size: 14.5px;
}
.agent-head-btns {
  display: inline-flex;
  gap: 2px;
}
.agent-head-btn,
.agent-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.agent-head-btn:hover {
  background: var(--hover, rgb(0 0 0 / 0.06));
  color: var(--text);
}
.agent-settings {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}
.agent-settings[hidden] {
  display: none;
}
.agent-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
.agent-seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  flex: none;
}
.agent-seg-btn {
  appearance: none;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 9px;
  cursor: pointer;
}
.agent-seg-btn + .agent-seg-btn {
  border-left: 1px solid var(--line);
}
.agent-seg-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-text, var(--accent));
  font-weight: 600;
}
.agent-set-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.agent-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-msg {
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.agent-msg p {
  margin: 0;
}
.agent-msg.user {
  align-self: flex-end;
  background: var(--accent-soft);
  color: var(--text);
  border-bottom-right-radius: 5px;
}
.agent-msg.assistant {
  align-self: flex-start;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-bottom-left-radius: 5px;
}
.agent-hello {
  max-width: 100%;
  align-self: stretch;
  padding: 6px 2px;
  color: var(--muted);
}
.agent-tries {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.agent-try {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.agent-try:hover {
  border-color: var(--accent);
}
.agent-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 14px 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.agent-status[hidden] {
  display: none;
}
.agent-compose {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px 10px;
  border-top: 1px solid var(--line);
}
.agent-input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 7px 10px;
  max-height: 110px;
  outline: none;
}
html.touch-ui .agent-input {
  font-size: 16px; /* (a phone does not zoom the page in on it) */
}
.agent-input:focus {
  border-color: var(--accent);
}
.agent-btn {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 11px;
}
.agent-btn[hidden] {
  display: none;
}
.agent-mic {
  background: color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text);
}
.agent-mic.live {
  background: var(--bad, #e5484d);
  color: #fff;
}
.agent-send {
  background: var(--grad);
  color: #fff;
}
.agent-send:disabled {
  opacity: 0.4;
  cursor: default;
}
@media (max-width: 520px) {
  .agent {
    left: 8px;
  }
  .agent-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(150px + env(safe-area-inset-bottom));
    width: auto;
    height: min(480px, calc(100dvh - 220px));
  }
}

/* ====================================================================================
   Purple highlights, the same everywhere: the place the AI points to, words picked on a
   page, hits of a search, and the purple highlighter (the one in hand to begin with)
   ==================================================================================== */
.swatch.purple {
  background: #a78bfa;
}
.hl.purple {
  background: rgb(167 139 250 / 0.5);
}
::highlight(study-purple) {
  background-color: rgb(167 139 250 / 0.55);
}
.found-strip {
  background: rgb(138 92 246 / 0.3);
  box-shadow: 0 0 0 2px rgb(110 80 235 / 0.75);
}
@keyframes found-pulse {
  from {
    box-shadow: 0 0 0 10px rgb(110 80 235 / 0.3);
  }
}
.pick-strip {
  background: rgb(138 92 246 / 0.32);
}
.pdfViewer .textLayer ::selection {
  background: rgb(138 92 246 / 0.32);
}
.search-item mark {
  background: rgb(138 92 246 / 0.25);
}

/* ====================================================================================
   AI 도우미, in sight: a bigger button beside the profile, the pointer that shows what it
   presses, the steps it took, and the choices it offers
   ==================================================================================== */
.agent {
  left: var(--agent-left, 10px);
  bottom: 10px;
}
html.touch-ui .agent {
  left: 10px;
  bottom: calc(96px + env(safe-area-inset-bottom));
}
.agent-fab {
  width: 58px;
  height: 58px;
}
.agent-panel {
  bottom: 68px;
}
.agent-pointer {
  position: fixed;
  left: 50vw;
  top: 50vh;
  z-index: 2147483000;
  margin: -3px 0 0 -5px;
  color: #6d4df2;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.35));
  transition: left 0.4s cubic-bezier(0.22, 0.8, 0.3, 1), top 0.4s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.2s;
}
.agent-pointer.on {
  opacity: 1;
}
.agent-ring {
  position: fixed;
  z-index: 2147482999;
  border-radius: 10px;
  border: 2.5px solid #7c5cf6;
  box-shadow: 0 0 0 4px rgb(124 92 246 / 0.22);
  pointer-events: none;
  animation: agent-ring 0.9s ease-out forwards;
}
@keyframes agent-ring {
  0% {
    opacity: 0;
    transform: scale(1.12);
  }
  25% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}
.agent-steps {
  list-style: none;
  margin: 0;
  padding: 0 4px;
  display: grid;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
}
.agent-steps li {
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.agent-steps li::before {
  content: "✓";
  color: var(--accent-text, var(--accent));
  font-weight: 700;
  flex: none;
}
.agent-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 2px;
}
.agent-choices .agent-try {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent-text, var(--accent));
  font-weight: 600;
}

/* While the helper acts, its panel is a small strip (what it is doing, the last steps): the
   page it works on stays in sight. */
.agent.acting .agent-panel {
  width: min(300px, calc(100vw - 20px));
  height: auto;
  max-height: 170px;
}
.agent.acting .agent-head,
.agent.acting .agent-settings,
.agent.acting .agent-compose,
.agent.acting .agent-msg,
.agent.acting .agent-choices {
  display: none;
}
.agent.acting .agent-list {
  justify-content: flex-end;
  padding: 8px 12px 2px;
  max-height: 110px;
}
.agent.acting .agent-steps:not(:last-of-type) {
  display: none;
}
.agent.acting .agent-status {
  padding: 6px 12px 10px;
  color: var(--text);
  font-weight: 600;
}
@media (max-width: 520px) {
  .agent.acting .agent-panel {
    height: auto;
  }
}

/* "+ 쪽 넣기": the pointer is on the button whatever part of it it is over. */
.page-adder > * {
  pointer-events: none;
}

/* "+ 쪽 넣기" and "이 쪽 삭제", side by side at the bottom edge of a page. */
.page-adder {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  gap: 6px;
  cursor: default;
}
.page-adder:hover {
  background: transparent;
}
.page-adder > * {
  pointer-events: auto;
}
.page-adder-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 11px 5px 9px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-text, var(--accent));
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.12);
  cursor: pointer;
  white-space: nowrap;
}
.page-adder-btn > * {
  pointer-events: none;
}
.page-adder-btn[hidden] {
  display: none;
}
.page-adder-btn:hover {
  background: var(--accent-soft);
}
.page-adder-btn.danger {
  color: var(--bad, #e5484d);
  border-color: color-mix(in srgb, var(--bad, #e5484d) 40%, var(--line));
}
.page-adder-btn.danger:hover {
  background: color-mix(in srgb, var(--bad, #e5484d) 10%, var(--surface));
}

/* A translation kept on a passage: it shows over the words (a 뜻 풀이 under them), marked in green. */
.note-tip.over {
  border-left-color: #1d9a6c;
}
.hl.note.over {
  background: rgb(29 154 108 / 0.1);
  border-bottom: 0;
  border-top: 2px solid rgb(29 154 108 / 0.85);
  border-radius: 0 0 2px 2px;
}

/* ====================================================================================
   공부 page, AI 도우미 first (library.js): its mark on the left and, beside it, the box that
   takes what it is to do. The box for material stands under it, named by a small label.
   Cards under that box carry their names only. A phone's front page is the mark and the box.
   ==================================================================================== */
.agent-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 10px 0 0;
}
.agent-bar-icon {
  appearance: none;
  flex: none;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgb(90 80 240 / 0.34), 0 1px 3px rgb(0 0 0 / 0.18);
  transition: transform 0.12s ease, filter 0.15s;
}
.agent-bar-icon:hover {
  transform: translateY(-1px) scale(1.04);
  filter: brightness(1.06);
}
.agent-bar-box {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 10px 10px 14px;
  border-radius: 22px;
}
/* (the things it could be asked, typed out in grey while the box is empty: library.js suggestIdeas) */
.agent-bar-box .composer-input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}
.agent-bar-box .composer-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 38px;
  padding: 7px 4px;
  font-size: 16px;
}
.agent-bar-mic {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--ink-2);
}
.agent-bar-box .send-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}
.agent-bar-box .send-btn:disabled {
  opacity: 0.45;
}
.home-label {
  margin: 22px 4px 6px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
}
.library .home-label + .home-ask {
  margin-top: 0;
}
/* (a card with nothing in it: its name alone, a little larger, and not as tall) */
.library .study-slot {
  min-height: 54px;
}
.library .file-slot:not(.has-file):not(.on) .slot-label {
  font-size: 13.5px;
  color: var(--ink);
}

/* A narrow screen: the helper's panel stands over its button, not across it (the panel is
   fixed to the screen there, and the larger button had come to sit on its message box). */
@media (max-width: 520px) {
  .agent-panel {
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
  html.touch-ui .agent-panel {
    bottom: calc(164px + env(safe-area-inset-bottom));
  }
}

/* ====================================================================================
   Phones and tablets: one chat box. AI 도우미 has no button or panel of its own there: what
   is typed in the chat's box comes to it (chat.js send), and what it says and does is
   written in the chat itself, a block for each thing asked (agent.js newBlock).
   ==================================================================================== */
html.touch-ui .agent-fab,
html.touch-ui .agent-panel {
  display: none !important;
}
.agent-block {
  display: contents;
}
.agent-block .agent-steps,
.agent-block .agent-choices {
  align-self: stretch;
  margin: 0;
  padding-left: 4px;
}
.agent-block .agent-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.agent-block .agent-try {
  font-size: 14.5px;
  padding: 8px 14px;
}
.agent-block + .agent-status {
  align-self: flex-start;
  border: 0;
  background: none;
  padding: 2px 4px;
}

/* An empty card's one line under its name: small, quiet, and on one line so it fits the card. */
.library .file-slot:not(.has-file) .slot-value {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

/* 내 문서, under the folders: cards of the folders' size (the name and one line; how far a
   test is solved and what went wrong show once the document is open, or in a folder's sheet). */
.library .recent-docs .exam-progress,
.library .recent-docs .exam-error {
  display: none;
}
.library .recent-docs .exam-card > .muted.small {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.library .section-head.doc-head {
  margin-top: 14px;
}

/* ====================================================================================
   공부 page: the helper's chat opens at the top of the page, in place of its bar (library.js
   agent-dock, agent.js dock). Its floating button is not shown on this page, nor on an empty
   new chat; it is there wherever a document is open.
   ==================================================================================== */
.agent-dock {
  display: none;
  margin: 10px 0 0;
}
.library.agent-open .agent-dock {
  display: block;
}
.library.agent-open .agent-bar {
  display: none;
}
/* (the panel in the page is drawn further down: "the helper's card on the 공부 page") */
.agent.docked .agent-fab {
  display: none;
}
body:has(.study.no-doc .is-empty) .agent:not(.open) {
  display: none;
}

/* ====================================================================================
   자료 찾기, as it happens (findlive.js): a panel at the right of the screen while the search
   runs: each search and what it brought back, each page as it is opened (shown small), what
   was found there.
   ==================================================================================== */
.find-live {
  position: fixed;
  top: 68px;
  right: 14px;
  bottom: 14px;
  z-index: 60;
  width: min(350px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.2), 0 2px 8px rgb(0 0 0 / 0.08);
  overflow: hidden;
  font-size: 13px;
  animation: fl-in 0.22s ease;
}
@keyframes fl-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}
.fl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 10px 9px 14px;
  border-bottom: 1px solid var(--line);
}
.fl-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--accent-text, var(--accent));
}
.fl-title strong {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fl-close {
  flex: none;
  width: 26px;
  height: 26px;
}
.fl-request {
  padding: 8px 14px 0;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fl-view {
  margin: 10px 12px 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  flex: none;
}
.fl-view[hidden] {
  display: none;
}
.fl-view-box {
  position: relative;
  height: 178px;
  overflow: hidden;
  background: #fff;
}
/* (the page itself, drawn at a computer's width and shown small; it is looked at, not used) */
.fl-frame {
  width: 1080px;
  height: 594px;
  border: 0;
  transform: scale(0.3);
  transform-origin: 0 0;
  pointer-events: none;
  background: #fff;
}
.fl-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fl-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgb(0 0 0 / 0.18);
}
.fl-paper {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.fl-view-cap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1px 8px;
  align-items: center;
  padding: 7px 10px 8px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.fl-view-kind {
  grid-row: span 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--accent-text, var(--accent));
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 8px;
}
.fl-view-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fl-view-site {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fl-steps {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 8px 12px 14px;
  list-style: none;
  display: grid;
  align-content: start;
  gap: 7px;
}
.fl-step {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: start;
  animation: fl-step 0.2s ease;
}
@keyframes fl-step {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
.fl-dot {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
}
.fl-search.own .fl-dot,
.fl-stage .fl-dot {
  background: var(--accent-soft);
  color: var(--accent);
}
.fl-text {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  line-height: 1.45;
  padding-top: 2px;
}
.fl-stage .fl-text {
  font-weight: 600;
}
.fl-badge {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
}
.fl-search.own .fl-badge {
  color: var(--accent-text, var(--accent));
}
.fl-query {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.fl-count {
  font-size: 11.5px;
  color: var(--muted);
}
.fl-count .spinner,
.fl-state .spinner {
  width: 11px;
  height: 11px;
}
.fl-results {
  grid-column: 2;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 1px;
}
.fl-results li {
  display: flex;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--ink-2, var(--text));
}
.fl-r-title {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fl-r-site {
  flex: none;
  max-width: 40%;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fl-o-title {
  flex: 1 1 100%;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fl-o-site {
  font-size: 11.5px;
  color: var(--muted);
}
.fl-state {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--muted);
}
.fl-open.ok .fl-state {
  color: #1d9a6c;
}
.fl-open.out {
  opacity: 0.55;
}
.fl-words {
  flex: 1 1 100%;
  font-size: 11.5px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.fl-words[hidden] {
  display: none;
}

/* The search panel shows what the AI looks at and what it presses: a pointer goes to the
   result it opens, and the page comes up in the small window and is read from the top down. */
.find-live {
  width: min(380px, calc(100vw - 28px));
}
.fl-view-box {
  height: 214px;
}
.fl-frame {
  width: 1180px;
  height: 2400px;
  transform: scale(0.3);
  animation: fl-read 6s linear 0.9s both;
}
@keyframes fl-read {
  from {
    transform: translateY(0) scale(0.3);
  }
  to {
    transform: translateY(-300px) scale(0.3);
  }
}
.fl-pointer {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  color: #6d4df2;
  pointer-events: none;
  opacity: 0;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / 0.3));
  transition: transform 0.36s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.2s;
}
.fl-pointer.on {
  opacity: 1;
}
.fl-results li.picked,
.fl-open.picked {
  background: var(--accent-soft);
  border-radius: 6px;
  box-shadow: 0 0 0 3px var(--accent-soft);
  color: var(--accent-text, var(--accent));
}
@media (prefers-reduced-motion: reduce) {
  .fl-frame {
    animation: none;
  }
}
/* (the line under the small window keeps its height while empty, so the list under it does not jump) */
.fl-view-cap {
  box-sizing: border-box;
  min-height: 48px;
}
/* (the panel's head and the request under it keep their height: a long list scrolls under them, not over them) */
.fl-head,
.fl-request {
  flex: none;
}
.fl-request {
  line-height: 1.45;
  padding-bottom: 2px;
}

/* 자료 찾기: a file found on a page (an exam paper, its answer key, notes), listed under it. */
.find-item.find-file {
  margin-left: 30px;
  padding-top: 6px;
  padding-bottom: 6px;
  border-left: 2px solid var(--accent-soft);
}
.find-kind.file {
  color: #1d6fb8;
  background: color-mix(in srgb, #1d6fb8 10%, transparent);
}
.find-item.find-file .find-title {
  font-size: 13.5px;
}
.find-item.find-file.old .find-title {
  color: var(--muted);
}

/* While the helper acts on the 공부 page, its chat at the top is shorter (its latest steps
   still in sight), so the part of the page it works on can be followed under it. */
/* (see "the helper's card on the 공부 page", further down) */
/* (the page scrolls so what it presses is in the middle; there is room for that under the last row) */
.library:has(.agent-dock) {
  scroll-margin-top: 70px;
}
.find-results {
  scroll-margin-top: 70px;
}

/* What the helper is doing now, with the time it has taken once that is more than a moment. */
.agent-status-time {
  margin-left: auto;
  padding-left: 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0.75;
}
.agent-status-time:empty {
  display: none;
}

/* Words selected in the panel on the right (the study guide, the chat): purple, as on the page itself. */
.side ::selection {
  background: rgb(138 92 246 / 0.32);
  color: inherit;
}

/* ====================================================================================
   One chat box. AI 도우미 has no floating button or panel: on the 공부 page its chat is at the
   top of the page, and wherever a chat is on the screen it writes in that chat (agent.js).
   ==================================================================================== */
.agent-fab,
.agent > .agent-panel {
  display: none !important;
}
.agent-msg .agent-text {
  margin: 0;
  white-space: pre-wrap;
}
.agent-block .msg.agent-said .agent-text {
  white-space: pre-wrap;
}
.agent-settings-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 18px 18px 14px;
}
.agent-settings-dialog h2 {
  margin: 0 0 10px;
  font-size: 16px;
}
.agent-settings-dialog .agent-settings {
  display: grid;
  gap: 10px;
  border: 0;
  padding: 0;
}
.agent-settings-dialog .dialog-actions {
  display: flex;
  justify-content: flex-end;
  /* (this dialog's padding is 18px, not the 24px the shared bar reaches out by: no sideways scroll) */
  bottom: -14px;
  margin: 14px -18px -14px;
  padding: 12px 18px;
}

/* Selected words are purple in every chat (the chat page too, whatever holds its list). */
.dock ::selection,
.chat-list ::selection,
.msg ::selection {
  background: rgb(138 92 246 / 0.32);
  color: inherit;
}

/* Computers, the chat page: the conversation scrolls with a scroll bar at the right edge of the
   page, not beside the narrow column: the list takes the whole width, and what is in it,
   its heading and the message box keep to the column in the middle. */
html:not(.touch-ui) .study.no-doc .dock.full {
  width: 100%;
  border-inline: 0;
}
html:not(.touch-ui) .study.no-doc .dock.full > .chat-list {
  padding-inline: max(14px, calc((100% - 760px) / 2));
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 28%, transparent) transparent;
}
html:not(.touch-ui) .study.no-doc .dock.full > .dock-head,
html:not(.touch-ui) .study.no-doc .dock.full > .chat-compose {
  width: min(760px, 100%);
  margin-inline: auto;
  box-sizing: border-box;
}
html:not(.touch-ui) .study.no-doc .dock.full.is-empty > .chat-list {
  padding-inline: 14px;
  width: min(760px, 100%);
  margin-inline: auto;
  box-sizing: border-box;
}

/* ====================================================================================
   The helper's card on the 공부 page (agent.js dock, toggle). It grows out of the bar that
   is typed into: the card's message box is that bar's box, the list unfolds above it, and
   the bar's round mark glides into the card's head. It is as tall as what is in it (up to
   most of the screen), shorter and held at the top of the screen while it works on the page
   under it. The same steps and choices are drawn this way in a chat too.
   ==================================================================================== */
.agent-dock .agent-panel.docked {
  position: static;
  width: 100%;
  height: auto;
  max-height: min(560px, 66vh);
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(60 50 200 / 0.06), 0 14px 44px rgb(90 80 240 / 0.13);
  transition: max-height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s;
}
.agent-dock .agent-panel.docked.acting {
  max-height: 236px;
}
/* (while it works on the page, the card stays at the top of the screen: its steps are followed there) */
.library.agent-open .agent-dock:has(.agent-panel.acting) {
  position: sticky;
  top: 62px;
  z-index: 6;
}
.agent-dock .agent-panel {
  scroll-margin-top: 72px;
}

/* (.agent-skin: another box drawn as this card is, the 작업 tab's chat, workchat.css; its head,
   bubbles and message box take these same rules, so the two stay alike) */
/* ---- its head: the mark, its name, and three quiet buttons */
:is(.agent-panel.docked, .agent-skin) .agent-head {
  padding: 12px 12px 10px 16px;
  border-bottom: 0;
}
:is(.agent-panel.docked, .agent-skin) .agent-title {
  gap: 10px;
}
.agent-avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 2px 8px rgb(90 80 240 / 0.3);
}
:is(.agent-panel.docked, .agent-skin) .agent-title strong {
  font-size: 15px;
  letter-spacing: -0.01em;
}
:is(.agent-panel.docked, .agent-skin) .agent-head-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

/* ---- the conversation */
.agent-panel.docked .agent-list {
  padding: 4px 18px 8px;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 18%, transparent) transparent;
}
:is(.agent-panel.docked, .agent-skin) .agent-msg {
  font-size: 15px;
  line-height: 1.6;
}
:is(.agent-panel.docked, .agent-skin) .agent-msg.user {
  max-width: 76%;
  padding: 9px 14px;
  border-radius: 18px 18px 6px 18px;
  background: var(--accent-soft);
}
/* (what it says is written on the card itself, not in a bubble of its own) */
:is(.agent-panel.docked, .agent-skin) .agent-msg.assistant {
  max-width: 92%;
  padding: 2px 2px;
  background: none;
  border-radius: 0;
}
.agent-panel.docked .agent-hello {
  padding: 2px 2px 6px;
  font-size: 14.5px;
}
.agent-panel.docked .agent-list > *,
.agent-panel.docked .agent-block > * {
  animation: agent-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes agent-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---- the steps it took: a short record down a line, each ticked */
.agent-steps {
  position: relative;
  margin: 0 0 0 4px;
  padding: 2px 0 2px 16px;
  gap: 5px;
  font-size: 12.5px;
  line-height: 1.45;
  border-left: 2px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.agent-steps li {
  gap: 8px;
  align-items: flex-start;
}
.agent-steps li::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 9px no-repeat,
    var(--accent);
  opacity: 0.85;
}

/* ---- the choices it offers: one press answers; the first is the one it would take */
.agent-choices {
  gap: 8px;
  padding: 2px 2px 4px;
}
.agent-choices .agent-try {
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  background: var(--surface);
  color: var(--accent-text, var(--accent));
  font-weight: 600;
  transition: background-color 0.12s, border-color 0.12s, transform 0.06s;
}
.agent-choices .agent-try:first-child {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}
.agent-choices .agent-try:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.agent-choices .agent-try:active {
  transform: translateY(1px);
}

/* ---- what it is doing now */
.agent-panel.docked .agent-status {
  margin: 0 18px 8px;
  padding: 7px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  color: var(--accent-text, var(--accent));
  font-size: 13px;
  font-weight: 550;
}

/* ---- its message box: the bar's own box, at the foot of the card */
:is(.agent-panel.docked, .agent-skin) .agent-compose {
  align-items: center;
  gap: 6px;
  margin: 4px 12px 12px;
  padding: 7px 8px 7px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
:is(.agent-panel.docked, .agent-skin) .agent-compose:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring), var(--shadow);
}
:is(.agent-panel.docked, .agent-skin) .agent-input {
  order: 1;
  border: 0;
  background: transparent;
  padding: 8px 2px;
  font-size: 16px;
  min-height: 24px;
}
:is(.agent-panel.docked, .agent-skin) .agent-mic {
  order: 2;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: transparent;
}
:is(.agent-panel.docked, .agent-skin) .agent-send {
  order: 3;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgb(60 50 200 / 0.3), 0 4px 12px rgb(90 80 240 / 0.25);
}
:is(.agent-panel.docked, .agent-skin) .agent-send:disabled {
  opacity: 0.45;
  box-shadow: none;
}

/* ---- the bar's round mark on its way into the card's head (agent.js unfold) */
.agent-ghost {
  position: fixed;
  z-index: 80;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad);
  color: #fff;
  pointer-events: none;
  box-shadow: 0 6px 20px rgb(90 80 240 / 0.34);
}

/* The assistant's boxes (the bar, and the message box in its card) show that they are being
   typed into by their border alone, with no tinted ring around them. */
.agent-bar-box.composer:focus-within,
:is(.agent-panel.docked, .agent-skin) .agent-compose:focus-within {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line-strong));
}
.agent-bar-box .composer-input:focus-visible,
.agent-panel .agent-input:focus-visible {
  box-shadow: none;
}

/* The round mark on its way between the bar and the card keeps the bar's look: the sparkle
   is half the circle's width at every size (the bar's is 30 in 60, the card's 15 in 28),
   so it neither swells nor shrinks against the circle as it travels. */
.agent-ghost .icon {
  width: 50%;
  height: 50%;
}
.agent-avatar .icon {
  width: 50%;
  height: 50%;
}
.agent-bar-icon .icon {
  width: 50%;
  height: 50%;
}

/* The bar and the card's message box are the same box, drawn the same way, so the one turns into
   the other without a jump (agent.js unfold, fold): the same padding, the same input and buttons;
   and the round mark's sparkle is half its width with no padding inside it. */
.agent-bar-icon {
  padding: 0;
}
:is(.agent-panel.docked, .agent-skin) .agent-compose {
  align-items: flex-end;
  padding: 10px 10px 10px 14px;
  border-radius: 22px;
}
:is(.agent-panel.docked, .agent-skin) .agent-input {
  min-height: 38px;
  padding: 7px 4px;
  line-height: 1.55;
}

/* The round mark on its way between the bar and the card travels in the card's own place on
   the page (agent.js unfold, fold), so it moves with the page. */
.agent-dock {
  position: relative;
}
.agent-ghost.in-place {
  position: absolute;
  z-index: 5;
}

/* The 공부 page keeps room for its scroll bar at all times: when the assistant's card grows
   past the window and shrinks back, the scroll bar comes and goes without moving everything
   sideways. */
.page:has(> .library),
.page:has(.library) {
  scrollbar-gutter: stable;
}

/* While the helper acts, its card is see-through, so the page it works on (and its pointer
   there) is in sight at every step; under the mouse it comes back whole, to read its steps or
   press stop. (The page's own card and the floating one alike.) */
.agent-panel.acting {
  opacity: 0.45;
  transition: opacity 0.2s ease, max-height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.2s;
}
.agent-panel.acting:hover {
  opacity: 1;
}

/* The note over a player (sourceview.js showWait): a small pill at its top, or, while what was
   turned on is made ready (readyFirst), over the whole picture, which cannot be pressed then. */
.media-wait {
  padding: 0;
  background: none;
  border-radius: 0;
}
.media-wait-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.72);
  color: #fff;
}
.media-wait.cover {
  inset: 0;
  top: 0;
  left: 0;
  translate: none;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.5);
  pointer-events: auto;
  cursor: progress;
  font-size: 14px;
}

/* 작업: the "직접 파일 넣기" box before a file is in it takes no typing (work.js drawAddFiles). */
.work-file-box.locked {
  opacity: 0.85;
}
.work-file-box.locked .composer-input {
  cursor: default;
}

/* 작업 with the assistant (work.js ai-only): it is asked through its bar alone. The bar of
   options it fills in shows only while it does (agent.js make_work); the file box is away,
   the cards hand what is put in them to the assistant. */
.work-home.ai-only:not(.agent-making) > .make-label,
.work-home.ai-only:not(.agent-making) > .work-bar,
.work-home.ai-only:not(.agent-making) > .work-options,
.work-home.ai-only .work-file-box {
  display: none;
}
.work-home.agent-making > .work-bar,
.work-home.agent-making > .work-options {
  animation: agent-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.work-slot-wrap {
  position: relative;
  display: grid;
}
.work-slot-wrap > .work-slot-x {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
}
.work-slot-wrap > .work-slot-x[hidden] {
  display: none;
}

/* Work studio: slides chosen together (Ctrl/⌘ + click, Shift + click, ⋯ 여러 장 선택). */
.wc-thumb.multi {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--accent-soft);
}
