.handnote-page-shell {
    padding: 20px 0 40px;
}

.handnote-header {
    margin-bottom: 28px;
}

.handnote-grade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 22px;
}

.handnote-grade-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 180px;
    padding: 24px;
    border-radius: 20px;
    text-decoration: none;
    color: #1f2530;
    background: linear-gradient(180deg, rgba(255, 250, 241, 0.94), rgba(246, 239, 227, 0.92));
    box-shadow: 0 14px 30px rgba(58, 44, 26, 0.09);
    border: 1px solid rgba(126, 101, 67, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.handnote-grade-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px rgba(58, 44, 26, 0.14);
    color: #1f2530;
}

.handnote-grade-topline {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.handnote-grade-banner {
    font-size: 1rem;
    font-weight: 700;
    color: #7d4e1d;
}

.handnote-grade-subline {
    margin-top: 8px;
    color: #5d6672;
    line-height: 1.45;
}

.handnote-subject-card .subject-overlay {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.handnote-card-copy {
    padding: 20px;
}

.handnote-card-copy .book-subtitle,
.handnote-subject-card .subject-subtitle {
    margin: 4px 0 0;
    font-size: 0.9rem;
    opacity: 0.92;
}

.handnote-editor-shell {
    padding-bottom: 40px;
}

.handnote-main-content {
    align-items: stretch;
}

@media (min-width: 768px) {
    .handnote-main-content.show {
        grid-template-columns: 320px 1fr;
    }
}

@media (min-width: 1200px) {
    .handnote-main-content.show {
        grid-template-columns: 340px 1fr;
    }
}

.chapter-panel {
    background: transparent;
    box-shadow: none;
    border: 0;
    padding: 0;
}

.handnote-control-panel {
    background: #2d2d2f;
    color: #f4f4f4;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.handnote-control-panel h3 {
    color: #f4f4f4;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 12px;
    margin-bottom: 18px;
}

.handnote-control-panel .temperature-label,
.handnote-control-panel .model-group-label,
.handnote-control-panel .handnote-checkbox-row span {
    color: #26272a;
}

.handnote-control-panel .temperature-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.handnote-control-panel .temperature-label .handnote-help {
    margin-left: auto;
}

.handnote-control-panel .model-group-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.handnote-control-panel .model-group-label .handnote-help {
    margin-left: auto;
}

.handnote-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #4b4f57;
    margin-top: 8px;
}

.handnote-control-panel .temp-bound {
    color: #4b4f57;
}

.handnote-control-panel .handnote-range-value {
    color: #1f1f21;
}

.handnote-control-panel .temperature-selector,
.handnote-control-panel .model-group-selector {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(31, 31, 33, 0.08);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.handnote-control-panel input[type="range"] {
    accent-color: #2d2d2f;
}

.handnote-control-panel .handnote-watermark-box {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(31, 31, 33, 0.08);
    margin-bottom: 2em;
}

.handnote-control-panel .handnote-watermark-box input {
    background: rgba(255, 255, 255, 0.9);
    color: #1f1f21;
    border: 1px solid rgba(31, 31, 33, 0.12);
}

.handnote-control-panel .handnote-watermark-box input::placeholder {
    color: rgba(31, 31, 33, 0.45);
}

.handnote-control-panel .model-group-labels span {
    color: #4b4f57;
}

.handnote-control-panel .model-group-labels span.active {
    color: #1f1f21;
}

.handnote-control-panel .handnote-generate-btn {
    background: #f4f4f4;
    color: #1f1f21;
    font-weight: 700;
    cursor: pointer;
}

.handnote-control-panel .handnote-generate-btn:hover {
    background: #ffffff;
}

.handnote-control-panel .temperature-slider input[type="range"],
.handnote-control-panel .model-group-slider input[type="range"] {
    background: #b7bec7;
    box-shadow: inset 0 0 0 1px rgba(31, 31, 33, 0.18);
}

.handnote-control-panel .temperature-slider input[type="range"]::-webkit-slider-thumb,
.handnote-control-panel .model-group-slider input[type="range"]::-webkit-slider-thumb {
    background: #2d2d2f;
    width: 20px;
    height: 20px;
    box-shadow: none;
}

.handnote-control-panel .temperature-slider input[type="range"]::-webkit-slider-thumb:hover,
.handnote-control-panel .model-group-slider input[type="range"]::-webkit-slider-thumb:hover {
    transform: none;
    box-shadow: none;
}

.handnote-control-panel .temperature-slider input[type="range"]::-moz-range-thumb,
.handnote-control-panel .model-group-slider input[type="range"]::-moz-range-thumb {
    background: #2d2d2f;
    width: 20px;
    height: 20px;
    border: none;
    box-shadow: none;
}

.handnote-control-panel .temperature-slider input[type="range"]::-moz-range-track,
.handnote-control-panel .model-group-slider input[type="range"]::-moz-range-track {
    background: #b7bec7;
    height: 8px;
    border-radius: 4px;
}

.handnote-range-value {
    display: none;
}

.handnote-range-tooltip {
    position: absolute;
    top: -36px;
    left: 0;
    transform: translateX(-50%);
    background: #ffffff;
    color: #1f1f21;
    font-size: 0.7rem;
    font-weight: 700;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(31, 31, 33, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.handnote-range-tooltip.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

[hidden] {
    display: none !important;
}

.handnote-generation-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0 8px;
    color: #4b5563;
    font-weight: 600;
}

.handnote-generation-status--standalone {
    padding-left: 4px;
}

.handnote-generation-status.is-error {
    color: #b91c1c;
}

.handnote-generation-status.is-error .handnote-status-dot {
    background: #ef4444;
    box-shadow: none;
    animation: none;
}

.handnote-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #5fb96a;
    box-shadow: 0 0 0 0 rgba(95, 185, 106, 0.6);
    animation: handnotePulse 1.6s infinite;
}

.handnote-stream-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    color: #4b5563;
    font-size: 0.88rem;
    font-weight: 600;
}

.handnote-stream-status .handnote-status-dot {
    width: 8px;
    height: 8px;
}

@keyframes handnotePulse {
    0% {
        box-shadow: 0 0 0 0 rgba(95, 185, 106, 0.6);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(95, 185, 106, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(95, 185, 106, 0);
    }
}

.handnote-control-panel {
    gap: 22px;
}

.handnote-mode-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.handnote-mode-tabs {
    display: inline-flex;
    padding: 6px;
    border-radius: 999px;
    background: rgba(247, 242, 234, 0.9);
    border: 1px solid rgba(126, 101, 67, 0.15);
}

.handnote-mode-tab {
    border: 0;
    background: transparent;
    padding: 8px 18px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1rem;
    color: #6a5a44;
    cursor: pointer;
    white-space: nowrap;
}

.handnote-mode-tab.active {
    background: #1f2530;
    color: #ffffff;
}

.handnote-mode-panel {
    display: none;
}

.handnote-mode-panel.active {
    display: block;
}

.handnote-range-value {
    margin-top: 10px;
    font-weight: 700;
    color: #23425f;
}

.handnote-watermark-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    border-radius: 16px;
    background: rgba(247, 242, 234, 0.9);
}

.handnote-selected-questions {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid rgba(31, 31, 33, 0.08);
    margin-bottom: 18px;
}

.handnote-selected-questions.is-visible {
    display: flex;
}

.selected-questions-header {
    font-weight: 700;
    color: #111111;
    font-size: 1.15rem;
}

.selected-questions-empty {
    color: #5b5f67;
    font-size: 0.92rem;
}

.selected-questions-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.selected-questions-list li {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(31, 31, 33, 0.06);
    font-size: 0.92rem;
}

.handnote-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-weight: 600;
}

.handnote-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid rgba(31, 31, 33, 0.24);
    background: #ffffff;
    color: #1f1f21;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
    position: relative;
}

.handnote-help::after {
    content: attr(data-tooltip);
    position: absolute;
    top: 130%;
    right: 0;
    min-width: 170px;
    max-width: 240px;
    padding: 8px 10px;
    background: #1f1f21;
    color: #ffffff;
    border-radius: 10px;
    font-size: 0.72rem;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 10;
}

.handnote-help:hover::after,
.handnote-help:focus::after {
    opacity: 1;
    transform: translateY(0);
}

.handnote-checkbox-row input {
    width: 18px;
    height: 18px;
}

.handnote-generate-btn {
    width: 100%;
    border: 0;
    cursor: pointer;
}

.handnote-output-section {
    margin-top: 26px;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}

#handnote-editor {
    min-height: 520px;
    background: #fff;
}

#handnote-editor .ql-editor h1,
#handnote-editor .ql-editor h2 {
    text-align: center;
    margin-top: 2.2rem;
    margin-bottom: 0.8rem;
}

#handnote-editor .ql-editor h1 {
    margin-top: 0.6rem;
    margin-bottom: 0.4rem;
}

#handnote-editor .ql-editor h3 {
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}

#handnote-editor .ql-editor p,
#handnote-editor .ql-editor li {
    margin-bottom: 0.2rem;
    line-height: 1.55;
}

#handnote-editor .ql-editor img,
.handnote-export-page img {
    display: block;
    margin: 0.8rem auto 0.8rem;
    max-width: 100%;
}

#handnote-book-info {
    margin-bottom: 24px;
    max-width: 100%;
    width: 100%;
}

#handnote-chapter-controls .book-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

#handnote-chapter-controls .book-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

#handnote-chapter-controls .book-title-row h4 {
    margin: 0;
    font-size: 1rem;
}

#handnote-chapter-controls .book-chapter-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 420px;
    overflow-y: auto;
}

#handnote-chapter-controls .book-select-all-row {
    background: transparent;
    padding: 6px 8px;
    border-radius: 8px;
}

#handnote-chapter-controls .book-select-all-row span {
    font-weight: 500;
    color: #6b7280;
    font-size: 0.8rem;
}

#handnote-chapter-controls .chapter-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(247, 244, 239, 0.85);
}

#handnote-chapter-controls .chapter-row-title {
    flex: 1;
    font-weight: 600;
    color: #1f2530;
}

#handnote-chapter-controls .chapter-row-meta {
    color: #6a7380;
    font-size: 0.82rem;
    white-space: nowrap;
}

#handnote-question-controls .question-book {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

#handnote-question-controls .question-book h4 {
    margin: 0 0 8px;
    font-size: 1rem;
}

#handnote-question-controls .question-chapter {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(247, 244, 239, 0.85);
    margin-bottom: 10px;
}

#handnote-question-controls .question-chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
}

#handnote-question-controls .question-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 0;
    padding: 0;
    font-weight: 700;
    color: #1f2530;
    cursor: pointer;
    flex: 1;
    justify-content: flex-start;
}

#handnote-question-controls .question-toggle span:last-child {
    font-size: 1rem;
}

#handnote-question-controls .question-chapter-range {
    font-size: 0.82rem;
    color: #6a7380;
    white-space: nowrap;
    text-align: right;
}

#handnote-question-controls .question-toggle .toggle-caret {
    transition: transform 0.2s ease;
}

#handnote-question-controls .question-chapter.open .question-toggle .toggle-caret {
    transform: rotate(90deg);
}

#handnote-question-controls .question-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#handnote-question-controls .question-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
}

#handnote-question-controls .question-checkbox-row input {
    width: 18px;
    height: 18px;
    margin-top: 3px;
}

#handnote-question-controls .question-preview {
    font-size: 0.92rem;
    color: #1f2530;
}

#handnote-question-controls .question-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(35, 66, 95, 0.12);
    color: #23425f;
    margin-top: 4px;
}

#handnote-question-controls .question-sublist {
    margin: 6px 0 0;
    padding-left: 18px;
    color: #4b5563;
    font-size: 0.9rem;
}

#handnote-question-controls .question-type-group {
    padding: 8px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
    margin-bottom: 10px;
}

#handnote-question-controls .question-type-title {
    font-weight: 600;
    color: #2a2f38;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

#handnote-question-controls .question-type-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.handnote-export-watermark {
    color: rgba(120, 120, 120, 0.16);
}

.handnote-watermark-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    font-family: "Tiro Bangla", "Nata Sans", sans-serif;
    font-size: 30px;
    color: rgba(120, 120, 120, 0.16);
    transform: rotate(-30deg);
    z-index: 1;
    white-space: nowrap;
}

.handnote-export-page > *:not(.handnote-watermark-overlay) {
    position: relative;
    z-index: 2;
}

@media (max-width: 768px) {
    .handnote-grade-grid {
        grid-template-columns: 1fr;
    }

    .handnote-grade-tile {
        min-height: 150px;
    }

    #handnote-editor {
        min-height: 420px;
    }
}
