:root {
    --bg-color: #f7f7f9;
    --apple-blue: #007aff;

    --note-yellow: #fdf2b5;
    --note-yellow-border: #e3cc65;
    --note-green: #e1f5c4;
    --note-green-border: #bcdb91;
    --note-blue: #d5f2fe;
    --note-blue-border: #a8dbf0;
    --note-pink: #fcddec;
    --note-pink-border: #e2aac8;
    --note-orange: #ffe3d1;
    --note-orange-border: #f4c2a5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, SF Pro Text, BlinkMacSystemFont, Helvetica, sans-serif;
    background-color: var(--bg-color);
    color: #1d1d1f;
    user-select: none;
    -webkit-user-select: none;
}

#viewport {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

#viewport.space-grabbing {
    cursor: grabbing !important;
}

#canvas {
    position: absolute;
    width: 20000px;
    height: 20000px;
    transform-origin: 0 0;
    will-change: transform;
    background-image: radial-gradient(rgba(0, 0, 0, var(--grid-opacity, 0.08)) 1.2px, transparent 1.2px);
    background-size: 28px 28px;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px) saturate(190%);
    -webkit-backdrop-filter: blur(20px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    border-radius: 12px;
}

/* 标题栏 */
.brand-info {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 10px 16px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

.brand-info h1 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    line-height: 1;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 侧边栏开关按钮 */
.sidebar-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #1d1d1f;
    border-radius: 6px;
    transition: background 0.15s;
}

.sidebar-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* info 矢量按钮 */
.info-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #8e8e93;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

.info-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--apple-blue);
}

/* 用户登录按钮 */
.user-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    border-radius: 20px;
    transition: background 0.15s;
    font-size: 0.82rem;
    color: #1d1d1f;
    font-weight: 500;
    white-space: nowrap;
}

.user-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.user-btn .user-avatar-mini {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-btn .user-placeholder {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--apple-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* 在线用户指示器（占位备用） */
.online-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34c759;
    flex-shrink: 0;
}

/* 留言板侧边栏样式 */
.sidebar-panel {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 260px;
    width: 238px;
    max-height: calc(100vh - 190px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 16px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
    transform: translateX(-280px);
    opacity: 0;
    pointer-events: none;
}

.sidebar-panel.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #8e8e93;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-create-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--apple-blue);
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}

.sidebar-create-btn:hover {
    background: rgba(0, 122, 255, 0.08);
}

.boards-list {
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 350px;
}

.board-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    font-size: 0.88rem;
    color: #1d1d1f;
}

.board-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.board-item.active {
    background-color: var(--apple-blue);
    color: #fff;
}

.board-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex: 1;
}

.board-item-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.board-visibility-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    flex-shrink: 0;
}

.board-item.active .board-visibility-badge {
    color: #fff;
    opacity: 0.9;
}

/* 删除留言板按钮 */
.board-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #8e8e93;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s;
    margin-left: 6px;
    flex-shrink: 0;
}

.board-item:hover .board-delete-btn {
    display: flex;
}

.board-item:hover .board-visibility-badge {
    display: none;
}

.board-delete-btn:hover {
    background: rgba(255, 59, 48, 0.12);
    color: #ff3b30;
}

.board-item.active .board-delete-btn {
    color: rgba(255, 255, 255, 0.8);
}

.board-item.active .board-delete-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* 留言板配置弹窗遮罩层 */
.board-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.board-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.board-modal-card {
    width: 360px;
    max-width: 90vw;
    padding: 32px 28px 28px 28px;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 18px;
}

.board-modal-overlay.active .board-modal-card {
    transform: scale(1);
}

.board-modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1d1d1f;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.board-modal-subtitle {
    font-size: 0.8rem;
    color: #8e8e93;
    text-align: center;
    margin-bottom: 24px;
}

.board-input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 8px;
}

.board-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    background: rgba(0, 0, 0, 0.02);
    color: #1d1d1f;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.board-input:focus {
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    background: #fff;
}

.board-input::placeholder {
    color: #c7c7cc;
}

/* 留言板权限选择样式 */
.board-privacy-options {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    margin-bottom: 12px;
}

.privacy-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
    background: rgba(0, 0, 0, 0.01);
}

.privacy-option.active {
    border-color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.03);
    color: var(--apple-blue);
}

.privacy-option-title {
    font-size: 0.85rem;
    font-weight: 600;
}

.privacy-option-desc {
    font-size: 0.72rem;
    color: #8e8e93;
    text-align: center;
}

.privacy-option.active .privacy-option-desc {
    color: var(--apple-blue);
    opacity: 0.8;
}

.board-submit-btn {
    width: 100%;
    padding: 12px 0;
    background: var(--apple-blue);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 8px;
}

.board-submit-btn:hover {
    background: #0066d6;
}

.board-submit-btn:active {
    transform: scale(0.98);
}

.board-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.board-error-msg {
    color: #ff3b30;
    font-size: 0.78rem;
    text-align: center;
    margin-top: 6px;
    min-height: 18px;
}

.board-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: #8e8e93;
    cursor: pointer;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    font-size: 1.1rem;
}

.board-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #1d1d1f;
}

/* 作者弹窗遮罩层 */
.info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.info-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* 悬浮作者卡片 */
.info-modal-card {
    width: 280px;
    padding: 30px 24px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 18px;
}

.info-modal-overlay.active .info-modal-card {
    transform: scale(1);
}

/* 作者头像渐变流光外圈 */
.author-avatar-wrap {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(135deg, var(--apple-blue), #34c759);
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.author-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
}

.author-name {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1d1d1f;
    margin-bottom: 4px;
}

.author-role {
    font-size: 0.8rem;
    color: #8e8e93;
    margin-bottom: 22px;
}

.author-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background-color: var(--apple-blue);
    color: #fff;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s, transform 0.1s;
}

.author-link-btn:hover {
    background-color: #0066d6;
}

.author-link-btn:active {
    transform: scale(0.97);
}

.info-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    color: #8e8e93;
    cursor: pointer;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
}

.info-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #1d1d1f;
}

/* 现代 3D 纸张便签及动画样式 */
.note-card {
    position: absolute;
    width: 200px;
    height: 200px;
    padding: 18px 18px 42px 18px;
    border-radius: 3px;
    cursor: move;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid rgba(0, 0, 0, 0.03);
    background-color: #fff;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.015),
        0 4px 10px rgba(0, 0, 0, 0.025),
        0 12px 24px rgba(0, 0, 0, 0.035),
        0 28px 56px rgba(0, 0, 0, 0.04);

    /* 新增：平滑切换留言板时的位置、微移及缩放属性 */
    opacity: 1;
    transform: scale(1) translateY(0);
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 切换空间时的入场与出场动画状态 */
.note-card.entering {
    opacity: 0;
    transform: scale(0.85) translateY(24px) !important;
}

.note-card.exiting {
    opacity: 0 !important;
    transform: scale(0.85) translateY(-24px) !important;
    pointer-events: none !important;
}

.note-card.selected {
    border-color: var(--apple-blue) !important;
    box-shadow: 0 0 0 1.5px var(--apple-blue), 0 12px 28px rgba(0, 0, 0, 0.08);
    z-index: 9999 !important;
}

/* 搜索匹配时的高亮样式 */
.note-card.search-highlight {
    box-shadow: 0 0 0 2.5px var(--apple-blue), 0 16px 36px rgba(0, 122, 255, 0.15) !important;
    z-index: 9998 !important;
}

.note-card.readonly-card {
    cursor: not-allowed !important;
    opacity: 0.9;
}

/* 锁图标 */
.lock-icon {
    position: absolute;
    top: 10px;
    right: 12px;
    color: rgba(0, 0, 0, 0.22);
    pointer-events: none;
    transition: color 0.2s;
}

.note-card.readonly-card:hover .lock-icon {
    color: rgba(0, 0, 0, 0.45);
}

/* 便签作者信息行 */
.note-author-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.35);
    pointer-events: none;
    max-width: 100%;
    overflow: hidden;
    margin-bottom: 6px;
    flex-shrink: 0;
    min-height: 18px;
}

.note-author-row .note-author-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.note-author-row .note-author-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.color-yellow {
    background-color: var(--note-yellow);
    border-color: var(--note-yellow-border);
}

.color-green {
    background-color: var(--note-green);
    border-color: var(--note-green-border);
}

.color-blue {
    background-color: var(--note-blue);
    border-color: var(--note-blue-border);
}

.color-pink {
    background-color: var(--note-pink);
    border-color: var(--note-pink-border);
}

.color-orange {
    background-color: var(--note-orange);
    border-color: var(--note-orange-border);
}

.note-body {
    font-size: 0.92rem;
    line-height: 1.5;
    color: #2c2c2e;
    flex: 1;
    overflow: hidden;
    word-break: break-all;
    outline: none;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
}

.readonly-card .note-body {
    cursor: default !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* 点赞交互组件 */
.like-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #8e8e93;
    font-size: 0.75rem;
    font-weight: 500;
    transition: color 0.15s, transform 0.1s, background 0.15s;
    padding: 4px 6px;
    border-radius: 8px;
    pointer-events: auto;
}

.like-btn:hover {
    color: #ff2d55;
    background: rgba(255, 45, 85, 0.06);
}

.like-btn.liked {
    color: #ff2d55;
}

.like-btn.liked svg {
    fill: #ff2d55;
}

.like-btn:active {
    transform: scale(0.9);
}

/* 实时字数限制器 */
.char-counter {
    position: absolute;
    bottom: 16px;
    left: 18px;
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.25);
    pointer-events: none;
    display: none;
    font-variant-numeric: tabular-nums;
}

.note-card.selected:not(.readonly-card) .char-counter {
    display: block;
}

#note-format-bar {
    position: absolute;
    display: none;
    padding: 6px 10px;
    border-radius: 10px;
    z-index: 10000;
    align-items: center;
    gap: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.02);
    pointer-events: auto;
    transform: translate(-50%, -100%);
    margin-top: -16px;
}

.bar-colors {
    display: flex;
    gap: 6px;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    padding-right: 10px;
}

.bar-color-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.12);
    transition: transform 0.15s;
}

.bar-color-dot:hover {
    transform: scale(1.15);
}

.bar-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    color: #515154;
    transition: background 0.15s, color 0.15s;
}

.bar-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #e30000;
}

/* 极简高雅的搜索框 */
.search-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 220px;
    height: 50px;
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s;
    pointer-events: auto;
}

.search-panel:focus-within {
    width: 280px;
    box-shadow: 0 8px 32px rgba(0, 74, 173, 0.05), 0 1px 2px rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 122, 255, 0.3);
}

.search-icon {
    color: #8e8e93;
    flex-shrink: 0;
}

#search-input {
    background: none;
    border: none;
    outline: none;
    font-size: 0.85rem;
    color: #1d1d1f;
    width: 100%;
}

#search-input::placeholder {
    color: #8e8e93;
}

#search-next-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #8e8e93;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

#search-next-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--apple-blue);
}

/* 物理对齐线 */
.snap-guide {
    position: absolute;
    display: none;
    border: 1px dashed #ff3b30;
    z-index: 999;
    pointer-events: none;
}

#guide-h {
    width: 20000px;
    height: 0;
    left: 0;
}

#guide-v {
    height: 20000px;
    width: 0;
    top: 0;
}

.control-dock {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 100;
}

.dock-btn {
    background: none;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1d1d1f;
    transition: background 0.2s, transform 0.1s;
}

.dock-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

.dock-btn:active {
    transform: scale(0.95);
}

.dock-divider {
    width: 1px;
    height: 18px;
    background-color: rgba(0, 0, 0, 0.08);
}

.dock-text {
    font-size: 0.8rem;
    color: #515154;
    font-weight: 500;
    padding: 0 4px;
}

.sync-status {
    font-size: 0.75rem;
    color: #8e8e93;
    margin-left: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #34c759;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.status-dot.saving {
    background-color: #ff9500;
}

html,
body,
#viewport {
    touch-action: none;
}

@media (max-width: 768px) {
    .brand-info {
        top: 12px;
        left: 12px;
        padding: 8px 12px;
    }

    .brand-info h1 {
        font-size: 0.85rem;
    }

    .search-panel {
        top: 12px;
        right: 12px;
        width: 140px;
        padding: 6px 10px;
    }

    .search-panel:focus-within {
        width: 180px;
    }

    #search-input {
        font-size: 0.8rem;
    }

    .sidebar-panel {
        top: 70px;
        left: 12px;
        width: calc(100% - 24px);
    }
}

@media (max-width: 375px) {
    .brand-info h1 {
        display: none;
    }

    .brand-info {
        padding: 6px;
    }
}