.notebook-dialog {
  --nb-surface: var(--cift-surface, #fff);
  --nb-soft: var(--cift-surface-soft, #f7f9fa);
  --nb-line: var(--cift-line, #dfe5ea);
  --nb-ink: var(--cift-ink, #242a31);
  --nb-muted: var(--cift-muted, #5b6772);
  box-sizing: border-box;
  width: min(1000px, calc(100vw - 48px));
  height: min(780px, calc(100dvh - 64px));
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--nb-line);
  border-radius: var(--cift-radius-md, 20px);
  background: var(--nb-surface);
  color: var(--nb-ink);
  box-shadow: var(--cift-shadow-float, 0 18px 48px rgb(0 0 0 / .12));
  font: 14px/1.5 var(--cift-font-ui, sans-serif);
  letter-spacing: 0;
  overflow: hidden;
}
.notebook-dialog::backdrop { background: var(--cift-scrim, rgb(27 39 50 / .3)); backdrop-filter: blur(5px); }
.notebook-dialog[open] { animation: notebook-enter 220ms var(--cift-ease, ease) both; }
.notebook-dialog *, .notebook-dialog *::before, .notebook-dialog *::after { box-sizing: border-box; }
.notebook-dialog [hidden] { display: none !important; }
.notebook-dialog :is(button, input, select) { font: inherit; letter-spacing: 0; }
.notebook-dialog button { cursor: pointer; }
.notebook-dialog button:disabled { opacity: .45; cursor: default; }
.notebook-dialog :is(button, input, select, summary):focus-visible { outline: 2px solid var(--brand-focus, #64859b); outline-offset: 3px; box-shadow: none; }
.notebook-dialog h2:focus { outline: none; }
.notebook-dialog :is(h1, h2, h3, p, ul, dl, dd) { margin: 0; }
.notebook-dialog .notebook-icon, .notebook-icon { display: inline-block; flex: 0 0 auto; width: 20px; height: 20px; vertical-align: middle; }
.notebook-shell { display: flex; height: 100%; min-height: 0; flex-direction: column; }
.notebook-header { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--nb-line); }
.notebook-heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
.notebook-heading-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 auto; color: var(--cift-accent); background: var(--cift-control); border-radius: 50%; }
.notebook-heading h1 { font-size: 21px; font-weight: 700; line-height: 1.4; }
.notebook-counts { margin-top: 4px !important; color: var(--nb-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.notebook-header-actions { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.notebook-dialog :is(.notebook-icon-button, .notebook-source-button), .notebook-source-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 50%; color: var(--cift-ink); background: transparent; transition: background 160ms ease, color 160ms ease; }
.notebook-dialog .notebook-icon-button:hover, .notebook-source-button:hover { background: var(--cift-control); }
.notebook-dialog :is(.notebook-primary, .notebook-secondary, .notebook-danger) { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; transition: background 160ms ease; }
.notebook-dialog .notebook-primary { background: var(--cift-accent, #496b80); color: var(--cift-on-accent, #fff); }
.notebook-dialog .notebook-primary:not(:disabled):hover { background: var(--cift-accent-hover, #3c5c70); }
.notebook-dialog .notebook-secondary { background: var(--cift-control); color: var(--nb-ink); }
.notebook-dialog .notebook-secondary:hover { background: var(--cift-control-hover); }
.notebook-dialog .notebook-danger { background: var(--cift-danger-bg); color: var(--cift-danger); }
.notebook-workspace { display: grid; grid-template-columns: 290px minmax(0, 1fr); flex: 1; min-height: 0; }
.notebook-directory { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--nb-line); background: var(--nb-soft); }
.notebook-search-row { padding: 18px 16px 0; }
.notebook-search { display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 12px; border: 1px solid var(--nb-line); border-radius: 999px; color: var(--nb-muted); background: var(--nb-surface); }
.notebook-search .notebook-icon { width: 17px; height: 17px; }
.notebook-search input { width: 100%; min-width: 0; min-height: 42px; padding: 8px 0; color: var(--nb-ink); border: 0; border-radius: 0; background: transparent; font-size: 13px; outline: none; }
.notebook-search input:focus-visible { outline: none; }
.notebook-search:focus-within { outline: 2px solid var(--brand-focus, #64859b); outline-offset: 2px; }
.notebook-search input::placeholder { color: var(--nb-muted); opacity: 1; }
.notebook-list-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; padding: 4px 18px; color: var(--nb-muted); font-size: 12px; }
.notebook-list-tools select { max-width: 136px; min-height: 44px; padding: 8px 4px; color: var(--nb-ink); background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: 12px; }
.notebook-list-tools option { color: var(--nb-ink); background: var(--nb-surface); }
.notebook-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--cift-scrollbar) transparent; scroll-padding: 8px; }
.notebook-list ul { list-style: none; padding: 0 8px 16px; }
.notebook-word-row { display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 14px 12px; border: 1px solid transparent; border-radius: 8px; text-align: left; background: transparent; color: var(--nb-ink); transition: background 160ms ease, border-color 160ms ease; }
.notebook-word-row:hover { background: var(--cift-control); }
.notebook-word-row.is-selected { border-color: var(--nb-line); background: var(--nb-surface); box-shadow: var(--cift-shadow-soft); }
.notebook-word-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; }
.notebook-word-row-top strong { min-width: 0; font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
.notebook-word-state { color: var(--nb-muted); flex: 0 0 auto; font-size: 11px; }
.notebook-word-state.is-due, .notebook-dates .is-due { color: var(--cift-accent); font-weight: 650; }
.notebook-word-meaning { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--nb-muted); overflow-wrap: anywhere; }
.notebook-word-meta { color: var(--nb-muted); font-size: 11px; }
.notebook-detail { min-width: 0; min-height: 0; padding: 14px 30px 30px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--cift-scrollbar) transparent; }
.notebook-detail-top { display: flex; justify-content: flex-end; min-height: 44px; margin-bottom: 4px; }
.notebook-dialog .notebook-back { display: none; }
.notebook-dialog .notebook-remove { color: var(--nb-muted); }
.notebook-dialog .notebook-remove:hover { background: var(--cift-danger-bg); color: var(--cift-danger); }
.notebook-word-heading { display: flex; align-items: center; gap: 16px; }
.notebook-word-heading > div { min-width: 0; }
.notebook-word-heading h2 { font-size: 32px; font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.notebook-phonetic { margin-top: 8px !important; color: var(--nb-muted); font-size: 15px; overflow-wrap: anywhere; }
.notebook-word-heading .notebook-icon-button { background: var(--nb-soft); }
.notebook-dates { display: flex; flex-wrap: wrap; gap: 12px 28px; margin-top: 22px !important; padding-bottom: 24px; border-bottom: 1px solid var(--nb-line); font-size: 12px; }
.notebook-dates dt { color: var(--nb-muted); margin-bottom: 4px; }
.notebook-dates dd { font-variant-numeric: tabular-nums; }
.notebook-definitions { padding-top: 24px; }
.notebook-dialog h3 { font-size: 13px; font-weight: 650; }
.notebook-definitions ul { list-style: none; padding: 12px 0 0; }
.notebook-definitions li { display: flex; align-items: baseline; gap: 12px; padding: 5px 0; font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; }
.notebook-part-of-speech { flex: 0 0 auto; min-width: 24px; color: var(--nb-muted); font-size: 12px; }
.notebook-dictionary { margin-top: 12px; }
.notebook-dictionary summary { padding: 8px 0; color: var(--nb-muted); font-size: 12px; cursor: pointer; }
.notebook-dictionary p { padding: 8px 0; font-size: 14px; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere; }
.notebook-contexts { margin-top: 28px; }
.notebook-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.notebook-section-heading > span { color: var(--nb-muted); font-size: 12px; }
.notebook-study-context { margin-top: 16px; padding: 16px 0; border-top: 1px solid var(--cift-line, #dfe5ea); color: var(--cift-ink, #242a31); text-align: left; }
.notebook-context-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--cift-muted, #5b6772); font-size: 12px; line-height: 1.5; }
.notebook-context-heading > span { min-width: 0; overflow-wrap: anywhere; }
.notebook-context-english { margin: 12px 0 0 !important; font-family: var(--cift-font-reading, Georgia, serif); font-size: 17px; line-height: 1.8; overflow-wrap: anywhere; white-space: pre-line; }
.notebook-context-english mark { padding: 1px 2px; color: var(--brand-blue-ink, #3c5b70); background: var(--brand-blue-soft, #e3ecf2); border-radius: 3px; }
.notebook-context-translation { margin: 10px 0 0 !important; color: var(--cift-muted, #5b6772); font-size: 13px; line-height: 1.8; white-space: pre-line; overflow-wrap: anywhere; }
.notebook-context-gloss { display: flex; align-items: baseline; gap: 12px; margin: 14px 0 0 !important; font-size: 14px; line-height: 1.65; }
.notebook-context-gloss > span { flex: 0 0 auto; color: var(--cift-muted, #5b6772); font-size: 12px; }
.notebook-context-gloss strong { font-weight: 550; overflow-wrap: anywhere; }
.notebook-context-gloss.is-pending strong { color: var(--cift-muted, #5b6772); font-weight: 400; }
.notebook-gloss-source { min-width: 0; }
.notebook-gloss-source summary { display: inline; color: var(--cift-ink); font-weight: 550; text-decoration-line: underline; text-decoration-style: dashed; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: color-mix(in srgb, var(--cift-muted) 58%, transparent); cursor: pointer; list-style: none; }
.notebook-gloss-source summary::-webkit-details-marker { display: none; }
.notebook-gloss-source summary:hover { text-decoration-color: var(--cift-accent); }
.notebook-gloss-source > div { display: grid; gap: 5px; max-width: 520px; margin-top: 10px; padding: 12px 14px; border: 1px solid var(--cift-line); border-radius: 8px; background: var(--cift-surface-soft); box-shadow: var(--cift-shadow-soft); }
.notebook-gloss-source > div strong { font-size: 12px; font-weight: 650; }
.notebook-gloss-source > div span, .notebook-gloss-source > div p { color: var(--cift-muted); font-size: 11px; line-height: 1.65; }
.notebook-context-time { display: block; margin-top: 12px; font-size: 11px; color: var(--cift-muted, #5b6772); }
.notebook-muted { margin-top: 12px !important; color: var(--nb-muted); font-size: 13px; }
.notebook-delete-confirm { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding: 14px; border-radius: 8px; color: var(--cift-danger); background: var(--cift-danger-bg); font-size: 13px; }
.notebook-delete-confirm > p { flex: 1 1 200px; }
.notebook-delete-confirm > div { display: flex; gap: 8px; }
.notebook-error { margin-top: 14px !important; color: var(--cift-danger); font-size: 13px; overflow-wrap: anywhere; }
.notebook-empty { display: flex; min-height: 260px; align-items: center; justify-content: center; flex-direction: column; gap: 12px; padding: 32px 20px; text-align: center; color: var(--nb-muted); }
.notebook-empty > .notebook-icon { width: 32px; height: 32px; margin-bottom: 4px; }
.notebook-empty h2 { color: var(--nb-ink); font-size: 16px; font-weight: 600; }
.notebook-empty p { max-width: 240px; font-size: 13px; line-height: 1.8; overflow-wrap: anywhere; }
.notebook-empty button { margin-top: 4px; }
.notebook-detail > .notebook-empty { height: 100%; }
.notebook-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--nb-muted); font-size: 13px; }
.notebook-loading > span { width: 16px; height: 16px; border: 1.5px solid var(--nb-line); border-top-color: var(--cift-accent); border-radius: 50%; animation: notebook-spin 900ms linear infinite; }
.notebook-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.notebook-save-button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--cift-line); border-radius: 999px; background: var(--cift-control); color: var(--cift-ink); font: 600 13px/1.4 var(--cift-font-ui); cursor: pointer; }
.notebook-save-button:hover { background: var(--cift-control-hover); }
.notebook-save-button:disabled { cursor: default; opacity: .6; }
.notebook-save-button[aria-pressed="true"], .notebook-save-button.is-saved { color: var(--brand-blue-ink); background: var(--brand-blue-soft); }
.notebook-save-note { margin: 8px 0 0; color: var(--cift-muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.notebook-book-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--cift-ink); }
.notebook-book-strip label { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.notebook-book-strip select { max-width: 220px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--cift-line); border-radius: 999px; background: var(--cift-surface); color: var(--cift-ink); font: inherit; }
.notebook-book-strip button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 14px; border: 1px solid var(--cift-line); border-radius: 999px; background: var(--cift-control); color: var(--cift-ink); font: 600 13px/1.4 var(--cift-font-ui); cursor: pointer; }
.notebook-book-strip button:hover { background: var(--cift-control-hover); }
html.cift-ui .word-lookup-dialog:has(> .word-lookup-actions) { display: flex; flex-direction: column; overflow: hidden; max-height: min(760px, calc(100dvh - 44px)); }
html.cift-ui .word-lookup-dialog:has(> .word-lookup-actions) > .word-lookup-head { flex: 0 0 auto; }
html.cift-ui .word-lookup-dialog:has(> .word-lookup-actions) > .word-lookup-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
html.cift-ui .word-lookup-dialog > .word-lookup-actions { display: flex; align-items: center; flex-wrap: wrap; flex: 0 0 auto; gap: 10px; margin: 0; padding: 16px 22px; border-top: 1px solid var(--cift-line); background: var(--cift-surface); }
html.cift-ui .word-lookup-dialog > .word-lookup-actions > button { min-height: 44px; }
html.cift-ui .word-lookup-dialog > .word-lookup-actions > .icon-button,
html.cift-ui .word-lookup-dialog > .word-lookup-head > .icon-button { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 44px; height: 44px; min-height: 44px; padding: 0; }
.study-app-shell:has(> .notebook-book-strip) { grid-template-rows: auto auto minmax(0, 1fr); }
.study-app-shell > .notebook-book-strip { min-height: 64px; padding: 10px max(16px, calc((100vw - 920px) / 2)); border-bottom: 1px solid var(--cift-line); background: var(--cift-bg); }
.study-app-shell > .notebook-book-strip + .study-fullscreen { min-height: 0; }
@keyframes notebook-enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes notebook-spin { to { transform: rotate(360deg); } }
@media (max-width: 700px) {
  .notebook-dialog { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .notebook-header { gap: 12px; padding: max(14px, env(safe-area-inset-top)) 16px 14px; }
  .notebook-heading { gap: 0; }
  .notebook-heading-icon { display: none; }
  .notebook-heading h1 { font-size: 19px; }
  .notebook-counts { font-size: 11px; }
  .notebook-header-actions { gap: 4px; }
  .notebook-dialog .notebook-primary { min-height: 44px; padding: 10px 12px; font-size: 12px; }
  .notebook-primary .notebook-icon { display: none; }
  .notebook-workspace { display: block; overflow: hidden; }
  .notebook-directory { height: 100%; border-right: 0; }
  .notebook-detail { display: none; height: 100%; padding: 10px 22px max(24px, env(safe-area-inset-bottom)); }
  .notebook-dialog[data-view="detail"] .notebook-directory { display: none; }
  .notebook-dialog[data-view="detail"] .notebook-detail { display: block; animation: notebook-enter 200ms var(--cift-ease, ease) both; }
  .notebook-dialog .notebook-back { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px 0 0; border: 0; background: transparent; color: var(--nb-muted); font-size: 13px; }
  .notebook-detail-top { justify-content: space-between; margin-bottom: 18px; }
  .notebook-search-row { padding: 16px 16px 0; }
  .notebook-search input { font-size: 16px; }
  .notebook-list-tools { padding-left: 20px; padding-right: 20px; }
  .notebook-list ul { padding: 0 12px max(24px, env(safe-area-inset-bottom)); }
  .notebook-word-row { padding: 16px 12px; }
  .notebook-word-row.is-selected { background: transparent; box-shadow: none; border-color: transparent; }
  .notebook-word-row:hover { background: var(--cift-control); }
  .notebook-word-row-top strong { font-size: 19px; }
  .notebook-word-meaning { font-size: 14px; }
  .notebook-dates { gap: 12px 24px; }
  .notebook-book-strip { width: 100%; }
  .notebook-book-strip label { flex: 1 1 auto; min-width: 0; }
  .notebook-book-strip select { flex: 1; min-width: 0; max-width: 100%; }
}
@media (max-width: 360px) {
  .notebook-header { padding-left: 12px; padding-right: 8px; }
  .notebook-counts { max-width: 156px; }
  .notebook-detail { padding-left: 18px; padding-right: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .notebook-dialog[open], .notebook-dialog[data-view="detail"] .notebook-detail, .notebook-loading > span { animation: none; }
  .notebook-dialog *, .notebook-save-button { transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
