:root {
  --ic-ink: #102542;
  --ic-ink-soft: #274c77;
  --ic-accent: #f4a261;
  --ic-accent-2: #2a9d8f;
  --ic-paper: #fffdf9;
  --ic-paper-2: #f6f1e9;
  --ic-line: rgba(16, 37, 66, 0.12);
  --ic-shadow: 0 24px 60px rgba(16, 37, 66, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--ic-ink);
  background:
    radial-gradient(circle at top left, rgba(244, 162, 97, 0.32), transparent 30%),
    radial-gradient(circle at bottom right, rgba(42, 157, 143, 0.24), transparent 26%),
    linear-gradient(145deg, #fbfaf7 0%, #f3efe6 46%, #ebf0f4 100%);
}

body.study-mode-fullscreen {
  overflow: hidden;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(16, 37, 66, 0.98), rgba(29, 53, 87, 0.96));
  color: #fff;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.sidebar-brand,
.workspace-header,
.study-panel-head,
.editor-head,
.drawing-head,
.profile-tile,
.folder-row,
.card-actions,
.section-label,
.header-actions,
.control-bar,
.control-pills {
  display: flex;
  align-items: center;
}

.sidebar-brand,
.workspace-header,
.study-panel-head,
.drawing-head,
.folder-row,
.control-bar {
  justify-content: space-between;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  opacity: 0.7;
}

.sidebar h1,
.workspace h2,
.study-panel h3 {
  font-family: "Fraunces", serif;
}

.sidebar h1 {
  font-size: 2.15rem;
  margin: 0.35rem 0 0;
}

.sidebar-section {
  margin-top: 2rem;
}

.section-label {
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}

.folder-tree {
  display: grid;
  gap: 0.45rem;
}

.folder-children {
  list-style: none;
  margin: 0.4rem 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.folder-node {
  list-style: none;
}

.folder-row {
  gap: 0.6rem;
  padding: 0.7rem 0.75rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.18s ease, background 0.18s ease;
}

.folder-row:hover {
  transform: translateX(2px);
  background: rgba(255, 255, 255, 0.11);
}

.folder-row.active {
  background: rgba(244, 162, 97, 0.2);
  border-color: rgba(244, 162, 97, 0.45);
}

.folder-title-btn {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  min-width: 0;
}

.folder-title-btn span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.07);
}

.folder-actions {
  display: flex;
  gap: 0.25rem;
}

.folder-actions .btn {
  --bs-btn-padding-y: 0.2rem;
  --bs-btn-padding-x: 0.4rem;
  --bs-btn-font-size: 0.8rem;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 1rem;
}

.profile-tile {
  justify-content: space-between;
  gap: 1rem;
  border-radius: 20px;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.workspace {
  padding: 1.75rem;
}

#cardModal .modal-content,
#cardModal #cardForm {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

#cardModal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--ic-line);
  box-shadow: var(--ic-shadow);
}

.mobile-brand-title {
  font-family: "Fraunces", serif;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
}

.mobile-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#mobileSidebar {
  background: linear-gradient(180deg, rgba(16, 37, 66, 0.98), rgba(29, 53, 87, 0.96));
  color: #fff;
}

#mobileSidebar .btn-close {
  filter: invert(1) grayscale(1);
}

.mobile-profile-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.workspace-header {
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.workspace h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0.25rem 0;
}

.guest-banner {
  border-radius: 22px;
  border: 1px solid rgba(244, 162, 97, 0.38);
}

.header-actions,
.control-pills,
.card-actions,
.drawing-tools {
  gap: 0.5rem;
}

.control-bar {
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--ic-line);
  box-shadow: var(--ic-shadow);
}

.resume-study-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.85rem 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--ic-line);
  box-shadow: var(--ic-shadow);
}

.resume-study-copy {
  min-width: 0;
}

.resume-study-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.search-wrap {
  flex: 1;
  min-width: 220px;
}

.search-field-shell {
  position: relative;
}

.search-field-shell .search-field-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(16, 37, 66, 0.5);
  pointer-events: none;
}

.search-field-shell input {
  padding-left: 2.8rem;
  padding-right: 2.8rem;
  border-radius: 999px;
  min-height: 48px;
}

.search-subheading {
  margin-top: 0.45rem;
  padding: 0 0.25rem;
}

.search-clear-btn {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: rgba(16, 37, 66, 0.55);
  padding: 0;
  line-height: 1;
  display: none;
  z-index: 2;
}

.search-clear-btn i {
  font-size: 1.05rem;
}

.search-clear-btn:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 992px) {
  .search-clear-btn {
    display: none !important;
  }
}

.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.12rem 0.18rem 0.12rem 0.65rem;
  border: 1px solid var(--ic-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ic-ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sort-control .form-select {
  min-width: 138px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  background-color: transparent;
  box-shadow: none;
  color: var(--ic-ink);
  font-size: 0.72rem;
  font-weight: 600;
  padding-top: 0.22rem;
  padding-bottom: 0.22rem;
  padding-right: 1.75rem;
}

.sort-control .form-select:focus {
  box-shadow: none;
}

.study-panel {
  margin-bottom: 1.5rem;
  padding: 1.25rem;
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.82), rgba(255, 249, 240, 0.9));
  border: 1px solid var(--ic-line);
  box-shadow: var(--ic-shadow);
}

.study-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.study-card-shell {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  perspective: 1400px;
  -webkit-perspective: 1400px;
}

.study-nav-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.study-swipe-hint {
  font-size: 0.9rem;
  color: rgba(16, 37, 66, 0.68);
}

.study-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 46px;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--ic-line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ic-ink);
}

.study-nav:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.study-card {
  --study-swipe-x: 0px;
  position: relative;
  width: min(100%, 860px);
  min-height: 420px;
  border-radius: 30px;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transform: translateX(var(--study-swipe-x));
  transition: transform 0.3s ease;
  cursor: pointer;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}

.study-card.is-zoomed {
  touch-action: pan-x pan-y pinch-zoom;
}

.study-card.is-dragging {
  transition: none;
}

.study-card-face {
  --study-zoom-scale: 1;
  position: absolute;
  inset: 0;
  border-radius: 30px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  overflow: auto;
  padding: 2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(250, 248, 243, 0.98)),
    repeating-linear-gradient(180deg, transparent 0, transparent 32px, rgba(16, 37, 66, 0.06) 33px, transparent 34px);
  border: 1px solid rgba(16, 37, 66, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 16px 40px rgba(16, 37, 66, 0.12);
  transition: transform 0.3s ease, opacity 0.2s ease;
  overscroll-behavior: contain;
}

.study-zoom-content {
  width: max(100%, calc(100% * var(--study-zoom-scale)));
  min-height: max(100%, calc(100% * var(--study-zoom-scale)));
  font-size: calc(1rem * var(--study-zoom-scale));
  transform-origin: top left;
}

.study-card-face.is-zoomed {
  cursor: zoom-out;
}

.study-card-front {
  opacity: 1;
  transform: rotateY(0deg) translateZ(1px);
  -webkit-transform: rotateY(0deg) translateZ(1px);
}

.study-card-back {
  opacity: 0;
  transform: rotateY(180deg) translateZ(1px);
  -webkit-transform: rotateY(180deg) translateZ(1px);
}

.study-card.is-flipped .study-card-front {
  opacity: 0;
  transform: rotateY(-180deg) translateZ(1px);
  -webkit-transform: rotateY(-180deg) translateZ(1px);
}

.study-card.is-flipped .study-card-back {
  opacity: 1;
  transform: rotateY(0deg) translateZ(1px);
  -webkit-transform: rotateY(0deg) translateZ(1px);
}

.study-card-face img,
.card-preview img,
.rich-block img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  display: block;
  margin-top: 0.75rem;
}

.study-card-face img {
  max-width: min(100%, calc(520px * var(--study-zoom-scale)));
  max-height: calc(320px * var(--study-zoom-scale));
  width: auto;
  object-fit: contain;
  margin-left: auto;
  margin-right: auto;
}

.study-card-face.is-zoomed img {
  width: min(100%, calc(520px * var(--study-zoom-scale)));
  max-width: none;
  max-height: none;
  margin-left: 0;
  margin-right: 0;
}

.study-card-face.is-zoomed .drawing-preview {
  width: min(100%, calc(800px * var(--study-zoom-scale)));
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.card-preview img,
.rich-block img {
  max-height: 220px;
  width: auto;
  object-fit: contain;
  margin-left: auto;
  margin-right: auto;
}

.study-card-face .drawing-preview,
.card-preview .drawing-preview {
  margin-top: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(16, 37, 66, 0.12);
  background: #fff;
}

.study-panel.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1080;
  margin: 0;
  padding:
    calc(1rem + env(safe-area-inset-top))
    calc(1rem + env(safe-area-inset-right))
    calc(1rem + env(safe-area-inset-bottom))
    calc(1rem + env(safe-area-inset-left));
  border-radius: 0;
  border: none;
  box-shadow: none;
  background:
    radial-gradient(circle at top left, rgba(244, 162, 97, 0.24), transparent 28%),
    radial-gradient(circle at bottom right, rgba(42, 157, 143, 0.2), transparent 24%),
    linear-gradient(145deg, #fbfaf7 0%, #f3efe6 46%, #ebf0f4 100%);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.study-panel.is-fullscreen .study-panel-head {
  gap: 1rem;
}

.study-panel.is-fullscreen .study-card-shell {
  flex: 1;
  min-height: 0;
  margin-top: 1.25rem;
}

.study-panel.is-fullscreen .study-card {
  width: min(100%, 1100px);
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

.study-panel.is-fullscreen .study-card-face {
  padding: clamp(1rem, 2vw, 2rem);
}

.study-panel.is-fullscreen .study-nav-row {
  margin-top: 1.25rem;
}

@media (orientation: landscape) {
  .study-panel.is-fullscreen .study-card {
    width: min(100%, calc((100dvh - 12rem) * 1.6));
  }
}

@media (orientation: portrait) {
  .study-panel.is-fullscreen .study-card {
    width: min(100%, calc((100dvh - 13rem) * 0.74));
  }
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
}

.card-tile {
  border-radius: 24px;
  padding: 1.15rem;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(16, 37, 66, 0.1);
  box-shadow: var(--ic-shadow);
  display: grid;
  gap: 1rem;
}

.card-tile-head {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: flex-start;
}

.card-title {
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.3;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.folder-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.32rem 0.7rem;
  font-size: 0.78rem;
  background: rgba(39, 76, 119, 0.09);
  color: var(--ic-ink-soft);
}

.card-preview {
  max-height: 220px;
  overflow: auto;
  padding-right: 0.15rem;
}

.card-actions {
  justify-content: space-between;
}

.card-actions .left-actions,
.card-actions .right-actions {
  display: flex;
  gap: 0.45rem;
}

.empty-state {
  padding: 1rem 0 2rem;
}

.empty-card {
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed rgba(16, 37, 66, 0.18);
}

.editor-tabs .nav-link.active {
  background: var(--ic-ink);
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.editor-pane,
.drawing-pane {
  border-radius: 22px;
  border: 1px solid var(--ic-line);
  background: #fff;
  padding: 1rem;
}

.editor-pane.solo {
  padding-bottom: 1.25rem;
}

.editor-head,
.drawing-head {
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.editor-head {
  justify-content: space-between;
  flex-wrap: wrap;
}

.editor-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.editor-tool-toggle,
.drawing-close,
.drawing-mode,
.drawing-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ic-ink);
  border-radius: 14px;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.8rem;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.editor-tool-toggle {
  min-width: 2.5rem;
  padding-inline: 0.7rem;
  color: rgba(16, 37, 66, 0.78);
}

.editor-tool-toggle i,
.drawing-close i,
.drawing-mode i,
.drawing-action i {
  font-size: 1rem;
}

.editor-tool-toggle.is-active,
.drawing-mode.active {
  border: 1px solid rgba(16, 37, 66, 0.9);
}

.editor-tool-toggle:not(.is-active),
.drawing-mode:not(.active) {
  border: 0;
}

.editor-tool-toggle:hover,
.drawing-close:hover,
.drawing-action:hover,
.drawing-mode:hover {
  background: rgba(16, 37, 66, 0.06);
}

.editor-head span,
.drawing-head span {
  font-weight: 700;
}

.quill-host {
  min-height: 280px;
  border-radius: 18px;
}

.editor-pane .ql-toolbar {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  background: rgba(246, 241, 233, 0.75);
}

.editor-pane .ql-toolbar .ql-formats {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.5rem;
}

.editor-pane .ql-toolbar .ql-formats:last-child {
  margin-right: 0;
}

.editor-pane .ql-toolbar button,
.editor-pane .ql-toolbar .ql-picker-label {
  border: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  transition: box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.editor-pane .ql-toolbar button:hover,
.editor-pane .ql-toolbar .ql-picker-label:hover {
  background: rgba(16, 37, 66, 0.06);
}

.editor-pane .ql-toolbar button.ql-active,
.editor-pane .ql-toolbar .ql-picker-label.ql-active {
  box-shadow: inset 0 0 0 1px rgba(16, 37, 66, 0.95) !important;
  outline: 1px solid rgba(16, 37, 66, 0.95) !important;
  outline-offset: 0 !important;
  background: rgba(16, 37, 66, 0.08) !important;
}

.editor-pane .ql-toolbar button svg {
  display: block;
}

.editor-pane .ql-toolbar button.ql-draw {
  width: 2rem;
  min-width: 2rem;
  padding: 0.2rem;
  line-height: 1;
}

.editor-pane .ql-toolbar button.ql-draw svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.quill-host .ql-container {
  min-height: 220px;
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.quill-host .ql-editor {
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
}

.quill-host .ql-editor .ql-font-serif {
  font-family: "Fraunces", serif;
}

.quill-host .ql-editor .ql-font-monospace {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.quill-host .ql-editor .ql-size-small {
  font-size: 0.875rem;
}

.quill-host .ql-editor .ql-size-large {
  font-size: 1.35rem;
}

.quill-host .ql-editor .ql-size-huge {
  font-size: 1.8rem;
  line-height: 1.25;
}

.editor-pane .ql-toolbar .ql-picker.ql-font,
.editor-pane .ql-toolbar .ql-picker.ql-size {
  width: 7rem;
}

.editor-pane .ql-toolbar .ql-picker.ql-size {
  width: 5.5rem;
}

.editor-pane .ql-toolbar .ql-picker.ql-font .ql-picker-label::before,
.editor-pane .ql-toolbar .ql-picker.ql-font .ql-picker-item::before {
  content: "Font: Sans";
}

.editor-pane .ql-toolbar .ql-picker.ql-font .ql-picker-label[data-value="serif"]::before,
.editor-pane .ql-toolbar .ql-picker.ql-font .ql-picker-item[data-value="serif"]::before {
  content: "Font: Fraunces";
  font-family: "Fraunces", serif;
}

.editor-pane .ql-toolbar .ql-picker.ql-font .ql-picker-label[data-value="monospace"]::before,
.editor-pane .ql-toolbar .ql-picker.ql-font .ql-picker-item[data-value="monospace"]::before {
  content: "Font: Mono";
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-label::before,
.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-item::before {
  content: "Normal";
}

.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-label[data-value="small"]::before,
.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-item[data-value="small"]::before {
  content: "Small";
}

.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-label[data-value="large"]::before,
.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-item[data-value="large"]::before {
  content: "Large";
}

.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-label[data-value="huge"]::before,
.editor-pane .ql-toolbar .ql-picker.ql-size .ql-picker-item[data-value="huge"]::before {
  content: "Huge";
}

.editor-pane .ql-toolbar button.ql-undo,
.editor-pane .ql-toolbar button.ql-redo {
  width: 2rem;
  min-width: 2rem;
  padding: 0.2rem;
}

.editor-pane .ql-toolbar button.ql-undo svg,
.editor-pane .ql-toolbar button.ql-redo svg {
  display: block;
  width: 1rem;
  height: 1rem;
  margin: 0 auto;
  fill: currentColor;
}

.drop-hint {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: rgba(16, 37, 66, 0.64);
}

.drawing-workspace[hidden] {
  display: none !important;
}

.drawing-workspace {
  position: fixed;
  inset: 0;
  z-index: 1080;
}

.drawing-workspace__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 17, 29, 0.36);
  backdrop-filter: blur(3px);
}

.drawing-workspace__panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  bottom: 1rem;
  width: min(40rem, calc(100vw - 2rem));
  display: flex;
}

.drawing-pane--overlay {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-radius: 28px;
  padding: 1.25rem;
  box-shadow: 0 24px 60px rgba(16, 37, 66, 0.24);
}

.drawing-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawing-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.drawing-close {
  min-width: 2.5rem;
  padding-inline: 0.6rem;
}

.indexcards-inline-image,
.rich-block img,
.study-zoom-content img {
  max-width: 100%;
  height: auto;
  cursor: zoom-in;
}

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(12, 18, 28, 0.72);
  color: #f4f7ff;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.chip.primary {
  border-color: rgba(122, 181, 255, 0.34);
  background: rgba(67, 115, 187, 0.34);
  color: #e8f2ff;
}

.plugin-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(5, 8, 12, 0.88);
  display: grid;
  place-items: center;
  padding: 22px;
}

.plugin-overlay[hidden] {
  display: none;
}

.plugin-overlay-card {
  position: relative;
  width: min(1200px, 100%);
  max-height: min(92vh, 100%);
  display: block;
  background: transparent;
  border: 0;
  border-radius: 18px;
  overflow: visible;
}

.plugin-overlay-head {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2010;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 12px;
  background: transparent;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.plugin-overlay-head.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#pluginOverlayTitle {
  min-width: 0;
  max-width: min(68vw, calc(100vw - 180px));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  color: #f3f7ff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  margin-right: auto;
}

#pluginOverlayClose {
  margin-left: auto;
}

.plugin-overlay-head .chip {
  border-color: transparent;
  background: transparent;
  color: #f3f7ff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  box-shadow: none;
}

.plugin-overlay-body {
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  background: transparent;
  position: relative;
  z-index: 1;
}

.plugin-overlay-dock {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2011;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.plugin-overlay-dock > * {
  pointer-events: auto;
}

.plugin-overlay-dock.is-toolbar {
  left: 50%;
  right: auto;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 920px);
  max-width: calc(100vw - 24px);
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 22, 0.74);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.plugin-overlay-dock.is-toolbar .annotate-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  width: auto;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
}

.plugin-overlay-dock.is-toolbar .annotate-tool-group {
  gap: 8px;
}

.plugin-overlay-dock.is-toolbar .annotate-tool-btn,
.plugin-overlay-dock.is-toolbar .chip {
  min-height: 42px;
}

.plugin-overlay-dock.is-toolbar .annotate-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #eef3fb;
}

.plugin-overlay-dock.is-toolbar .annotate-control-icon {
  font-size: 1rem;
  line-height: 1;
}

.plugin-overlay-dock.is-toolbar input[type="color"] {
  width: 28px;
  height: 28px;
  border: 0;
  padding: 0;
  background: transparent;
}

.plugin-overlay-dock.is-toolbar input[type="range"] {
  width: 96px;
}

.plugin-dock-btn {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 18, 28, 0.72);
  color: #f4f7ff;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.plugin-overlay-image {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 90px);
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
}

.annotate-stage {
  width: min(calc(100vw - 32px), 1200px);
  height: min(calc(100vh - 128px), 820px);
  min-height: 320px;
  background: #111723;
  border-radius: 18px;
  overflow: hidden;
}

.annotate-viewport {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.annotate-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid rgba(229, 230, 238, 0.16);
  background: rgba(10, 14, 22, 0.32);
  position: relative;
  z-index: 2;
}

.annotate-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.annotate-tool-btn {
  min-width: 58px;
}

.annotate-tool-btn.is-active {
  border-color: rgba(122, 181, 255, 0.34);
  background: rgba(67, 115, 187, 0.26);
  color: #e8f2ff;
}

.annotate-canvas-wrap {
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 12px;
  position: relative;
  touch-action: none;
}

.annotate-scene {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  will-change: transform;
}

.annotate-canvas {
  display: block;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.34);
  touch-action: none;
  cursor: crosshair;
}

.annotate-text-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.annotate-text-layer.is-editing,
.annotate-text-layer.is-moving {
  pointer-events: auto;
}

.annotate-text-box {
  position: absolute;
  min-width: 80px;
  min-height: 48px;
  border-radius: 12px;
  background: transparent;
  overflow: visible;
  pointer-events: auto;
}

.annotate-text-box.is-selected {
  z-index: 3;
}

.annotate-text-box:focus-within .annotate-text-controls {
  opacity: 1;
  pointer-events: auto;
}

.annotate-text-input {
  width: 100%;
  min-height: 46px;
  padding: 6px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--annotate-text-color, #ff3b30);
  caret-color: var(--annotate-text-color, #ff3b30);
  font: 600 24px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  overflow: hidden;
}

.annotate-text-input::placeholder {
  color: color-mix(in srgb, var(--annotate-text-color, #ff3b30) 72%, transparent);
}

.annotate-text-box:not(.is-selected):not(.is-editing) .annotate-text-input {
  pointer-events: none;
}

.annotate-text-controls {
  position: absolute;
  top: -34px;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 14, 22, 0.88);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.annotate-text-size-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #f3f7ff;
  font: 700 1rem/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  cursor: pointer;
}

.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(16, 37, 66, 0.28);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.upload-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.upload-overlay-card {
  width: min(100%, 24rem);
  border-radius: 24px;
  padding: 1.4rem 1.5rem;
  color: var(--ic-ink);
  background: rgba(255, 253, 249, 0.96);
  border: 1px solid rgba(16, 37, 66, 0.1);
  box-shadow: 0 24px 60px rgba(16, 37, 66, 0.18);
  display: grid;
  gap: 1rem;
  justify-items: center;
  text-align: center;
}

.upload-overlay-copy strong {
  display: block;
  font-size: 1rem;
  font-weight: 800;
}

.upload-overlay-copy p {
  margin: 0.35rem 0 0;
  color: rgba(16, 37, 66, 0.7);
  font-size: 0.92rem;
}

.upload-overlay-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.upload-overlay-spinner span {
  width: 0.78rem;
  height: 0.78rem;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--ic-accent), var(--ic-accent-2));
  animation: upload-overlay-bounce 0.9s ease-in-out infinite;
}

.upload-overlay-spinner span:nth-child(2) {
  animation-delay: 0.15s;
}

.upload-overlay-spinner span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes upload-overlay-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0) scale(0.92);
    opacity: 0.55;
  }

  40% {
    transform: translateY(-0.45rem) scale(1.08);
    opacity: 1;
  }
}

.draft-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.draft-discard-btn {
  --bs-btn-padding-y: 0;
  --bs-btn-padding-x: 0;
  color: rgba(16, 37, 66, 0.72);
}

.canvas-wrap {
  border-radius: 18px;
  border: 1px dashed rgba(16, 37, 66, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 249, 244, 1)),
    repeating-linear-gradient(180deg, transparent 0, transparent 28px, rgba(16, 37, 66, 0.045) 29px, transparent 30px);
  overflow: hidden;
  min-height: 0;
  flex: 1 1 auto;
}

.sketch-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 24rem;
  touch-action: none;
  cursor: crosshair;
}

.drawing-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
}

.drawing-tools .form-control-color {
  width: 3rem;
  padding: 0.2rem;
}

.drawing-tools .form-range {
  width: 100%;
  margin: 0;
}

.drawing-mode,
.drawing-action {
  justify-content: flex-start;
  width: 100%;
}

.rich-block {
  line-height: 1.55;
}

.rich-block p:last-child,
.rich-block ul:last-child,
.rich-block ol:last-child,
.rich-block blockquote:last-child {
  margin-bottom: 0;
}

.ql-editor.ql-blank::before {
  color: rgba(16, 37, 66, 0.42);
  font-style: normal;
}

.sortable-ghost {
  opacity: 0.3;
}

@media (max-width: 991.98px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .workspace {
    padding: 1rem;
  }

  .mobile-topbar {
    display: flex;
  }

  #cardModal .modal-header,
  #cardModal .modal-footer {
    position: sticky;
    z-index: 2;
    background: #fff;
  }

  #cardModal .modal-header {
    top: 0;
  }

  #cardModal .modal-footer {
    bottom: 0;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    box-shadow: 0 -10px 24px rgba(16, 37, 66, 0.08);
  }

  .editor-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 3rem;
  }

  .editor-pane {
    margin-bottom: 1.5rem;
  }

  .drawing-workspace__panel {
    inset: 0;
    width: 100%;
  }

  .drawing-pane--overlay {
    border-radius: 0;
    padding: 1rem;
  }

  .sketch-canvas {
    min-height: 18rem;
  }

  .study-card {
    min-height: 360px;
  }

  .study-panel.is-fullscreen {
    padding:
      calc(0.85rem + env(safe-area-inset-top))
      calc(0.85rem + env(safe-area-inset-right))
      calc(0.85rem + env(safe-area-inset-bottom))
      calc(0.85rem + env(safe-area-inset-left));
  }
}

@media (max-width: 575.98px) {
  .mobile-topbar,
  .mobile-profile-tile {
    flex-direction: column;
    align-items: stretch;
  }

  .mobile-topbar-actions {
    width: 100%;
  }

  .mobile-topbar-actions .btn {
    flex: 1;
  }

  .workspace h2 {
    font-size: 2rem;
  }

  .control-pills {
    width: 100%;
  }

  .control-pills .btn {
    flex: 1;
  }

  .card-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .card-actions .left-actions,
  .card-actions .right-actions {
    width: 100%;
  }

  .card-actions .btn {
    flex: 1;
  }

  .study-nav-row {
    flex-wrap: wrap;
  }

  .study-swipe-hint {
    width: 100%;
    text-align: center;
    order: 3;
  }

  .study-panel-head,
  .study-panel-actions {
    align-items: stretch;
  }

  .study-panel-head {
    flex-direction: column;
    gap: 0.75rem;
  }

  .study-panel-actions {
    width: 100%;
    justify-content: stretch;
  }

  .study-panel-actions .btn {
    flex: 1;
  }

  .study-panel.is-fullscreen .study-card-shell {
    margin-top: 0.85rem;
  }

  .study-panel.is-fullscreen .study-nav-row {
    gap: 0.75rem;
    margin-top: 0.85rem;
  }

  .study-panel.is-fullscreen .study-card {
    width: 100%;
  }

  #cardModal .modal-footer {
    justify-content: stretch;
  }

  #cardModal .modal-footer > * {
    width: 100%;
  }
}
