/* ============================================================
    编辑页专属样式（全高布局）
    ============================================================ */

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
}

.navbar {
    flex-shrink: 0;
}

.editor-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ===== 左侧面板 ===== */
.left-panel {
    width: 220px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.left-panel .panel-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1rem 1rem 0.6rem 1rem;
    flex-shrink: 0;
}

.left-panel .template-list-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 0.5rem 1rem;
}

.left-panel .template-list-wrap::-webkit-scrollbar {
    width: 3px;
}

.left-panel .template-list-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.left-panel .template-list-wrap::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.left-panel .template-list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.left-panel .template-list a {
    display: block;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    border: 1px solid transparent;
}

.left-panel .template-list a:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border);
}

.left-panel .template-list a.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-color: var(--color-primary);
    font-weight: 500;
}

.left-panel .template-list a .sub {
    font-size: 0.65rem;
    color: var(--color-text-light);
    display: block;
}

.left-panel .template-list a.active .sub {
    color: var(--color-primary);
}

.left-panel .footer-info {
    flex-shrink: 0;
    padding: 0.8rem 1rem 1.2rem 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.7rem;
    color: var(--color-text-light);
    text-align: center;
    line-height: 1.6;
}

.left-panel .footer-info a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.left-panel .footer-info a:hover {
    color: var(--color-primary);
}

.center-canvas {
    position: relative;
    flex: 1;
    background: var(--color-bg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.scroll-container {
    flex: 1;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--color-bg);
    scroll-behavior: smooth;
    scrollbar-width: thin;
}

.scroll-container::-webkit-scrollbar {
    width: 5px;
}

.scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

/* ===== 纸张包装（居中） ===== */
.paper-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 0.5rem 0;
    min-height: 100%;
}

.paper-view {
    background: var(--color-surface);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.02);
    width: 100%;
    max-width: 793px;
    aspect-ratio: 1 / 1.414;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    margin: 1rem 0;
}

.paper-content {
    width: 100%;
    height: 100%;
    background: var(--color-surface);
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.paper-content .preview-text {
    font-size: 2rem;
    line-height: 1.8;
    text-align: center;
    color: var(--color-text);
    font-family: 'Noto Serif SC', serif;
}

.paper-content .preview-placeholder {
    color: var(--color-text-light);
    font-size: 1rem;
}

.paper-content .preview-pinyin {
    font-size: 1.2rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
    text-align: center;
}

.shadow-top,
.shadow-bottom {
    position: absolute;
    left: 0;
    width: 100%;
    height: 32px;
    pointer-events: none;
    z-index: 5;
    display: block;
    flex-shrink: 0;
}

.shadow-top {
    top: 0;
    background: linear-gradient(to bottom, var(--color-bg) 0%, transparent 100%);
}

.shadow-bottom {
    bottom: 0;
    background: linear-gradient(to top, var(--color-bg) 0%, transparent 100%);
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    padding: 4px 12px 4px 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 10;
    user-select: none;
}

.zoom-controls button {
    background: none;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 300;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.zoom-controls button:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.zoom-controls .zoom-level {
    min-width: 44px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.zoom-controls .reset-btn {
    font-size: 14px;
}

.right-panel {
    width: 400px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
    border-left: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 1.2rem 1.2rem 1.5rem 1.2rem;
    height: 100%;
}

.right-panel::-webkit-scrollbar {
    width: 4px;
}

.right-panel::-webkit-scrollbar-track {
    background: transparent;
}

.right-panel::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.right-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.right-panel .panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.right-panel .panel-header .badge {
    font-size: 0.7rem;
    background: var(--color-primary-light);
    color: var(--color-primary);
    padding: 0.1rem 0.6rem;
    border-radius: var(--radius-full);
}

/* ===== 折叠面板 ===== */
.accordion {
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl);
    margin-bottom: 0.7rem;
    border: 1px solid var(--color-border);
    overflow: hidden;
    transition: border-color var(--transition);
}

.accordion:hover {
    border-color: var(--color-border-hover);
}

.accordion-header {
    padding: 0.6rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--color-surface-hover);
    display: flex;
    justify-content: space-between;
    user-select: none;
    color: var(--color-text);
    transition: background var(--transition);
}

.accordion-header:hover {
    background: var(--color-border);
}

.accordion-header .arrow {
    transition: transform 0.25s ease;
    font-size: 0.75rem;
    color: var(--color-text-light);
}

.accordion-header .arrow.open {
    transform: rotate(180deg);
}

.accordion-content {
    padding: 0.6rem 1rem 1rem;
    border-top: 1px solid var(--color-border);
    display: none;
}

.accordion-content.open {
    display: block;
}

/* ===== 控件 ===== */
.control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
    flex-wrap: wrap;
}

.control-row label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.control-row>label:first-child {
    width: 70px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

.control-row input[type="text"],
.control-row input[type="number"],
.control-row input[type="password"],
.control-row input[type="email"],
.control-row input[type="url"],
.control-row input[type="tel"],
.control-row input[type="search"],
.control-row input[type="color"],
.control-row select,
.control-row textarea {
    flex: 1;
    padding: 0.35rem 0.7rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-size: 0.8rem;
    font-family: inherit;
    color: var(--color-text);
    transition: all var(--transition);
}

.control-row input[type="text"]:focus,
.control-row input[type="number"]:focus,
.control-row input[type="password"]:focus,
.control-row input[type="email"]:focus,
.control-row input[type="url"]:focus,
.control-row input[type="tel"]:focus,
.control-row input[type="search"]:focus,
.control-row input[type="color"]:focus,
.control-row select:focus,
.control-row textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.control-row input[type="color"] {
    width: 48px;
    padding: 2px;
    height: 32px;
    flex: 0 0 48px;
}

.control-row input[type="range"] {
    flex: 2;
    padding: 0;
    height: 4px;
    border: none;
    background: var(--color-border);
    border-radius: var(--radius-sm);
    appearance: none;
}

.control-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    border: 2px solid var(--color-surface);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.control-row .range-value {
    background: var(--color-primary-light);
    border-radius: var(--radius-full);
    padding: 0.05rem 0.5rem;
    font-size: 0.75rem;
    color: var(--color-primary);
    font-weight: 500;
    min-width: 32px;
    text-align: center;
}

.control-row textarea {
    resize: vertical;
    min-height: 44px;
}

.btn-full {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--radius-full);
    border: none;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-primary-full {
    background: var(--color-primary);
    color: var(--color-surface);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.btn-primary-full:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
}

.btn-secondary-full {
    background: var(--color-surface-hover);
    color: var(--color-text-secondary);
}

.btn-secondary-full:hover {
    background: var(--color-border);
}

.flex-btns {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.flex-btns .btn-full {
    flex: 1;
}

/* ============================================================
    响应式
    ============================================================ */

@media (max-width: 1024px) {
    .left-panel {
        width: 170px;
    }

    .right-panel {
        width: 270px;
    }

    .left-panel .template-list a {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .left-panel .panel-title {
        font-size: 0.65rem;
        padding: 0.6rem 0.8rem 0.3rem 0.8rem;
    }

    .left-panel .template-list-wrap {
        padding: 0 0.6rem 0.3rem 0.6rem;
    }

    .left-panel .footer-info {
        font-size: 0.6rem;
        padding: 0.5rem 0.6rem 0.8rem 0.6rem;
    }

    .right-panel {
        padding: 0.8rem;
    }

    .right-panel .panel-header h3 {
        font-size: 0.9rem;
    }

    .paper-view {
        max-width: 700px;
    }

    .center-canvas {
        padding: 1.5rem 0 1.5rem 1rem;
    }
}

@media (max-width: 768px) {

    html,
    body {
        overflow-y: auto;
    }

    .editor-layout {
        flex-direction: column;
        overflow-y: visible;
        min-height: 100vh;
    }

    .left-panel {
        width: 100%;
        height: auto;
        max-height: 140px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        flex-shrink: 0;
    }

    .left-panel .panel-title {
        padding: 0.5rem 1rem 0.2rem 1rem;
        font-size: 0.65rem;
    }

    .left-panel .template-list-wrap {
        overflow-y: hidden;
        overflow-x: auto;
        padding: 0 0.5rem 0.3rem 0.5rem;
        flex: none;
        white-space: nowrap;
    }

    .left-panel .template-list {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.3rem;
    }

    .left-panel .template-list a {
        display: inline-block;
        font-size: 0.75rem;
        padding: 0.2rem 0.7rem;
        flex-shrink: 0;
        white-space: nowrap;
    }

    .left-panel .template-list a .sub {
        display: inline;
        font-size: 0.6rem;
        margin-left: 0.2rem;
    }

    .left-panel .footer-info {
        display: none;
    }

    .center-canvas {
        padding: 0.8rem;
        min-height: 50vh;
        flex: 1;
        overflow: hidden;
    }

    .scroll-container {
        flex: 1;
        width: 100%;
        height: auto;
        max-height: 70vh;
        overflow-y: auto;
    }

    .paper-view {
        padding: 1rem;
        margin: 0.8rem 0;
        max-width: 100%;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    }

    .shadow-top,
    .shadow-bottom {
        height: 24px;
    }

    .right-panel {
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid var(--color-border);
        overflow-y: auto;
        padding: 0.8rem 1rem 1.2rem 1rem;
        flex-shrink: 0;
        backdrop-filter: blur(8px);
    }

    .right-panel .panel-header {
        margin-bottom: 0.6rem;
    }

    .right-panel .panel-header h3 {
        font-size: 0.85rem;
    }

    .mobile-footer {
        display: block !important;
        text-align: center;
        padding: 0.8rem 1rem 1.2rem 1rem;
        font-size: 0.65rem;
        color: var(--color-text-light);
        border-top: 1px solid var(--color-border);
        background: var(--color-surface);
        flex-shrink: 0;
    }

    .mobile-footer a {
        color: var(--color-text-muted);
        text-decoration: none;
    }

    .mobile-footer a:hover {
        color: var(--color-primary);
    }
}

.mobile-footer {
    display: none;
}

@media (max-width: 480px) {
    .left-panel .template-list a {
        font-size: 0.65rem;
        padding: 0.15rem 0.5rem;
    }

    .left-panel .template-list a .sub {
        font-size: 0.55rem;
    }

    .center-canvas {
        padding: 0.4rem;
        min-height: 40vh;
    }

    .paper-view {
        padding: 0.6rem;
        margin: 0.4rem 0;
    }

    .paper-content .preview-text {
        font-size: 1.2rem;
    }

    .paper-content .preview-placeholder {
        font-size: 0.8rem;
    }

    .right-panel {
        padding: 0.5rem 0.6rem 0.8rem 0.6rem;
        max-height: 40vh;
    }

    .control-row label {
        font-size: 0.7rem;
    }

    .control-row>label:first-child {
        width: 60px;
    }

    .control-row input,
    .control-row select,
    .control-row textarea {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }

    .accordion-header {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
    }

    .accordion-content {
        padding: 0.4rem 0.6rem 0.6rem;
    }

    .btn-full {
        font-size: 0.75rem;
        padding: 0.4rem;
    }

    .shadow-top,
    .shadow-bottom {
        height: 16px;
    }
}