/**
FileName: assets/css/notebook.css
Version: 1.5.1
Written based on the version: 9.2.0
Purpose: Notebook styles — one-row toolbar, visible preview/code toggle,
         centered color sun, compact secondary actions, solid table preview.
Decision Log:
1.5.1 FIX: Toolbar no longer wraps into two rows; it scrolls horizontally if needed.
1.5.1 NEW: Visible text mode toggle button as first toolbar control.
1.5.1 CHANGE: Headings limited visually by JS to H1-H3; toolbar density reduced.
1.5.0 NEW: Color sun styles, table preview styles, responsive layout.
Dependencies: tokens.css, core.css, workspace.css
Used By: assets/js/items/notebook/notebook.js
Owner: A-SUN Studio
*/

.a-sun-studio .astudio-notebook {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    min-height: 320px;
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.a-sun-studio .astudio-notebook * {
    box-sizing: border-box;
}

/* =============================== Banner =============================== */

.a-sun-studio .astudio-notebook-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--color-primary, #a46497) 32%, transparent);
    background: color-mix(in srgb, var(--color-primary, #a46497) 10%, transparent);
    border-radius: 0 7px 0 7px;
}

.a-sun-studio .astudio-notebook-banner p {
    margin: 0;
    line-height: 1.7;
}

.a-sun-studio .astudio-notebook-banner-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--color-primary, #a46497);
    color: var(--color-primary, #a46497);
    background: transparent;
    border-radius: 0 7px 0 7px;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.a-sun-studio .astudio-notebook-banner-btn:hover,
.a-sun-studio .astudio-notebook-banner-btn:focus-visible {
    background: color-mix(in srgb, var(--color-primary, #a46497) 14%, transparent);
}

/* =============================== Toolbar =============================== */

.a-sun-studio .astudio-notebook-toolbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--astudio-border, rgba(255, 255, 255, 0.09));
    background: color-mix(in srgb, var(--astudio-surface, rgba(255, 255, 255, 0.04)) 72%, transparent);
    backdrop-filter: blur(10px);
    border-radius: 0 7px 0 7px;
    position: relative;
    z-index: 20;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}

.a-sun-studio .astudio-notebook-toolbar::-webkit-scrollbar {
    height: 6px;
}

.a-sun-studio .astudio-notebook-toolbar::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--astudio-text, #fff) 18%, transparent);
    border-radius: 999px;
}

.a-sun-studio .astudio-notebook-toolbar-group {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex: 0 0 auto;
}

.a-sun-studio .astudio-notebook-toolbar-group--right {
    justify-content: flex-start;
}

.a-sun-studio .astudio-notebook-toolbar-group--sun {
    justify-content: center;
}

.a-sun-studio .astudio-notebook-toolbar-group--left {
    justify-content: flex-end;
}

.a-sun-studio .astudio-notebook-toolbar-spacer {
    flex: 1 1 24px;
    min-width: 10px;
    height: 1px;
}

.a-sun-studio .astudio-notebook-toolbar-separator {
    display: inline-block;
    width: 1px;
    height: 20px;
    margin: 0 4px;
    background: var(--astudio-border, rgba(255, 255, 255, 0.15));
    vertical-align: middle;
    flex: 0 0 auto;
}

/* =============================== Mode toggle =============================== */

.a-sun-studio .astudio-notebook-mode-btn {
    min-height: 30px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--color-primary, #a46497) 42%, transparent);
    background: color-mix(in srgb, var(--color-primary, #a46497) 10%, transparent);
    color: inherit;
    border-radius: 0 7px 0 7px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
    flex: 0 0 auto;
    transition:
        color 0.15s ease,
        background 0.15s ease,
        border-color 0.15s ease;
}

.a-sun-studio .astudio-notebook-mode-btn:hover,
.a-sun-studio .astudio-notebook-mode-btn:focus-visible {
    border-color: color-mix(in srgb, var(--color-primary, #a46497) 65%, transparent);
    color: var(--color-primary, #a46497);
    background: color-mix(in srgb, var(--color-primary, #a46497) 14%, transparent);
}

.a-sun-studio .astudio-notebook-mode-btn:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--color-primary, #a46497) 60%, transparent);
    outline-offset: 2px;
}

.a-sun-studio .astudio-notebook-mode-btn.is-preview {
    border-color: color-mix(in srgb, var(--color-primary, #a46497) 70%, transparent);
    color: var(--color-primary, #a46497);
    background: color-mix(in srgb, var(--color-primary, #a46497) 16%, transparent);
}

/* =============================== Buttons =============================== */

.a-sun-studio .astudio-notebook-icon-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    border-radius: 0 7px 0 7px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    flex: 0 0 auto;
    transition:
        color 0.15s ease,
        background 0.15s ease,
        border-color 0.15s ease,
        opacity 0.15s ease;
}

.a-sun-studio .astudio-notebook-icon-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.a-sun-studio .astudio-notebook-format-btn.is-heading {
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.2px;
}

.a-sun-studio .astudio-notebook-btn-text {
    font-size: 11px;
    font-weight: 700;
}

.a-sun-studio .astudio-notebook-icon-btn:hover:not(:disabled),
.a-sun-studio .astudio-notebook-icon-btn:focus-visible {
    border-color: color-mix(in srgb, var(--color-primary, #a46497) 55%, transparent);
    color: var(--color-primary, #a46497);
    background: color-mix(in srgb, var(--color-primary, #a46497) 9%, transparent);
}

.a-sun-studio .astudio-notebook-icon-btn:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--color-primary, #a46497) 60%, transparent);
    outline-offset: 2px;
}

.a-sun-studio .astudio-notebook-icon-btn:disabled,
.a-sun-studio .astudio-notebook-icon-btn.is-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.a-sun-studio .astudio-notebook-toolbar.is-preview .astudio-notebook-format-btn {
    opacity: 0.35;
    pointer-events: none;
}

/* =============================== Color sun =============================== */

.a-sun-studio .astudio-notebook-color-sun {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.a-sun-studio .astudio-notebook-color-sun svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.a-sun-studio .astudio-notebook-color-sun g {
    cursor: pointer;
    outline: none;
}

.a-sun-studio .astudio-notebook-sun-ray {
    stroke-width: 4.5;
    stroke-linecap: round;
    transition: stroke-width 0.12s ease, opacity 0.12s ease;
}

.a-sun-studio .astudio-notebook-color-sun g:hover .astudio-notebook-sun-ray,
.a-sun-studio .astudio-notebook-color-sun g:focus-visible .astudio-notebook-sun-ray {
    stroke-width: 6.5;
}

.a-sun-studio .astudio-notebook-sun-center {
    stroke: color-mix(in srgb, var(--astudio-text, #ffffff) 25%, transparent);
    stroke-width: 1.25;
    cursor: pointer;
    transition: transform 0.12s ease;
}

.a-sun-studio .astudio-notebook-color-sun g.is-disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* =============================== Template dropdown =============================== */

.a-sun-studio .astudio-notebook-template-wrapper {
    position: relative;
    display: inline-block;
    z-index: 1000;
    flex: 0 0 auto;
}

.a-sun-studio .astudio-notebook-template-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: auto;
    z-index: 1000;
    min-width: 230px;
    max-height: 300px;
    overflow: auto;
    padding: 6px;
    border: 1px solid var(--astudio-border, rgba(255, 255, 255, 0.10));
    background: rgba(17, 18, 23, 0.98);
    backdrop-filter: blur(12px);
    border-radius: 0 7px 0 7px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
}

.a-sun-studio .astudio-notebook-template-dropdown[hidden] {
    display: none;
}

.a-sun-studio .astudio-notebook-template-item {
    display: block;
    width: 100%;
    padding: 9px 12px;
    border: none;
    background: transparent;
    color: var(--astudio-text, #fff);
    font: inherit;
    text-align: right;
    cursor: pointer;
    border-radius: 0 7px 0 7px;
    transition: background 0.15s ease;
}

.a-sun-studio .astudio-notebook-template-item:hover,
.a-sun-studio .astudio-notebook-template-item:focus-visible {
    background: color-mix(in srgb, var(--color-primary, #a46497) 16%, transparent);
}

/* =============================== Layout =============================== */

.a-sun-studio .astudio-notebook-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.a-sun-studio .astudio-notebook-sidebar,
.a-sun-studio .astudio-notebook-editor {
    min-height: 0;
    border: 1px solid var(--astudio-border, rgba(255, 255, 255, 0.09));
    background: color-mix(in srgb, var(--astudio-surface, rgba(255, 255, 255, 0.04)) 65%, transparent);
    backdrop-filter: blur(10px);
    border-radius: 0 7px 0 7px;
}

.a-sun-studio .astudio-notebook-sidebar {
    overflow: auto;
    padding: 8px;
}

.a-sun-studio .astudio-notebook-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.a-sun-studio .astudio-notebook-empty {
    padding: 12px;
    color: var(--astudio-muted, rgba(255, 255, 255, 0.62));
    font-size: 0.8rem;
    line-height: 1.8;
}

.a-sun-studio .astudio-notebook-list-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.a-sun-studio .astudio-notebook-list-item-btn {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: right;
    padding: 9px 10px;
    border: 1px solid transparent;
    background: rgba(0, 0, 0, 0.10);
    color: inherit;
    border-radius: 0 7px 0 7px;
    cursor: pointer;
    font: inherit;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.a-sun-studio .astudio-notebook-list-item.is-active .astudio-notebook-list-item-btn {
    border-color: color-mix(in srgb, var(--color-primary, #a46497) 55%, transparent);
    background: color-mix(in srgb, var(--color-primary, #a46497) 8%, rgba(0, 0, 0, 0.10));
}

.a-sun-studio .astudio-notebook-list-item-btn strong {
    font-size: 0.84rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a-sun-studio .astudio-notebook-list-item-btn span {
    font-size: 0.74rem;
    color: var(--astudio-muted, rgba(255, 255, 255, 0.62));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a-sun-studio .astudio-notebook-list-item-meta {
    font-size: 0.68rem;
    color: color-mix(in srgb, var(--astudio-muted, rgba(255, 255, 255, 0.62)) 80%, transparent);
}

.a-sun-studio .astudio-notebook-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
}

.a-sun-studio .astudio-notebook-title,
.a-sun-studio .astudio-notebook-content {
    width: 100%;
    color: inherit;
    background: rgba(0, 0, 0, 0.14);
    border: 1px solid var(--astudio-border, rgba(255, 255, 255, 0.09));
    border-radius: 0 7px 0 7px;
    padding: 10px 11px;
    font: inherit;
}

.a-sun-studio .astudio-notebook-title:focus-visible,
.a-sun-studio .astudio-notebook-content:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--color-primary, #a46497) 45%, transparent);
    outline-offset: 2px;
}

.a-sun-studio .astudio-notebook-title {
    font-weight: 700;
}

.a-sun-studio .astudio-notebook-content {
    flex: 1;
    min-height: 240px;
    resize: vertical;
    line-height: 1.95;
    white-space: pre-wrap;
}

/* =============================== Preview =============================== */

.a-sun-studio .astudio-notebook-preview {
    flex: 1;
    min-height: 240px;
    padding: 14px;
    overflow-y: auto;
    border: 1px solid var(--astudio-border, rgba(255, 255, 255, 0.09));
    background: rgba(0, 0, 0, 0.14);
    border-radius: 0 7px 0 7px;
    line-height: 1.95;
    font-size: 0.92rem;
}

.a-sun-studio .astudio-notebook-preview h1,
.a-sun-studio .astudio-notebook-preview h2,
.a-sun-studio .astudio-notebook-preview h3,
.a-sun-studio .astudio-notebook-preview h4,
.a-sun-studio .astudio-notebook-preview h5,
.a-sun-studio .astudio-notebook-preview h6 {
    margin: 1em 0 0.55em;
    line-height: 1.45;
    color: var(--astudio-text, #fff);
    font-weight: 800;
}

.a-sun-studio .astudio-notebook-preview h1 {
    font-size: 1.8em;
}

.a-sun-studio .astudio-notebook-preview h2 {
    font-size: 1.5em;
}

.a-sun-studio .astudio-notebook-preview h3 {
    font-size: 1.3em;
}

.a-sun-studio .astudio-notebook-preview h4 {
    font-size: 1.15em;
}

.a-sun-studio .astudio-notebook-preview h5 {
    font-size: 1.05em;
}

.a-sun-studio .astudio-notebook-preview h6 {
    font-size: 1em;
}

.a-sun-studio .astudio-notebook-preview p {
    margin: 0.85em 0;
}

.a-sun-studio .astudio-notebook-preview ul,
.a-sun-studio .astudio-notebook-preview ol {
    margin: 0.85em 0;
    padding-right: 1.55em;
}

.a-sun-studio .astudio-notebook-preview li {
    margin: 0.35em 0;
}

.a-sun-studio .astudio-notebook-preview li.task-done {
    text-decoration: line-through;
    opacity: 0.72;
}

.a-sun-studio .astudio-notebook-preview code {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.30);
    border: 1px solid color-mix(in srgb, var(--astudio-text, #fff) 10%, transparent);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.88em;
}

.a-sun-studio .astudio-notebook-preview pre {
    margin: 1em 0;
    padding: 12px;
    background: rgba(0, 0, 0, 0.40);
    border: 1px solid color-mix(in srgb, var(--astudio-text, #fff) 12%, transparent);
    border-radius: 0 7px 0 7px;
    overflow-x: auto;
}

.a-sun-studio .astudio-notebook-preview pre code {
    padding: 0;
    background: transparent;
    border: none;
}

.a-sun-studio .astudio-notebook-preview blockquote {
    margin: 1em 0;
    padding: 0.6em 1em;
    border-right: 4px solid var(--color-primary, #a46497);
    background: rgba(0, 0, 0, 0.20);
    border-radius: 0 7px 0 7px;
}

.a-sun-studio .astudio-notebook-preview hr {
    margin: 1.5em 0;
    border: none;
    border-top: 2px solid color-mix(in srgb, var(--astudio-text, #fff) 18%, transparent);
}

.a-sun-studio .astudio-notebook-preview table {
    width: 100%;
    margin: 1em 0;
    border-collapse: collapse;
    border: 1px solid color-mix(in srgb, var(--astudio-text, #fff) 18%, transparent);
    background: color-mix(in srgb, rgba(0, 0, 0, 0.18) 80%, transparent);
}

.a-sun-studio .astudio-notebook-preview th,
.a-sun-studio .astudio-notebook-preview td {
    border: 1px solid color-mix(in srgb, var(--astudio-text, #fff) 18%, transparent);
    border-style: solid;
    padding: 9px 11px;
    text-align: right;
    vertical-align: top;
}

.a-sun-studio .astudio-notebook-preview thead th {
    background: color-mix(in srgb, var(--color-primary, #a46497) 16%, rgba(0, 0, 0, 0.25));
    font-weight: 800;
}

.a-sun-studio .astudio-notebook-preview tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.a-sun-studio .astudio-notebook-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 0 7px 0 7px;
}

.a-sun-studio .astudio-notebook-preview a {
    color: var(--color-primary, #a46497);
    text-decoration: underline;
}

.a-sun-studio .astudio-notebook-preview strong {
    font-weight: 800;
}

.a-sun-studio .astudio-notebook-preview em {
    font-style: italic;
}

.a-sun-studio .astudio-notebook-preview u {
    text-decoration: underline;
}

.a-sun-studio .astudio-notebook-preview del {
    text-decoration: line-through;
    opacity: 0.72;
}

.a-sun-studio .astudio-notebook-preview mark {
    background: color-mix(in srgb, #eac96e 35%, transparent);
    color: inherit;
    padding: 0 0.2em;
    border-radius: 3px;
}

/* =============================== Responsive =============================== */

@media (max-width: 900px) {
    .a-sun-studio .astudio-notebook-layout {
        grid-template-columns: 1fr;
    }

    .a-sun-studio .astudio-notebook-sidebar {
        max-height: 190px;
    }
}