/* 小兔文档 网页版样式 */
:root {
    --primary: #1a73e8;
    --primary-dark: #1967d2;
    --primary-light: #d2e3fc;
    --secondary: #f1f3f4;
    --bg: #ffffff;
    --panel: #f8f9fa;
    --border: #dadce0;
    --text: #202124;
    --muted: #5f6368;
    --danger: #d93025;
    --success: #188038;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(60, 64, 67, .16);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "SimSun", sans-serif;
    font-size: 13px;
    color: var(--text);
    background: var(--panel);
}

button,
input,
select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* ---------------------------------------------------------- 登录页 */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eef4ff 0%, #f7f9fc 45%, #eef7f2 100%);
    padding: 20px;
}

.auth-card {
    width: 380px;
    max-width: 100%;
    background: var(--bg);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(26, 115, 232, .12);
    padding: 34px 34px 24px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 22px;
}

.auth-logo {
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    line-height: 54px;
    text-align: center;
    box-shadow: 0 6px 16px rgba(26, 115, 232, .35);
}

.auth-brand h1 {
    margin: 0 0 4px;
    font-size: 22px;
    letter-spacing: 1px;
}

.auth-brand p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.auth-tabs {
    display: flex;
    background: var(--secondary);
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 8px 0;
    border-radius: 6px;
    color: var(--muted);
    font-weight: 600;
}

.auth-tab.active {
    background: var(--bg);
    color: var(--primary);
    box-shadow: var(--shadow);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.field input {
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .12);
}

.btn-primary {
    height: 38px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    transition: background .15s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.alert {
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-bottom: 14px;
}

.alert-error {
    background: #fce8e6;
    color: var(--danger);
}

.alert-success {
    background: #e6f4ea;
    color: var(--success);
}

.auth-foot {
    margin: 20px 0 0;
    text-align: center;
    font-size: 11px;
    color: #9aa0a6;
}

/* ---------------------------------------------------------- 主界面框架 */

.app-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    flex: none;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
}

.brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    line-height: 28px;
    text-align: center;
}

.brand-tag {
    font-size: 10px;
    font-weight: 500;
    color: var(--primary);
    background: var(--primary-light);
    border-radius: 10px;
    padding: 2px 8px;
}

.menubar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.menu {
    position: relative;
}

.menu summary {
    list-style: none;
    padding: 7px 12px;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.menu summary::-webkit-details-marker {
    display: none;
}

.menu summary:hover,
.menu[open] summary {
    background: var(--secondary);
    color: var(--text);
}

.menu-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 160px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(60, 64, 67, .18);
    padding: 6px;
    display: flex;
    flex-direction: column;
}

.menu-panel button,
.menu-panel a {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 8px 10px;
    border-radius: 5px;
    text-decoration: none;
    color: var(--text);
}

.menu-panel button:hover,
.menu-panel a:hover {
    background: var(--primary-light);
}

.menu-panel hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 5px 4px;
}

.userbox {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.avatar {
    font-size: 14px;
}

.btn-ghost {
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 5px 12px;
}

.btn-ghost:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 356px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
}

/* ---------------------------------------------------------- 左侧面板 */

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.panel {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.panel:first-child {
    flex: 0 1 40%;
    min-height: 150px;
}

.panel-files {
    flex: 1 1 60%;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 8px;
}

.panel-head h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
}

.panel-hint {
    font-size: 11px;
    color: var(--muted);
}

.btn-row {
    display: flex;
    gap: 6px;
    padding: 0 12px 8px;
}

.btn {
    border: 1px solid transparent;
    background: var(--secondary);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text);
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    background: var(--primary-light);
}

.btn:disabled {
    color: #b0b4b8;
    cursor: not-allowed;
}

.btn.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn.btn-primary:hover {
    background: var(--primary-dark);
}

/* 文件夹树 */

.tree-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0 6px 8px;
}

.tree,
.tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.tree-row:hover {
    background: var(--secondary);
}

.tree-row.active {
    background: var(--primary);
    color: #fff;
}

.tree-row.active .caret {
    color: rgba(255, 255, 255, .85);
}

.caret {
    width: 14px;
    flex: none;
    text-align: center;
    color: var(--muted);
    font-size: 11px;
}

.tree-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-empty {
    padding: 16px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

/* 搜索与文件列表 */

.search-row {
    display: flex;
    gap: 6px;
    padding: 0 12px 8px;
}

.search-row input {
    flex: 1;
    min-width: 0;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 10px;
    outline: none;
}

.search-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .1);
}

.file-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
}

.file-head {
    display: flex;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.sort-btn {
    border: 0;
    background: transparent;
    padding: 5px 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-align: left;
}

.sort-btn:first-child {
    flex: 1;
}

.sort-btn:hover {
    color: var(--primary);
}

.sort-btn .arrow {
    font-size: 9px;
    margin-left: 3px;
}

.file-list {
    list-style: none;
    margin: 0;
    padding: 4px;
    overflow: auto;
    flex: 1;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
}

.file-item:hover {
    background: var(--secondary);
}

.file-item.active {
    background: var(--primary);
    color: #fff;
}

.file-item .f-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-item .f-date {
    flex: none;
    font-size: 11px;
    color: var(--muted);
}

.file-item.active .f-date {
    color: rgba(255, 255, 255, .8);
}

.list-empty {
    padding: 24px 12px;
    text-align: center;
    color: #9aa0a6;
    font-size: 12px;
}

/* ---------------------------------------------------------- 编辑区 */

.editor-pane {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.title-input {
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    font-size: 17px;
    font-weight: 600;
    outline: none;
    background: var(--bg);
}

.title-input::placeholder {
    color: #b0b4b8;
    font-weight: 400;
}

.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}

.tb-group {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
}

.tb-group select {
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    padding: 0 6px;
    outline: none;
}

.tb-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
}

.tb-btn {
    min-width: 30px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: 5px;
    padding: 0 8px;
    font-size: 12px;
}

.tb-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.tb-color {
    position: relative;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg);
    text-align: center;
    line-height: 26px;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
}

.tb-color input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
}

.tb-spacer {
    flex: 1;
}

.editor {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 22px 34px;
    outline: none;
    font-family: "SimSun", "Microsoft YaHei", serif;
    font-size: 15px;
    line-height: 1.8;
    word-break: break-word;
}

.editor:empty::before {
    content: "在此输入文档内容，系统会自动保存...";
    color: #b0b4b8;
}

.find-bar {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 6px 12px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}

.find-bar input {
    width: 200px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 10px;
    outline: none;
}

.find-bar input:focus {
    border-color: var(--primary);
}

.statusbar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 14px;
    border-top: 1px solid var(--border);
    background: var(--panel);
    color: var(--muted);
    font-size: 11px;
}

.save-state {
    color: #9aa0a6;
}

/* ---------------------------------------------------------- 提示 */

.toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    transform: translateX(-50%);
    background: rgba(32, 33, 36, .92);
    color: #fff;
    padding: 9px 18px;
    border-radius: 18px;
    font-size: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
    z-index: 999;
    max-width: 70vw;
}

.toast.error {
    background: rgba(217, 48, 37, .95);
}

/* ---------------------------------------------------------- 响应式 */

@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 290px minmax(0, 1fr);
    }

    .brand-tag,
    .userbox .username {
        display: none;
    }

    .editor {
        padding: 16px 18px;
    }
}

@media (max-width: 700px) {
    .app-page {
        height: auto;
        overflow: auto;
    }

    .topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 10px;
        gap: 8px;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .sidebar {
        max-height: 60vh;
    }

    .editor-pane {
        min-height: 60vh;
    }
}
