.study-button { left: 8px; }
.study-button.is-active { color: #fff; background: var(--accent); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 24%, transparent); }
#attachment-button { left: 48px; }
#message-input { padding-left: 96px; }

.study-dock {
  display: flex;
  width: calc(100% - 6px);
  min-height: 58px;
  align-items: center;
  gap: 6px;
  margin: 0 3px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--ai-border));
  border-radius: 18px;
  padding: 5px 6px;
  background: color-mix(in srgb, var(--surface-solid) 76%, transparent);
  box-shadow: 0 8px 24px rgba(72, 56, 104, .09);
  backdrop-filter: blur(18px) saturate(1.08);
  -webkit-backdrop-filter: blur(18px) saturate(1.08);
}
.study-dock-main { display: flex; min-width: 0; flex: 1; align-items: center; gap: 10px; border: 0; padding: 0; color: var(--text); background: transparent; text-align: left; }
.study-dock-thumb { position: relative; display: grid; width: 46px; height: 46px; flex: 0 0 auto; overflow: hidden; place-items: center; border-radius: 13px; color: var(--accent-deep); background: var(--accent-soft); font: 700 15px/1 Georgia, serif; }
.study-dock-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.study-dock-thumb img:not([src]), .study-dock-thumb img[src=""] { display: none; }
.study-dock-thumb img[src]:not([src=""]) + span { display: none; }
.study-dock-copy { display: grid; min-width: 0; gap: 3px; }
.study-dock-copy small { color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.study-dock-copy strong { overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.study-dock-close { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 50%; color: var(--muted); background: transparent; }
.study-dock-close:active { background: var(--accent-soft); transform: scale(.94); }
.study-dock-close svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.study-dialog { width: min(calc(100% - 24px), 760px); max-width: 760px; border: 0; padding: 0; color: var(--text); background: transparent; }
.study-dialog::backdrop { background: rgba(29, 24, 37, .34); backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
.study-card { max-height: min(88dvh, 880px); overflow: hidden; border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--ai-border)); border-radius: 28px; padding: 20px; background: color-mix(in srgb, var(--surface-solid) 92%, transparent); box-shadow: 0 24px 80px rgba(37, 28, 53, .24); backdrop-filter: blur(24px) saturate(1.08); -webkit-backdrop-filter: blur(24px) saturate(1.08); }
.study-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.study-head h2 { margin: 0; font: 600 22px/1.2 Georgia, "Noto Serif SC", serif; }
.study-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 17px 0 14px; border-radius: 16px; padding: 4px; background: var(--accent-soft); }
.study-tabs button { min-height: 42px; border: 0; border-radius: 12px; color: var(--muted); background: transparent; font: inherit; font-size: 12px; font-weight: 650; }
.study-tabs button.is-active { color: var(--accent-deep); background: var(--surface-solid); box-shadow: 0 3px 10px rgba(62, 48, 83, .1); }
.study-panel { display: none; max-height: min(68dvh, 680px); overflow-y: auto; overscroll-behavior: contain; padding: 3px 2px 2px; }
.study-panel.is-active { display: block; animation: studyPanelIn 160ms ease-out; }
.study-empty { display: grid; min-height: 420px; place-content: center; justify-items: center; padding: 34px 18px; text-align: center; }
.study-empty.compact { min-height: 260px; }
.study-empty > span { display: grid; width: 68px; height: 68px; place-items: center; border-radius: 22px; color: var(--accent-deep); background: var(--accent-soft); font: 700 15px/1 Georgia, serif; }
.study-empty h3, .study-setup-intro h3 { margin: 17px 0 7px; font: 600 18px/1.35 Georgia, "Noto Serif SC", serif; }
.study-empty p, .study-setup-intro p { max-width: 430px; margin: 0 0 18px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.study-primary, .study-secondary { min-height: 45px; border-radius: 14px; padding: 0 18px; font: inherit; font-size: 12px; font-weight: 700; }
.study-primary { border: 0; color: #fff; background: var(--accent); box-shadow: 0 5px 16px color-mix(in srgb, var(--accent) 24%, transparent); }
.study-secondary { width: 100%; border: 1px solid var(--ai-border); color: var(--accent-deep); background: color-mix(in srgb, var(--surface-solid) 70%, transparent); }
.study-primary:active, .study-secondary:active { transform: scale(.985); }
.study-pdf-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 2px 10px; }
.study-pdf-meta strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.study-pdf-meta button { border: 0; padding: 7px 10px; color: var(--accent); background: transparent; font-size: 11px; }
.study-canvas-wrap { position: relative; display: grid; min-height: 240px; max-height: min(55dvh, 570px); overflow: auto; place-items: start center; border: 1px solid var(--ai-border); border-radius: 16px; padding: 10px; background: color-mix(in srgb, var(--bg) 76%, #fff); }
.study-canvas-wrap canvas { display: block; max-width: 100%; height: auto; border-radius: 3px; background: #fff; box-shadow: 0 8px 24px rgba(35, 28, 45, .12); }
.study-loading { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; color: var(--muted); background: color-mix(in srgb, var(--surface-solid) 80%, transparent); backdrop-filter: blur(8px); font-size: 12px; }
.study-page-controls { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; margin: 10px 0; }
.study-page-controls > button { width: 44px; height: 44px; border: 1px solid var(--ai-border); border-radius: 13px; color: var(--accent); background: var(--surface-solid); font-size: 27px; }
.study-page-controls > button:disabled { opacity: .35; }
.study-page-controls label { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: 11px; }
.study-page-controls input { width: 62px; height: 40px; border: 1px solid var(--ai-border); border-radius: 12px; outline: 0; color: var(--text); background: var(--surface-solid); text-align: center; font: inherit; }
.study-pdf-viewer > .study-primary { width: 100%; }
.study-scan-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 4px 0 14px; }
.study-scan-cell { position: relative; min-width: 0; }
.study-scan-item { position: relative; display: block; width: 100%; overflow: hidden; border: 2px solid transparent; border-radius: 15px; padding: 0; background: var(--accent-soft); aspect-ratio: 4 / 3; }
.study-scan-item.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }
.study-scan-item img { width: 100%; height: 100%; object-fit: cover; }
.study-scan-item span { position: absolute; right: 6px; bottom: 6px; border-radius: 999px; padding: 4px 7px; color: #fff; background: rgba(30, 25, 40, .7); font-size: 9px; }
.study-scan-remove { position: absolute; top: 5px; right: 5px; display: grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 50%; color: #fff; background: rgba(32, 26, 42, .66); font-size: 20px; line-height: 1; backdrop-filter: blur(7px); }
.study-setup-intro { margin: 4px 2px 14px; }
.study-setup-intro h3 { margin-top: 0; }
.study-steps { margin: 0 0 18px; padding-left: 24px; color: var(--text); font-size: 12px; line-height: 1.75; }
.study-steps li + li { margin-top: 5px; }
.study-setup-field { display: grid; gap: 7px; margin-top: 12px; color: var(--muted); font-size: 10px; font-weight: 700; }
.study-setup-field > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.study-setup-field code { overflow: auto; border: 1px solid var(--ai-border); border-radius: 12px; padding: 11px 12px; color: var(--text); background: color-mix(in srgb, var(--bg) 76%, transparent); font: 10px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: nowrap; }
.study-setup-field button { min-width: 58px; border: 1px solid var(--ai-border); border-radius: 12px; color: var(--accent-deep); background: var(--surface-solid); font-size: 11px; }
.study-secret-note { margin: 12px 2px 2px; color: var(--muted); font-size: 10px; line-height: 1.55; }

@keyframes studyPanelIn { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 560px) {
  .study-dialog { width: calc(100% - 14px); margin-bottom: calc(7px + env(safe-area-inset-bottom)); }
  .study-card { border-radius: 24px; padding: 17px 12px 14px; }
  .study-tabs { margin-top: 14px; }
  .study-empty { min-height: 52dvh; }
  .study-scan-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (orientation: landscape) and (max-height: 650px) {
  .study-card { max-height: 94dvh; }
  .study-panel { max-height: 72dvh; }
  .study-empty { min-height: 270px; }
  .study-canvas-wrap { max-height: 45dvh; }
}

@media (prefers-reduced-motion: reduce) {
  .study-panel.is-active { animation: none; }
}
