/* Same full-width, full-height page shell the calendar uses: the shared style caps main at
   1200px and centres it, which is exactly what kept the notes from filling the window. */
body {
    overflow: hidden;
}

main {
    max-width: none;
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding: 1rem;
    overflow: hidden;
}

.notes-page {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    padding-bottom: 0;
    flex: 1 1 auto;
    min-height: 0;
    height: calc(100dvh - 2rem);
    display: flex;
    overflow: hidden;
}

.notes-layout {
    display: grid;
    grid-template-columns: minmax(240px, 336px) minmax(0, 1fr);
    gap: 0.8rem;
    width: 100%;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.notes-sidebar,
.notes-main {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    min-height: 0;
    height: 100%;
    max-height: 100%;
}

.notes-sidebar {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.notes-sidebar-top {
    padding: 0.7rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.notes-sidebar-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.notes-sidebar-title {
    margin: 0;
    font-size: 1rem;
    text-align: center;
    flex: 1 1 auto;
    min-width: 0;
}

/* The sidebar search mirrors the interactive-table board column search in every regard. */
.notes-search-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.notes-search-wrap[hidden] {
    display: none;
}

.notes-search-input {
    width: 100%;
    min-height: 42px;
    box-sizing: border-box;
}

.notes-search-empty {
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    color: var(--text-color);
    opacity: 0.72;
    text-align: center;
}

.notes-card-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.7rem;
    display: flex;
    flex-direction: column;
}

.notes-card-tree {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Same footer link the calendar sidebar carries and the same style, kept at the very bottom of
   the sidebar even when there are only a few notebooks. */
.notes-card-list-footer {
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 3rem;
    text-align: center;
}

.notes-config-copy-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin: 0 auto;
    text-decoration: none;
    transition: opacity 0.2s ease;
    opacity: 0.3;
    color: var(--link-color);
    font-size: 0.7em;
    cursor: pointer;
}

.notes-config-copy-link:hover {
    opacity: 0.2;
}

.notes-config-copy-link.is-copied,
.notes-config-copy-link.is-copied:hover {
    opacity: 0.2;
    cursor: default;
    pointer-events: none;
}

.notes-config-copy-link[hidden] {
    display: none !important;
}

.notes-section-add-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.35rem;
    white-space: nowrap;
}

.notes-section-add-link {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    font-size: 0.7rem;
    text-decoration: none;
    color: var(--link-color);
    opacity: 0.5;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.notes-section-add-link:hover {
    opacity: 1;
}

.notes-section-add-separator {
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 0.7rem;
    opacity: 0.5;
}

/* Collapsed cards say what is hidden underneath, inside the card itself. */
.notes-collapsed-summary {
    margin-top: 0.35rem;
    font-size: 0.7rem;
    opacity: 0.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}

.notes-card {
    position: relative;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow-color);
    min-width: 0;
    padding: 0.55rem 0.65rem;
    box-sizing: border-box;
    cursor: pointer;
    transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Hovering only dims, exactly like the interactive-table board cards: the outline is reserved
   for the card that is actually open. */
.notes-card:hover,
.notes-card:focus-within {
    opacity: 0.8;
}

/* A parent wraps its children, so it must not dim while the pointer is really over one of them. */
.notes-card:has(.notes-card:hover),
.notes-card:has(.notes-card:focus-within) {
    opacity: 1;
}

.notes-card.is-open {
    border: 1px solid var(--link-color);
    box-shadow: 0 0 0 1px var(--link-color), 0 2px 4px var(--shadow-color);
}

.notes-card.is-selected {
    border: 1px solid var(--primary-color);
    background-color: rgba(66, 133, 244, 0.12);
    box-shadow: 0 2px 4px var(--shadow-color);
}

.notes-card.is-dragging,
.notes-card.is-group-dragging {
    opacity: 0.55;
}

.notes-card.is-drop-before {
    box-shadow: inset 0 3px 0 0 var(--primary-color);
}

.notes-card.is-drop-after {
    box-shadow: inset 0 -3px 0 0 var(--primary-color);
}

.notes-card.is-drop-unavailable {
    opacity: 0.3;
    cursor: not-allowed;
}

.notes-card.is-drop-unavailable > .notes-card-label {
    cursor: not-allowed;
}

.notes-card.is-drop-inside {
    border-color: var(--primary-color);
    background-color: rgba(66, 133, 244, 0.08);
}

.notes-card-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    color: var(--link-color);
}

.notes-card-emoji {
    flex: 0 0 auto;
    line-height: 1;
}

.notes-card-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
}

.notes-card-progress {
    margin-top: 0.35rem;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.notes-card-progress-bar {
    height: 4px;
    border-radius: 2px;
    background-color: var(--border-color);
    overflow: hidden;
}

.notes-card-progress-fill {
    display: block;
    height: 100%;
    background-color: var(--accent-color);
    opacity: 0.5;
}

/* The children and the add links of a parent live inside its own card, which turns every
   notebook and chapter into a sub-box around what belongs to it. */
.notes-card-children {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

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

.notes-card.notes-branch {
    cursor: default;
}

.notes-card.notes-branch > .notes-card-label {
    cursor: pointer;
}

.notes-level-2 {
    margin-left: 10px;
}

.notes-level-deep {
    margin-left: 20px;
}

.notes-main {
    display: flex;
    flex-direction: column;
    position: relative;
}

.notes-main-header {
    flex: 0 0 auto;
    padding: 0.7rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--input-bg);
    position: relative;
    z-index: 5;
}

.notes-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.notes-title-row .tnx-symbol-picker {
    flex: 0 0 auto;
    position: relative;
}

/* The picker is the standard one, only scaled down: the shared style sizes the box at 6rem with a
   3.6rem glyph and a 14px radius, so every one of those keeps its exact proportion at 2.2rem. */
.notes-title-row .tnx-symbol-picker-trigger {
    width: 2.2rem !important;
    height: 2.2rem !important;
    min-width: 2.2rem !important;
    max-width: 2.2rem !important;
    min-height: 2.2rem !important;
    max-height: 2.2rem !important;
    inline-size: 2.2rem;
    block-size: 2.2rem;
    flex: 0 0 2.2rem !important;
    border-radius: 5px;
}

.notes-title-row .tnx-symbol-picker-trigger-value {
    font-size: 1.32rem;
}

/* In the title row the picker panel floats over the notes instead of pushing the row apart.
   Its shared style carries "max-width: 100%", which against the 2.2rem trigger box collapsed the
   panel into a one-emoji-wide strip, so that cap is lifted and the normal panel width restored. */
.notes-title-row .tnx-symbol-picker-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    z-index: 60;
    width: min(28.8rem, calc(100vw - 2rem));
    max-width: none;
    max-height: min(60vh, 26rem);
    box-shadow: 0 6px 18px var(--shadow-color);
}

.notes-title-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 2rem;
    box-sizing: border-box;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0 0.5rem;
    margin: 0;
}

.notes-title-row .saving-indicator {
    flex: 0 0 auto;
    font-size: 0.85rem;
    opacity: 0.3;
    white-space: nowrap;
    text-align: right;
}

/* Emoji, name and controls share one line; only a small screen splits them. */
.notes-title-actions {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    white-space: nowrap;
}

.notes-controls-row {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 auto;
    gap: 0.45rem;
    margin: 0;
    white-space: nowrap;
    line-height: 1;
}

.notes-controls-separator {
    display: inline-flex;
    flex: 0 0 auto;
    opacity: 0.5;
}

.notes-control-link {
    display: inline-flex;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    opacity: 0.5;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.notes-control-link:hover {
    opacity: 1;
}

.notes-control-link[hidden] {
    display: none;
}

.notes-main-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    padding: 0.7rem;
    overflow: hidden;
}

.notes-body-input {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    resize: none;
    overflow-y: auto;
    box-sizing: border-box;
}

.notes-empty-state {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem;
    overflow: auto;
}

.notes-empty-state[hidden] {
    display: none;
}

/* Same wording style the calendar uses when nothing is selected yet. */
.notes-no-selection {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    text-align: center;
    padding: 1rem 0.5rem;
}

.notes-no-selection[hidden] {
    display: none;
}

/* With nothing opened only the saving indicator stays, so a save still reports back. */
.notes-main.is-empty .notes-title-row .tnx-symbol-picker,
.notes-main.is-empty .notes-title-input,
.notes-main.is-empty .notes-main-body {
    display: none;
}

/* Beats the row's own !important display, which is there to survive the shared button rules. */
.notes-main.is-empty .notes-controls-row {
    display: none !important;
}

@media (max-width: 900px) {
    /* Emoji and name move onto separate lines.  The fixed header logo covers the top left corner
       of the pane and reaches down past the first line, so both the emoji and the name start to
       the right of it, while the "|" and everything after it stay aligned right. */
    .notes-title-row {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        column-gap: 0.5rem;
        row-gap: 5px;
        padding-left: calc(var(--tnx-logo-space) + 0.4rem);
    }

    .notes-title-row .tnx-symbol-picker {
        grid-row: 1;
        grid-column: 1;
        justify-self: start;
    }

    .notes-title-actions {
        grid-row: 1;
        grid-column: 2;
        justify-self: end;
        margin-left: 0;
    }

    .notes-title-input {
        grid-row: 2;
        grid-column: 1 / -1;
        width: 100%;
    }

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

    .notes-layout.is-mobile-main .notes-sidebar {
        display: none;
    }

    .notes-layout:not(.is-mobile-main) .notes-main {
        display: none;
    }
}
