/*
 * Wooshin Tutor notes reference layer
 * Loaded after the legacy stylesheets. This file intentionally changes only
 * the note library, note market, and handwriting editor surfaces.
 */

:root {
  --note-green: #0f654b;
  --note-green-strong: #0a513d;
  --note-green-soft: #edf7f2;
  --note-green-tint: #f6fbf8;
  --note-ink: #17211d;
  --note-muted: #68736e;
  --note-line: #dfe6e2;
  --note-line-strong: #cbd7d1;
  --note-canvas-bg: #edf1ef;
  --note-danger: #c73b33;
  --note-control-radius: 8px;
  --note-card-radius: 10px;
}

/* --------------------------------------------------------------------------
 * Note library frame
 * ----------------------------------------------------------------------- */

.notes-workspace {
  width: 100%;
  min-width: 0;
  color: var(--note-ink);
}

/* Profile tab integration may arrive after this isolated stylesheet. */
.profile-tab-notes {
  min-width: 0;
  overflow: visible;
  gap: 0;
}

.profile-tab-notes > .profile-cover,
.profile-tab-notes > .profile-navigation-shell {
  display: none;
}

.profile-tab-notes .notes-workspace {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.notes-workspace,
.notes-workspace * {
  box-sizing: border-box;
}

.notes-workspace > .workspace-head {
  min-height: 0;
  margin: 0 0 22px;
  padding: 0 0 18px;
  border: 0;
  border-bottom: 1px solid var(--note-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.notes-workspace > .workspace-head::before,
.notes-workspace > .workspace-head::after {
  display: none;
}

.notes-workspace > .workspace-head .workspace-kicker,
.notes-workspace > .workspace-head .eyebrow {
  color: var(--note-green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
}

.notes-workspace > .workspace-head h1,
.notes-workspace > .workspace-head h2 {
  margin: 4px 0 5px;
  color: var(--note-ink);
  font-size: clamp(25px, 3vw, 32px);
  font-weight: 750;
  line-height: 1.25;
  letter-spacing: 0;
}

.notes-workspace > .workspace-head p {
  max-width: 660px;
  margin: 0;
  color: var(--note-muted);
  font-size: 14px;
  line-height: 1.55;
}

.notes-workspace .workspace-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.notes-workspace .workspace-head-actions > button {
  min-width: 0;
  min-height: 42px;
  padding: 0 15px;
  border-radius: var(--note-control-radius);
  font-size: 14px;
  font-weight: 700;
  box-shadow: none;
}

.notes-workspace .workspace-head-actions > .primary {
  border-color: var(--note-green);
  background: var(--note-green);
  color: #fff;
}

.notes-workspace .workspace-head-actions > .primary:hover {
  border-color: var(--note-green-strong);
  background: var(--note-green-strong);
}

.notes-workspace .workspace-head-actions > .ghost {
  border-color: var(--note-line-strong);
  background: #fff;
  color: var(--note-ink);
}

/* Recovery is important, but should not dominate the whole page. */
.notes-workspace .note-recovery-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  margin: 0 0 14px;
  padding: 11px 12px;
  border: 1px solid #d9e4dd;
  border-radius: var(--note-card-radius);
  background: var(--note-green-tint);
  color: var(--note-ink);
  box-shadow: none;
}

.notes-workspace .note-recovery-banner > div:first-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.notes-workspace .note-recovery-banner strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .note-recovery-banner span {
  overflow: hidden;
  color: var(--note-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .note-recovery-banner .chips {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.notes-workspace .note-recovery-banner button {
  min-height: 36px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 13px;
  box-shadow: none;
}

/* Search and sort are one quiet utility row. */
.notes-workspace .note-toolbar.workspace-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 172px;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.notes-workspace .note-toolbar .search-field {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--note-line-strong);
  border-radius: var(--note-control-radius);
  background: #fff;
  box-shadow: none;
}

.notes-workspace .note-toolbar .search-field:focus-within {
  border-color: var(--note-green);
  box-shadow: 0 0 0 3px rgba(15, 101, 75, 0.1);
}

.notes-workspace .note-toolbar .search-field .icon {
  width: 18px;
  height: 18px;
  color: #75817b;
}

.notes-workspace .note-toolbar .search-field input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--note-ink);
  font-size: 14px;
  box-shadow: none;
}

.notes-workspace .note-toolbar .compact-select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--note-line-strong);
  border-radius: var(--note-control-radius);
  background-color: #fff;
  color: #38453f;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

/* Categories behave like document tabs, not a row of floating pills. */
.notes-workspace .note-tabs.workspace-tabs {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-width: 0;
  margin: 0 0 14px;
  padding: 0;
  overflow-x: auto;
  border: 0;
  border-bottom: 1px solid var(--note-line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.notes-workspace .note-tabs.workspace-tabs::-webkit-scrollbar {
  display: none;
}

.notes-workspace .note-tabs.workspace-tabs > button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  min-width: 0;
  min-height: 43px;
  margin: 0;
  padding: 0 14px;
  scroll-snap-align: start;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #65716b;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

.notes-workspace .note-tabs.workspace-tabs > button::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
}

.notes-workspace .note-tabs.workspace-tabs > button:hover {
  background: transparent;
  color: var(--note-green);
}

.notes-workspace .note-tabs.workspace-tabs > button.active {
  border: 0;
  background: transparent;
  color: var(--note-green);
  box-shadow: none;
}

.notes-workspace .note-tabs.workspace-tabs > button.active::after {
  background: var(--note-green);
}

.notes-workspace .note-tabs .icon {
  width: 16px;
  height: 16px;
}

.notes-workspace .note-tabs .chip-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 5px;
  border-radius: 10px;
  background: #eef2f0;
  color: #5f6a65;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.notes-workspace .note-tabs > button.active .chip-count {
  background: var(--note-green-soft);
  color: var(--note-green);
}

/* Optional metrics retain one shared surface instead of four nested cards. */
.notes-workspace .note-workspace-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 14px;
  overflow: hidden;
  border: 1px solid var(--note-line);
  border-radius: var(--note-card-radius);
  background: #fff;
  box-shadow: none;
}

.notes-workspace .note-stat {
  display: grid;
  min-width: 0;
  min-height: 62px;
  place-items: center;
  align-content: center;
  gap: 4px;
  padding: 10px;
  border: 0;
  border-right: 1px solid var(--note-line);
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.notes-workspace .note-stat:last-child {
  border-right: 0;
}

.notes-workspace .note-stat strong {
  color: var(--note-ink);
  font-size: 20px;
  font-weight: 750;
  line-height: 1;
}

.notes-workspace .note-stat span {
  color: var(--note-muted);
  font-size: 11px;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
 * Library list and selected document
 * ----------------------------------------------------------------------- */

.notes-workspace .note-layout.grid.two {
  display: grid;
  grid-template-columns: minmax(300px, 0.78fr) minmax(0, 1.22fr);
  align-items: start;
  gap: 18px;
  min-width: 0;
}

.notes-workspace .note-layout.grid.two.is-empty {
  grid-template-columns: minmax(0, 1fr);
}

.notes-workspace .note-inspector[hidden] {
  display: none;
}

.notes-workspace .note-card[hidden] {
  display: none;
}

.notes-workspace .note-list.notice-list {
  display: grid;
  min-width: 0;
  max-height: min(690px, calc(100dvh - 250px));
  gap: 0;
  padding: 0;
  overflow: hidden auto;
  border: 1px solid var(--note-line);
  border-radius: var(--note-card-radius);
  background: #fff;
  box-shadow: none;
  scrollbar-color: #c8d3cd transparent;
  scrollbar-width: thin;
}

.notes-workspace .note-card.notice-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  grid-template-rows: auto minmax(30px, auto) auto;
  column-gap: 12px;
  row-gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 14px;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--note-line);
  border-radius: 0;
  background: #fff;
  color: var(--note-ink);
  outline: 0;
  box-shadow: none;
  transform: none;
  transition: background-color 140ms ease, color 140ms ease;
}

.notes-workspace .note-card.notice-card:last-child {
  border-bottom: 0;
}

.notes-workspace .note-card.notice-card:hover {
  border-color: var(--note-line);
  background: #f8faf9;
  box-shadow: none;
  transform: none;
}

.notes-workspace .note-card.notice-card:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--note-green);
  outline-offset: -2px;
  background: #f8faf9;
}

.notes-workspace .note-card.notice-card.active-note {
  border-color: var(--note-line);
  background: var(--note-green-soft);
  color: var(--note-ink);
  box-shadow: none;
  transform: none;
}

.notes-workspace .note-card .card-head {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.notes-workspace .note-card .card-head strong {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-size: 15px;
  font-weight: 720;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .note-card .badge {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid #d7e4dd;
  border-radius: 6px;
  background: #f5faf7;
  color: var(--note-green);
  font-size: 10px;
  font-weight: 700;
}

.notes-workspace .note-card .note-thumb {
  grid-column: 2;
  grid-row: 1 / 4;
  align-self: stretch;
  width: 72px;
  height: 88px;
  max-width: 100%;
  max-height: 88px;
  margin: 0;
  border: 1px solid var(--note-line);
  border-radius: 7px;
  background: #f7f9f8;
  object-fit: cover;
  box-shadow: none;
}

.notes-workspace .note-card > p {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--note-muted);
  font-size: 13px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .note-card:has(.note-thumb) > p {
  grid-column: 1;
}

.notes-workspace .note-card .meta {
  grid-column: 1;
  grid-row: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #7b857f;
  font-size: 11px;
  font-weight: 550;
  line-height: 1.4;
}

.notes-workspace .note-card .meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .note-card .meta span + span::before {
  content: "\00b7";
  margin-right: 7px;
  color: #a1aaa5;
}

.notes-workspace .note-list[data-empty="true"]::after {
  content: "Search results are empty.";
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--note-muted);
  font-size: 13px;
  font-weight: 600;
}

.notes-workspace .note-empty.empty {
  display: grid;
  min-height: 230px;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 28px 20px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--note-muted);
  text-align: center;
}

.notes-workspace .note-empty strong {
  color: var(--note-ink);
  font-size: 16px;
  font-weight: 720;
}

.notes-workspace .note-empty span {
  max-width: 310px;
  font-size: 13px;
  line-height: 1.55;
}

.notes-workspace .note-empty button {
  min-height: 39px;
  margin-top: 7px;
  padding: 0 13px;
  border-radius: var(--note-control-radius);
  font-size: 13px;
  box-shadow: none;
}

.notes-workspace .note-inspector.panel {
  position: sticky;
  top: 80px;
  min-width: 0;
  min-height: 330px;
  margin: 0;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--note-line);
  border-radius: var(--note-card-radius);
  background: #fff;
  box-shadow: none;
}

.notes-workspace .note-inspector > .form,
.notes-workspace .note-inspector > form {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.notes-workspace .note-inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.notes-workspace .note-inspector-head .badge {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #d6e4dc;
  border-radius: 6px;
  background: var(--note-green-soft);
  color: var(--note-green);
  font-size: 11px;
}

.notes-workspace .note-inspector-head .muted {
  min-width: 0;
  overflow: hidden;
  color: var(--note-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .note-title-edit {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 3px;
  padding: 0 0 11px;
  border: 0;
  border-bottom: 1px solid var(--note-line);
  border-radius: 0;
  background: transparent;
  color: var(--note-ink);
  text-align: left;
  box-shadow: none;
}

.notes-workspace .note-title-edit:hover span {
  color: var(--note-green);
}

.notes-workspace .note-title-edit span {
  width: 100%;
  overflow: hidden;
  font-size: 19px;
  font-weight: 750;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .note-title-edit small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--note-muted);
  font-size: 11px;
  font-weight: 600;
}

.notes-workspace .note-title-edit small .icon {
  width: 13px;
  height: 13px;
}

.notes-workspace .hand-note-summary {
  display: grid;
  width: 100%;
  min-width: 0;
  max-height: 440px;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--note-line);
  border-radius: 8px;
  background: #f5f7f6;
}

.notes-workspace .hand-note-summary img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: 420px;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  object-fit: contain;
  box-shadow: none;
}

.notes-workspace .note-inspector :is(.input, .select, .textarea) {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--note-line-strong);
  border-radius: var(--note-control-radius);
  background-color: #fff;
  color: var(--note-ink);
  box-shadow: none;
}

.notes-workspace .note-inspector :is(.input, .select) {
  min-height: 43px;
  padding-inline: 12px;
}

.notes-workspace .note-inspector :is(.input, .select, .textarea):focus {
  border-color: var(--note-green);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(15, 101, 75, 0.1);
}

.notes-workspace .note-textarea {
  min-height: 350px;
  padding: 13px 14px;
  resize: vertical;
  background-color: #fff;
  background-image: linear-gradient(to bottom, transparent 30px, #edf1ef 31px);
  background-size: 100% 31px;
  font-size: 14px;
  line-height: 31px;
  overflow-wrap: anywhere;
}

.notes-workspace .note-text-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.notes-workspace .note-text-tools > button {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--note-line-strong);
  border-radius: 9px;
  background: #f8faf9;
  color: var(--note-ink);
  font-size: 12px;
  font-weight: 680;
}

.notes-workspace .note-text-tools > button:focus-visible {
  outline: 2px solid var(--note-green);
  outline-offset: 2px;
}

.notes-workspace .note-draft-hint {
  margin: 0;
  color: var(--note-muted);
  font-size: 12px;
  line-height: 1.55;
}

.notes-workspace .note-draft-hint kbd {
  padding: 1px 3px;
  border: 1px solid var(--note-line);
  border-radius: 4px;
  background: #f8faf9;
  font: inherit;
}

.notes-workspace .note-inspector .chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.notes-workspace .note-inspector .chips > button {
  min-height: 40px;
  padding: 0 13px;
  border-radius: var(--note-control-radius);
  font-size: 13px;
  font-weight: 680;
  box-shadow: none;
}

.notes-workspace .note-inspector .chips > .primary {
  border-color: var(--note-green);
  background: var(--note-green);
  color: #fff;
}

.notes-workspace .note-inspector .chips > .ghost {
  border-color: var(--note-line-strong);
  background: #fff;
  color: var(--note-ink);
}

.notes-workspace .note-inspector .chips > .danger {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: var(--note-danger);
}

.notes-workspace .note-inspector :is(.katex-display, pre, table) {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.notes-workspace .note-inspector :is(p, span, strong, textarea) {
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
 * Note market
 * ----------------------------------------------------------------------- */

.notes-workspace > .panel:not(.note-toolbar):not(.note-inspector),
.notes-workspace .note-tabs + .panel {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--note-line);
  border-radius: var(--note-card-radius);
  background: #fff;
  box-shadow: none;
}

.notes-workspace .compact-title.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.notes-workspace .compact-title h2 {
  margin: 0;
  color: var(--note-ink);
  font-size: 19px;
  font-weight: 750;
}

.notes-workspace .compact-title .compact-select {
  width: auto;
  min-width: 120px;
  min-height: 40px;
  border: 1px solid var(--note-line-strong);
  border-radius: var(--note-control-radius);
  background-color: #fff;
  box-shadow: none;
}

.notes-workspace .market-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.notes-workspace .market-card.notice-card {
  display: grid;
  min-width: 0;
  gap: 9px;
  margin: 0;
  padding: 13px;
  overflow: hidden;
  border: 1px solid var(--note-line);
  border-radius: var(--note-card-radius);
  background: #fff;
  box-shadow: none;
}

.notes-workspace .market-card:hover {
  border-color: var(--note-line-strong);
  transform: none;
}

.notes-workspace .note-full-preview {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--note-line);
  border-radius: 7px;
  background: #f5f7f6;
  box-shadow: none;
}

.notes-workspace .market-card .note-thumb {
  display: block;
  width: 100%;
  height: auto;
  max-height: 250px;
  aspect-ratio: 3 / 4;
  border: 0;
  border-radius: 0;
  object-fit: cover;
}

.notes-workspace .market-card .card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.notes-workspace .market-card .card-head strong {
  min-width: 0;
  overflow: hidden;
  color: var(--note-ink);
  font-size: 14px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-workspace .market-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--note-muted);
  font-size: 11px;
}

.notes-workspace .market-card .chips {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}

.notes-workspace .market-card .chips button {
  min-width: 0;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 12px;
  box-shadow: none;
}

/* --------------------------------------------------------------------------
 * Handwriting workspace
 * ----------------------------------------------------------------------- */

.app-shell.has-note-editor {
  width: 100%;
  min-width: 0;
  min-height: 100dvh;
  padding: 0;
  overflow: hidden;
  background: var(--note-canvas-bg);
}

.has-note-editor .note-editor-backdrop {
  position: fixed;
  z-index: 400;
  inset: 0;
  display: block;
  min-width: 0;
  min-height: 100dvh;
  padding: 0;
  background: var(--note-canvas-bg);
}

.has-note-editor .note-editor {
  display: grid;
  grid-template-rows: 62px minmax(0, 1fr);
  width: 100%;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: var(--note-canvas-bg);
  box-shadow: none;
}

.has-note-editor .note-editor-top {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(230px, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 62px;
  padding: 8px 14px;
  border: 0;
  border-bottom: 1px solid var(--note-line);
  background: #fff;
  box-shadow: none;
}

.has-note-editor .note-editor-leading,
.has-note-editor .note-editor-actions,
.has-note-editor .note-header-history {
  display: flex;
  align-items: center;
  min-width: 0;
}

.has-note-editor .note-editor-leading {
  gap: 9px;
}

.has-note-editor .note-document-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.has-note-editor .note-document-copy > span {
  color: var(--note-green);
  font-size: 10px;
  font-weight: 700;
}

.has-note-editor .note-title-input {
  width: min(38vw, 430px);
  min-width: 0;
  height: auto;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--note-ink);
  font: inherit;
  font-size: 15px;
  font-weight: 740;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: none;
}

.has-note-editor .note-editor-back-button,
.has-note-editor .note-header-history .icon-ghost {
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--note-control-radius);
  background: transparent;
  color: #4c5953;
  box-shadow: none;
}

.has-note-editor .note-editor-back-button:hover,
.has-note-editor .note-header-history .icon-ghost:hover {
  border-color: var(--note-line);
  background: #f5f8f6;
  color: var(--note-green);
}

.has-note-editor .note-save-status {
  justify-self: center;
  min-width: 72px;
  color: var(--note-muted);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
  white-space: nowrap;
}

.has-note-editor .note-save-status[data-status="saving"],
.has-note-editor .note-save-status[data-status="dirty"],
.has-note-editor .note-save-status[data-status="local"] {
  color: #9a6a15;
}

.has-note-editor .note-save-status[data-status="saved"] {
  color: var(--note-green);
}

.has-note-editor .note-save-status[data-status="error"],
.has-note-editor .note-save-status[data-status="backup-error"] {
  color: var(--note-danger);
}

.has-note-editor .note-editor-actions {
  justify-self: end;
  gap: 6px;
}

.has-note-editor .note-header-history {
  gap: 2px;
  padding-right: 7px;
  border-right: 1px solid var(--note-line);
}

.has-note-editor .note-save-button,
.has-note-editor .note-share-button,
.has-note-editor .note-copy-button {
  min-width: 0;
  min-height: 40px;
  padding: 0 13px;
  border-radius: var(--note-control-radius);
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}

.has-note-editor .note-save-button {
  border-color: var(--note-line-strong);
  background: #fff;
  color: var(--note-ink);
}

.has-note-editor .note-share-button,
.has-note-editor .note-copy-button {
  border-color: var(--note-green);
  background: var(--note-green);
  color: #fff;
}

.has-note-editor .note-editor-body {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  /* Override the legacy <=980px two-row layout on portrait tablets. */
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.has-note-editor .note-toolrail {
  position: relative;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 8px 7px;
  overflow: hidden auto;
  border: 0;
  border-right: 1px solid var(--note-line);
  background: #fff;
  box-shadow: none;
  scrollbar-width: thin;
}

.has-note-editor .note-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.has-note-editor .note-toolrail .note-tool-group {
  width: 100%;
  flex-direction: column;
}

.has-note-editor .note-toolrail .note-tool-group + .note-tool-group {
  padding-top: 8px;
  border-top: 1px solid #edf1ef;
}

.has-note-editor .note-toolrail button {
  position: relative;
  display: grid;
  width: 52px;
  min-width: 52px;
  height: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #52605a;
  box-shadow: none;
}

.has-note-editor .note-toolrail button:hover {
  background: #f1f5f3;
  color: var(--note-green);
}

.has-note-editor .note-toolrail button.active,
.has-note-editor .note-toolrail button[aria-pressed="true"] {
  background: var(--note-green-soft);
  color: var(--note-green);
  box-shadow: none;
}

.has-note-editor .note-toolrail button .icon,
.has-note-editor .note-toolrail button svg {
  width: 20px;
  height: 20px;
}

.has-note-editor .note-toolrail button > span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.has-note-editor .note-rail-actions {
  margin-top: auto;
}

.has-note-editor .note-workbench {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.has-note-editor .note-tool-inspector {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 56px;
  padding: 7px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 0;
  border-bottom: 1px solid var(--note-line);
  background: #fff;
  box-shadow: none;
  scrollbar-color: #c8d3cd transparent;
  scrollbar-width: thin;
}

.has-note-editor .note-active-tool-state {
  display: grid;
  flex: 0 0 auto;
  min-width: 66px;
  gap: 0;
}

.has-note-editor .note-active-tool-state span,
.has-note-editor .note-size-wrap > span {
  color: var(--note-muted);
  font-size: 10px;
  font-weight: 650;
}

.has-note-editor .note-active-tool-state strong {
  color: var(--note-ink);
  font-size: 13px;
  font-weight: 720;
}

.has-note-editor .note-colors {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  padding: 0 11px;
  border-inline: 1px solid var(--note-line);
}

.has-note-editor .note-colors button {
  width: 25px;
  min-width: 25px;
  height: 25px;
  min-height: 25px;
  padding: 0;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px #bfcac4;
}

.has-note-editor .note-colors button.active {
  box-shadow: 0 0 0 2px var(--note-green);
}

.has-note-editor .note-size-wrap {
  display: grid;
  grid-template-columns: auto minmax(84px, 136px) 34px;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  min-width: 0;
  margin: 0;
}

.has-note-editor .note-size-wrap input[type="range"] {
  min-width: 84px;
  accent-color: var(--note-green);
}

.has-note-editor .note-size-wrap output {
  color: #5f6b65;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.has-note-editor .shape-detail-tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
}

.has-note-editor .shape-detail-tools > button,
.has-note-editor .pen-only-button,
.has-note-editor .vector-eraser-button {
  width: auto;
  min-width: 40px;
  height: 36px;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid var(--note-line-strong);
  border-radius: 7px;
  background: #fff;
  color: #52605a;
  box-shadow: none;
}

.has-note-editor .shape-detail-tools > button.active,
.has-note-editor .pen-only-button.active,
.has-note-editor .vector-eraser-button.active {
  border-color: #a9cbbd;
  background: var(--note-green-soft);
  color: var(--note-green);
  box-shadow: none;
}

.has-note-editor .note-editor:not([data-active-tool="line"]):not([data-active-tool="arrow"]):not([data-active-tool="rect"]):not([data-active-tool="ellipse"]):not([data-active-tool="triangle"]):not([data-active-tool="diamond"]) .shape-detail-tools {
  display: none;
}

.has-note-editor .note-editor[data-active-tool="eraser"] .note-colors,
.has-note-editor .note-editor[data-active-tool="eraser"] .pen-only-button {
  display: none;
}

.has-note-editor .vector-eraser-button {
  display: none;
  white-space: nowrap;
}

.has-note-editor .note-editor[data-active-tool="eraser"] .vector-eraser-button {
  display: inline-flex;
}

.has-note-editor .hand-canvas-stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(14px, 2.5vw, 34px);
  background-color: var(--note-canvas-bg);
  background-image: radial-gradient(#ccd5d0 0.65px, transparent 0.65px);
  background-size: 18px 18px;
}

.has-note-editor .hand-paper {
  position: relative;
  display: block;
  max-width: none;
  margin: auto;
  border: 1px solid #ccd5d0;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(23, 33, 29, 0.11);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.has-note-editor .hand-paper canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.has-note-editor #handCanvas,
.has-note-editor #handInkCanvas {
  pointer-events: none;
}

.has-note-editor #handPreviewCanvas {
  touch-action: none;
  cursor: crosshair;
}

.has-note-editor .note-editor-readonly #handPreviewCanvas {
  cursor: default;
}

.has-note-editor .mobile-tabbar,
.has-note-editor .bottom-ask {
  display: none !important;
}

/* --------------------------------------------------------------------------
 * Responsive behavior
 * ----------------------------------------------------------------------- */

@media (max-width: 960px) {
  .notes-workspace .note-layout.grid.two {
    grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
    gap: 12px;
  }

  .notes-workspace .market-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell:has(.notes-workspace) .container {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .notes-workspace {
    padding-bottom: 10px;
  }

  .notes-workspace > .workspace-head {
    margin-bottom: 16px;
    padding-bottom: 15px;
  }

  .notes-workspace > .workspace-head h1,
  .notes-workspace > .workspace-head h2 {
    font-size: 24px;
  }

  .notes-workspace > .workspace-head p {
    max-width: 100%;
    font-size: 13px;
  }

  .notes-workspace .workspace-head-actions {
    width: 100%;
  }

  .notes-workspace .workspace-head-actions > button {
    flex: 1 1 0;
    min-height: 42px;
  }

  .notes-workspace .note-recovery-banner {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .notes-workspace .note-recovery-banner .chips {
    width: 100%;
  }

  .notes-workspace .note-recovery-banner .chips > button {
    flex: 1 1 0;
  }

  .notes-workspace .note-toolbar.workspace-section {
    grid-template-columns: minmax(0, 1fr) 126px;
  }

  .notes-workspace .note-tabs.workspace-tabs > button {
    min-height: 42px;
    padding-inline: 12px;
  }

  .notes-workspace .note-layout.grid.two {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .notes-workspace .note-list.notice-list {
    max-height: min(44dvh, 430px);
  }

  .notes-workspace .note-inspector.panel {
    position: static;
    min-height: 0;
    padding: 15px;
  }

  .notes-workspace .note-textarea {
    min-height: 300px;
  }

  .notes-workspace .market-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .notes-workspace .market-card.notice-card {
    grid-template-columns: 82px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    align-items: start;
  }

  .notes-workspace .market-card .note-full-preview {
    grid-column: 1;
    grid-row: 1 / 4;
  }

  .notes-workspace .market-card .note-thumb {
    max-height: none;
    aspect-ratio: 3 / 4;
  }

  .notes-workspace .market-card .card-head,
  .notes-workspace .market-card > p,
  .notes-workspace .market-card .meta,
  .notes-workspace .market-card .chips {
    grid-column: 2;
    min-width: 0;
  }

  .notes-workspace .market-card .chips {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .has-note-editor .note-editor {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .has-note-editor .note-editor-top {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    min-height: calc(58px + env(safe-area-inset-top));
    padding: max(7px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) 7px max(9px, env(safe-area-inset-left));
  }

  .has-note-editor .note-editor-leading {
    gap: 5px;
  }

  .has-note-editor .note-editor-back-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .has-note-editor .note-document-copy > span {
    display: none;
  }

  .has-note-editor .note-title-input {
    width: min(43vw, 190px);
    height: 22px !important;
    min-height: 22px !important;
    font-size: 14px;
    line-height: 22px;
  }

  .has-note-editor .note-save-status {
    position: absolute;
    left: calc(max(9px, env(safe-area-inset-left)) + 43px);
    bottom: 4px;
    height: 14px;
    min-width: 0;
    min-height: 14px;
    font-size: 9px;
    line-height: 14px;
  }

  .has-note-editor .note-header-history {
    display: none;
  }

  .has-note-editor .note-editor-actions {
    gap: 4px;
  }

  .has-note-editor .note-save-button,
  .has-note-editor .note-share-button,
  .has-note-editor .note-copy-button {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
  }

  .has-note-editor .note-save-button span,
  .has-note-editor .note-share-button span,
  .has-note-editor .note-copy-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .has-note-editor .note-editor-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) calc(56px + env(safe-area-inset-bottom));
  }

  .has-note-editor .note-workbench {
    grid-column: 1;
    grid-row: 1;
    grid-template-rows: 52px minmax(0, 1fr);
  }

  .has-note-editor .note-toolrail {
    grid-column: 1;
    grid-row: 2;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    padding: 5px max(8px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    overflow: auto hidden;
    border: 0;
    border-top: 1px solid var(--note-line);
    background: #fff;
    scrollbar-width: none;
  }

  .has-note-editor .note-toolrail::-webkit-scrollbar {
    display: none;
  }

  .has-note-editor .note-toolrail .note-tool-group {
    width: auto;
    flex: 0 0 auto;
    flex-direction: row;
  }

  .has-note-editor .note-toolrail .note-tool-group + .note-tool-group {
    padding: 0 0 0 6px;
    border-top: 0;
    border-left: 1px solid var(--note-line);
  }

  .has-note-editor .note-toolrail button {
    width: 44px;
    min-width: 44px;
    height: 42px;
    min-height: 42px;
  }

  .has-note-editor .note-rail-actions {
    margin-top: 0;
  }

  .has-note-editor .note-tool-inspector {
    min-height: 52px;
    gap: 8px;
    padding: 6px 8px;
  }

  .has-note-editor .note-active-tool-state {
    min-width: 55px;
  }

  .has-note-editor .note-colors {
    gap: 4px;
    padding-inline: 8px;
  }

  .has-note-editor .note-colors button {
    width: 23px;
    min-width: 23px;
    height: 23px;
    min-height: 23px;
  }

  .has-note-editor .note-size-wrap {
    grid-template-columns: auto 78px 31px;
  }

  .has-note-editor .note-size-wrap input[type="range"] {
    min-width: 78px;
  }

  .has-note-editor .shape-detail-tools > button,
  .has-note-editor .pen-only-button,
  .has-note-editor .vector-eraser-button {
    height: 34px;
    min-height: 34px;
  }

  .has-note-editor .hand-canvas-stage {
    padding: 10px;
  }
}

@media (max-width: 430px) {
  .notes-workspace .note-toolbar.workspace-section {
    grid-template-columns: minmax(0, 1fr) 112px;
    gap: 6px;
  }

  .notes-workspace .note-toolbar .search-field {
    padding-inline: 10px;
  }

  .notes-workspace .note-tabs.workspace-tabs > button {
    gap: 5px;
    padding-inline: 11px;
    font-size: 12px;
  }

  .notes-workspace .note-tabs .chip-count {
    min-width: 18px;
    height: 18px;
    padding-inline: 4px;
  }

  .notes-workspace .note-card.notice-card {
    grid-template-columns: minmax(0, 1fr) 64px;
    column-gap: 10px;
    padding: 12px;
  }

  .notes-workspace .note-card .note-thumb {
    width: 64px;
    height: 78px;
    max-height: 78px;
  }

  .notes-workspace .note-card .card-head strong {
    font-size: 14px;
  }

  .notes-workspace .note-inspector.panel {
    padding: 13px;
  }

  .notes-workspace .note-inspector .chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .notes-workspace .note-inspector .chips > button {
    width: 100%;
    min-width: 0;
  }

  .notes-workspace .note-inspector .chips > .danger {
    margin-left: 0;
  }

  .notes-workspace .market-card.notice-card {
    grid-template-columns: 74px minmax(0, 1fr);
  }

  .has-note-editor .note-title-input {
    width: min(36vw, 142px);
  }

  .has-note-editor .note-active-tool-state {
    display: none;
  }

  .has-note-editor .shape-detail-tools > button span,
  .has-note-editor .pen-only-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .notes-workspace .note-card,
  .notes-workspace button,
  .has-note-editor button {
    scroll-behavior: auto;
    transition: none !important;
  }
}

/* James study materials: the original stays server-side; students write on a page layer. */
.has-note-editor .note-editor-material {
  grid-template-rows: 62px auto minmax(0, 1fr);
}

/* The fixed backdrop fills the iPad screen even if Safari briefly reports a
   stale 100dvh after rotation or dismissing the page-jump keyboard. */
.app-shell.has-note-editor .note-editor-backdrop.is-material-editor {
  inset: 0;
  height: auto;
  min-height: 0;
}

.app-shell.has-note-editor .note-editor-material {
  height: 100%;
  min-height: 0;
  max-height: none;
}

.has-note-editor .note-pagebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  min-height: 54px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--note-line);
  background: #fff;
  color: var(--note-ink);
}

.has-note-editor .note-pagebar > button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 37px;
  padding: 0 12px;
  border: 1px solid var(--note-line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--note-green);
  font-weight: 750;
}

.has-note-editor .note-pagebar > button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.has-note-editor .note-pagebar label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--note-muted);
  font-size: 12px;
}

.has-note-editor .note-page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.has-note-editor .note-page-jump input {
  width: 58px;
  min-height: 37px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  appearance: textfield;
}

.has-note-editor .note-page-jump input::-webkit-inner-spin-button,
.has-note-editor .note-page-jump input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.has-note-editor .note-page-jump .note-page-total {
  color: var(--note-muted);
  font-size: 12px;
  white-space: nowrap;
}

.has-note-editor .note-page-jump button {
  min-height: 37px;
  padding: 0 10px;
  border: 1px solid var(--note-line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--note-green);
  font-weight: 750;
}

.has-note-editor .note-pagebar .note-page-progress {
  min-width: 62px;
  color: var(--note-muted);
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

.has-note-editor .study-touch-mode {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--note-line-strong);
  border-radius: 12px;
  background: #f3f8f5;
}

.has-note-editor .study-touch-mode button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--note-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.has-note-editor .study-touch-mode button.active {
  background: var(--note-green);
  color: #fff;
  box-shadow: 0 2px 5px rgba(22, 89, 65, .16);
}

.has-note-editor .study-touch-mode button:focus-visible {
  outline: 2px solid var(--note-green);
  outline-offset: 2px;
}

.has-note-editor .study-reader-view-controls {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--note-line-strong);
  border-radius: 12px;
  background: #f3f8f5;
}

.has-note-editor .study-reader-view-controls button {
  min-height: 36px;
  padding: 0 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--note-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  cursor: pointer;
}

.has-note-editor .study-reader-view-controls button.active {
  background: var(--note-green);
  color: #fff;
  box-shadow: 0 2px 5px rgba(22, 89, 65, .16);
}

.has-note-editor .study-reader-view-controls button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.has-note-editor .note-pagebar > small {
  width: 100%;
  margin: 0;
  color: var(--note-muted);
  font-size: 11px;
  text-align: center;
}

.has-note-editor .study-solution-conflict {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid #e9c175;
  border-radius: 10px;
  background: #fff8e7;
  color: #6b4a13;
  font-size: 12px;
}

.has-note-editor .study-solution-conflict > span {
  flex: 1 1 auto;
}

.has-note-editor .study-solution-conflict > button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid #dfbd82;
  border-radius: 8px;
  background: #fff;
  color: #5b441a;
  font-weight: 700;
}

.has-note-editor .hand-canvas-stage.is-material-page:not(.is-ready) .hand-paper {
  visibility: hidden;
}

/* The page and its ink enter as one sheet after the next image is ready. */
.has-note-editor .hand-canvas-stage.is-material-page.is-ready[data-page-turn="next"] .hand-paper {
  animation: study-page-slide-next 260ms cubic-bezier(.2, .72, .24, 1) both;
}

.has-note-editor .hand-canvas-stage.is-material-page.is-ready[data-page-turn="prev"] .hand-paper {
  animation: study-page-slide-prev 260ms cubic-bezier(.2, .72, .24, 1) both;
}

@keyframes study-page-slide-next {
  from { opacity: .7; transform: translate3d(46px, 0, 0) rotateY(-4deg); }
  to { opacity: 1; transform: translate3d(0, 0, 0) rotateY(0); }
}

@keyframes study-page-slide-prev {
  from { opacity: .7; transform: translate3d(-46px, 0, 0) rotateY(4deg); }
  to { opacity: 1; transform: translate3d(0, 0, 0) rotateY(0); }
}

.has-note-editor .study-page-image-status {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(90%, 360px);
  margin: 0;
  padding: 18px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--note-line);
  border-radius: 14px;
  background: #fff;
  color: var(--note-muted);
  font-size: 13px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(20, 50, 40, .08);
}

.has-note-editor .study-page-image-status[hidden] {
  display: none;
}

.has-note-editor .study-page-image-status button {
  margin-left: 4px;
  border: 0;
  background: transparent;
  color: var(--note-green);
  font-weight: 750;
}

.has-note-editor .hand-canvas-stage.is-material-page {
  position: relative;
  /* Include the empty margins around a narrow portrait page in the gesture surface. */
  touch-action: none;
}

.has-note-editor .study-page-spread {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  max-width: none;
  margin: auto;
  transition: translate 160ms ease-out;
}

.has-note-editor .study-page-spread .hand-paper {
  flex: 0 0 auto;
  margin: 0;
}

.has-note-editor .study-spread-companion {
  position: relative;
  display: block;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #ccd5d0;
  border-radius: 2px;
  background: #fff;
  color: #fff;
  box-shadow: 0 8px 24px rgba(23, 33, 29, .11);
  cursor: pointer;
}

.has-note-editor .study-spread-companion img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.has-note-editor .study-spread-companion span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(17, 24, 39, .72);
  font-size: 10px;
  font-weight: 750;
  opacity: .78;
  backdrop-filter: blur(8px);
}

.has-note-editor .study-spread-companion:hover span,
.has-note-editor .study-spread-companion:focus-visible span {
  opacity: 1;
}

.has-note-editor .study-reference-viewer {
  position: fixed;
  z-index: 430;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  width: min(var(--study-reference-width, 300px), calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow: hidden;
  border: 1px solid rgba(17, 70, 51, .28);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 54px rgba(19, 47, 38, .28);
  transition: box-shadow 140ms ease, width 140ms ease;
}

.has-note-editor .study-reference-viewer.is-dragging {
  box-shadow: 0 24px 72px rgba(19, 47, 38, .38);
  transition: none;
}

.has-note-editor .study-reference-viewer > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 7px 8px 7px 12px;
  border-bottom: 1px solid var(--note-line);
  background: #f6faf7;
  color: var(--note-ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.has-note-editor .study-reference-viewer.is-dragging > header {
  cursor: grabbing;
}

.has-note-editor .study-reference-viewer > header strong {
  font-size: 12px;
}

.has-note-editor .study-reference-viewer > header span {
  color: var(--note-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.has-note-editor .study-reference-viewer button {
  display: inline-grid;
  min-width: 32px;
  min-height: 32px;
  place-items: center;
  padding: 0 8px;
  border: 1px solid var(--note-line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--note-green);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.has-note-editor .study-reference-viewer button:disabled {
  opacity: .38;
  cursor: not-allowed;
}

.has-note-editor .study-reference-viewer > header button {
  border: 0;
  background: transparent;
  color: #53625b;
  font-size: 21px;
}

.has-note-editor .study-reference-nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border-bottom: 1px solid var(--note-line);
}

.has-note-editor .study-reference-nav form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.has-note-editor .study-reference-nav input {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 0 7px;
  border: 1px solid var(--note-line-strong);
  border-radius: 8px;
  color: var(--note-ink);
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.has-note-editor .study-reference-sheet {
  position: relative;
  display: grid;
  min-height: 120px;
  overflow: auto;
  place-items: center;
  background: #e8eeeb;
}

.has-note-editor .study-reference-sheet.is-loading::before {
  content: "페이지 불러오는 중…";
  position: absolute;
  z-index: 1;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .9);
  color: var(--note-muted);
  font-size: 10px;
}

.has-note-editor .study-reference-sheet img {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(62dvh, 720px);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.has-note-editor .study-reference-size {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 10px;
  border-top: 1px solid var(--note-line);
  background: #fff;
  color: var(--note-muted);
  font-size: 10px;
}

.has-note-editor .study-reference-size input {
  width: 100%;
  accent-color: var(--note-green);
}

.study-invite-panel {
  display: grid;
  gap: 14px;
  margin: 14px 0 18px;
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid var(--note-line-strong);
  border-radius: 18px;
  background: #fff;
}

.study-material-heading-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 7px;
}

.study-material-heading-actions > button {
  min-height: 40px;
  border-radius: 11px;
}

.study-book-upload-panel {
  display: grid;
  gap: 14px;
  margin: 14px 0 18px;
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid var(--note-line-strong);
  border-radius: 18px;
  background: #fff;
}

.study-book-upload-panel > form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.study-book-upload-panel > form > label {
  display: grid;
  gap: 5px;
  color: var(--note-muted);
  font-size: 12px;
}

.study-book-upload-panel > form > label > input,
.study-book-upload-panel > form > label > select {
  width: 100%;
  min-width: 0;
}

.study-book-upload-panel > form > button {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 40px;
}

.study-category-create-panel > form > .study-book-published {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 8px;
  color: var(--note-text);
  font-size: 13px;
}

.study-category-create-panel > form > .study-book-published input {
  width: auto;
  min-width: auto;
  margin: 0;
  accent-color: var(--note-green);
}

.study-upload-status {
  display: grid;
  gap: 6px;
  color: var(--note-muted);
  font-size: 12px;
}

.study-upload-status progress {
  width: 100%;
  height: 9px;
  accent-color: var(--note-green);
}

.study-upload-ready {
  margin: 0;
  color: var(--note-green);
  font-weight: 750;
}

.study-upload-error {
  margin: 0;
  color: var(--note-danger);
  font-size: 12px;
}

.study-book-metadata-form {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 9px;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--note-line);
  border-radius: 13px;
  background: #fff;
}

.study-book-metadata-form > label {
  display: grid;
  gap: 4px;
  color: var(--note-muted);
  font-size: 12px;
  text-align: left;
}

.study-book-metadata-form :is(input, select) {
  min-width: 0;
  width: 100%;
}

.study-book-metadata-form .study-book-published {
  display: flex;
  align-items: center;
  gap: 7px;
}

.study-book-metadata-form .study-book-published input {
  width: auto;
}

.study-material-card.is-loading .study-material-actions button {
  cursor: progress;
}

.study-book-opening-overlay {
  position: fixed;
  z-index: 2147482800;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(232, 248, 240, .94);
  backdrop-filter: blur(10px);
  animation: study-book-loading-appear 360ms ease 320ms both;
}

.study-book-opening-panel {
  display: grid;
  justify-items: center;
  gap: 11px;
  width: min(100%, 390px);
  padding: 27px 22px;
  border: 1px solid #cfe5d8;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(17, 70, 43, .13);
  color: #183d2c;
  text-align: center;
}

.study-book-opening-panel strong { font-size: 19px; }
.study-book-opening-title { font-size: 14px; font-weight: 750; }
.study-book-opening-panel small { color: #677f70; line-height: 1.55; }
.study-book-opening-panel button { margin-top: 3px; }

.study-book-opening-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #d6ece0;
  border-top-color: #087b62;
  border-radius: 50%;
  animation: study-book-loading-spin .8s linear infinite;
}

@keyframes study-book-loading-spin { to { transform: rotate(360deg); } }
@keyframes study-book-loading-appear { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .study-book-opening-overlay,
  .study-book-opening-spinner { animation: none; }
}

.study-category-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 20px;
  color: var(--note-muted);
  font-size: 12px;
}

.study-category-summary > span {
  display: inline-flex;
  gap: 5px;
  padding: 6px 10px;
  border: 1px solid var(--note-line);
  border-radius: 999px;
  background: #fff;
}

.study-category-summary strong {
  color: var(--note-green);
}

.study-privacy-note {
  margin: -8px 0 19px;
  color: #536b5c;
  font-size: 12px;
  line-height: 1.55;
}

.study-invite-head,
.study-invite-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.study-invite-head strong,
.study-invite-list-title {
  color: var(--note-ink);
  font-size: 15px;
}

.study-invite-head p {
  margin: 4px 0 0;
  color: var(--note-muted);
  font-size: 12px;
}

.study-invite-search {
  display: flex;
  gap: 8px;
}

.study-invite-search input {
  flex: 1 1 auto;
  min-width: 0;
}

.study-invite-list {
  display: grid;
  gap: 0;
}

.study-invite-list > div {
  min-height: 54px;
  padding: 8px 0;
  border-bottom: 1px solid var(--note-line);
}

.study-invite-list > div > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.study-invite-list small,
.study-invite-loading,
.study-invite-empty {
  color: var(--note-muted);
  font-size: 12px;
}

.study-invite-list button {
  flex: 0 0 auto;
  min-height: 34px;
}

.study-analytics-backdrop {
  z-index: 700;
}

.study-analytics-modal {
  width: min(94vw, 680px);
  max-height: min(82dvh, 720px);
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(10, 35, 25, .2);
}

.study-analytics-modal > header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.study-analytics-modal h2 {
  margin: 4px 0 0;
  color: var(--note-ink);
  font-size: clamp(19px, 3vw, 24px);
}

.study-analytics-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin: 20px 0;
}

.study-analytics-stats > div {
  display: grid;
  gap: 3px;
  padding: 14px 10px;
  border-radius: 12px;
  background: var(--note-green-soft);
  text-align: center;
}

.study-analytics-stats strong {
  color: var(--note-green);
  font-size: 21px;
}

.study-analytics-stats span,
.study-analytics-users small {
  color: var(--note-muted);
  font-size: 11px;
}

.study-analytics-users {
  display: grid;
}

.study-analytics-users > button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px;
  border: 0;
  border-top: 1px solid var(--note-line);
  background: #fff;
  color: var(--note-ink);
  text-align: left;
}

.study-analytics-users > button > span {
  display: grid;
  gap: 3px;
}

@media (max-width: 760px) {
  .study-material-heading-actions {
    width: 100%;
  }

  .study-book-upload-panel > form {
    grid-template-columns: minmax(0, 1fr);
  }

  .has-note-editor .note-editor-material {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .has-note-editor .note-pagebar {
    gap: 5px;
    min-height: 48px;
    padding-inline: 8px;
  }

  .has-note-editor .note-pagebar > button {
    min-width: 37px;
    padding-inline: 7px;
  }

  .has-note-editor .note-pagebar > button > span,
  .has-note-editor .note-pagebar label > span {
    display: none;
  }

  .has-note-editor .note-pagebar > small {
    order: 5;
    width: 100%;
    margin: 0;
    font-size: 10px;
    line-height: 1.3;
    text-align: center;
  }

  .has-note-editor .study-touch-mode {
    order: 4;
    width: 100%;
    max-width: 340px;
    margin-inline: auto;
  }

  .has-note-editor .study-reader-view-controls {
    order: 3;
    flex: 1 1 auto;
    justify-content: center;
  }

  .has-note-editor .study-reader-view-controls button {
    flex: 1;
    padding-inline: 7px;
  }

  .has-note-editor .hand-canvas-stage.is-spread-view {
    padding-inline: 8px;
  }

  .has-note-editor .study-spread-companion span {
    right: 4px;
    bottom: 4px;
    padding: 3px 5px;
    font-size: 8px;
  }

  .has-note-editor .study-reference-viewer {
    border-radius: 13px;
  }

  .has-note-editor .study-touch-mode button {
    flex: 1;
    min-width: 0;
    padding-inline: 5px;
  }

  .has-note-editor .note-pagebar .note-page-progress {
    min-width: 48px;
    font-size: 11px;
  }

  .has-note-editor .study-solution-conflict {
    flex-wrap: wrap;
  }

  .study-analytics-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .has-note-editor .hand-canvas-stage.is-material-page.is-ready[data-page-turn] .hand-paper {
    animation: none;
  }

  .has-note-editor .study-page-spread,
  .has-note-editor .study-reference-viewer {
    transition: none;
  }
}
