/* 知识库列表 / 创建弹层 / 文章列表 — knowledge.html & kb-articles.html */

body.kb-articles-body {
    background: #f5f5f5;
}

.kb-standalone-app.kb-articles-app {
    background: #f5f5f5;
}

.kb-articles-app .app-bottom-nav {
    flex-shrink: 0;
}

/* —— 创建个人知识库弹层 —— */
.kb-create-root {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
}

.kb-create-root.is-open {
    display: flex !important;
    pointer-events: auto;
}

.kb-create-root[hidden]:not(.is-open) {
    display: none !important;
}

body.kb-create-sheet-open {
    overflow: hidden;
}

.kb-create-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}

.kb-create-sheet {
    position: relative;
    width: 100%;
    max-width: 1000px;
    max-height: min(88vh, 640px);
    background: #f5f5f5;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.kb-create-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.kb-create-cancel,
.kb-create-submit {
    border: none;
    background: transparent;
    font-size: 16px;
    font-family: inherit;
    padding: 8px 4px;
    cursor: pointer;
    color: #1a1a1a;
}

.kb-create-submit {
    font-weight: 600;
    color: #ff7f50;
}

.kb-create-submit:disabled {
    color: #c4c4c4;
    cursor: default;
}

.kb-create-title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #1a1a1a;
}

.kb-create-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kb-create-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px 18px;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    box-sizing: border-box;
}

.kb-create-label {
    display: block;
    font-size: 15px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 10px;
}

.kb-create-req {
    color: #e53935;
    margin-left: 2px;
}

.kb-create-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    color: #1a1a1a;
    background: transparent;
    padding: 0;
}

.kb-create-input::placeholder {
    color: #c4c4c4;
}

.kb-create-error {
    margin: 8px 0 0;
    font-size: 13px;
    color: #e53935;
}

.kb-create-cover-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.kb-create-cover-row .kb-create-label {
    margin-bottom: 0;
}

.kb-create-cover-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-create-chevron {
    color: #c4c4c4;
    flex-shrink: 0;
}

/* —— 文章列表页 —— */
.kb-articles-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 10px 12px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.kb-articles-back {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1a1a1a;
    border-radius: 10px;
}

.kb-articles-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-articles-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.kb-articles-icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #333;
    border-radius: 10px;
}

.kb-articles-icon-btn:hover {
    background: #f5f5f5;
}

.kb-articles-search-bar {
    flex-shrink: 0;
    padding: 0 16px 10px;
    background: #fff;
}

.kb-articles-search-bar[hidden] {
    display: none !important;
}

.kb-articles-search-bar input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: #f5f5f5;
    font-size: 15px;
    font-family: inherit;
    outline: none;
}

.kb-articles-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
}

.kb-articles-item {
    display: flex;
    align-items: stretch;
    width: 100%;
    padding: 0;
    border: none;
    border-bottom: 1px solid #f5f5f5;
    background: #fff;
    text-align: left;
    font-family: inherit;
}

.kb-articles-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 8px 14px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.kb-articles-item-main:hover {
    background: #fafafa;
}

.kb-articles-item .kb-page-item-more {
    align-self: center;
    margin-right: 4px;
}

.kb-articles-item-thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.kb-articles-item-thumb svg {
    opacity: 0.9;
}

.kb-articles-item-body {
    flex: 1;
    min-width: 0;
}

.kb-articles-item-title {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    margin: 0 0 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-articles-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #9a9a9a;
}

.kb-articles-item-meta-icon {
    color: #5cb8a8;
    display: flex;
}

.kb-articles-empty {
    padding: 32px 20px;
    text-align: center;
    font-size: 14px;
    color: #999;
    line-height: 1.6;
}

.kb-articles-ask {
    flex-shrink: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

.kb-articles-ask-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 24px;
}

.kb-articles-ask-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    color: #1a1a1a;
}

.kb-articles-ask-input::placeholder {
    color: #9a9a9a;
}

.kb-articles-ask-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    cursor: pointer;
    border-radius: 50%;
}

.kb-articles-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: transparent;
}

.kb-articles-menu-backdrop[hidden] {
    display: none !important;
}

.kb-articles-menu {
    position: fixed;
    z-index: 1101;
    right: 12px;
    top: calc(56px + env(safe-area-inset-top, 0px));
    min-width: 200px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 6px 0;
    overflow: hidden;
}

.kb-articles-menu[hidden] {
    display: none !important;
}

.kb-articles-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 18px;
    border: none;
    background: #fff;
    font-size: 16px;
    font-family: inherit;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
}

.kb-articles-menu-item--danger {
    color: #e53935;
}

.kb-articles-menu-item--danger svg {
    stroke: #e53935;
}

.kb-page-scroll {
    background: #f5f5f5;
}

.kb-standalone-app .kb-page-header {
    background: #fff;
}

.kb-page-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.kb-page-header-add {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #333;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.kb-page-header-add:hover {
    background: #f5f5f5;
}

.kb-standalone-app .kb-page-search-bar {
    flex-shrink: 0;
    display: block;
    padding: 0 16px 12px;
    background: #fff;
}

.kb-standalone-app .kb-page-search-bar[hidden] {
    display: none !important;
}

.kb-standalone-app .kb-page-search-bar input {
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 10px;
    background: #f5f5f5;
    font-size: 15px;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
}

.kb-standalone-app .kb-page-search-bar input:focus {
    background: #f0f0f0;
    box-shadow: 0 0 0 2px rgba(61, 204, 192, 0.25);
}

.kb-page-section {
    background: #fff;
    margin-bottom: 8px;
}

.kb-page-section:first-of-type {
    margin-top: 0;
}

/* 知识库列表项：主区域 + 更多菜单 */
.kb-standalone-app .kb-page-item {
    display: flex;
    align-items: stretch;
    width: 100%;
    padding: 0;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
    text-align: left;
    font-family: inherit;
}

.kb-standalone-app .kb-page-item:last-child {
    border-bottom: none;
}

.kb-standalone-app .kb-page-item-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 8px 14px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.12s;
}

.kb-standalone-app .kb-page-item-main:hover {
    background: #fafafa;
}

.kb-standalone-app .kb-page-item-more {
    flex-shrink: 0;
    align-self: center;
    width: 44px;
    height: 44px;
    margin-right: 6px;
    border: none;
    background: transparent;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
}

.kb-standalone-app .kb-page-item-more:hover,
.kb-standalone-app .kb-page-item-more.is-active {
    background: #f0f0f0;
    color: #333;
}

.kb-page-item-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1150;
    background: transparent;
}

.kb-page-item-menu-backdrop[hidden] {
    display: none !important;
}

.kb-page-item-menu {
    position: fixed;
    z-index: 1151;
    min-width: 140px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    padding: 6px 0;
    overflow: hidden;
}

.kb-page-item-menu[hidden] {
    display: none !important;
}

.kb-page-item-menu-item {
    display: block;
    width: 100%;
    padding: 12px 18px;
    border: none;
    background: #fff;
    font-size: 16px;
    font-family: inherit;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
}

.kb-page-item-menu-item:hover {
    background: #f5f5f5;
}

.kb-page-item-menu-item--danger {
    color: #e53935;
}

/* 文章编辑页 kb-edit.html */
body.kb-edit-body {
    margin: 0;
    background: #fff;
    color: #1a1a1a;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.kb-edit-app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    max-width: 100%;
    background: #fff;
}

.kb-edit-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 4px;
    flex-shrink: 0;
    background: #fff;
}

.kb-edit-back {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
    flex-shrink: 0;
}

.kb-edit-back:hover {
    background: #f5f5f5;
}

.kb-edit-save-btn {
    margin-left: auto;
    flex-shrink: 0;
    padding: 8px 22px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, #3dccbf 0%, #2eb8ab 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(46, 184, 171, 0.35);
    line-height: 1.2;
}

.kb-edit-save-btn:hover {
    filter: brightness(1.05);
}

.kb-edit-save-btn:active {
    transform: scale(0.98);
}

.kb-edit-save-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.kb-edit-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.kb-edit-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.kb-edit-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kb-edit-more-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
}

.kb-edit-more-btn:hover {
    background: #f5f5f5;
}

.kb-edit-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.kb-edit-title-wrap {
    flex-shrink: 0;
    margin: 0 20px;
    padding: 4px 0 10px;
    border-bottom: 1px solid #d8d8d8;
}

.kb-edit-title-input {
    width: 100%;
    box-sizing: border-box;
    border: none;
    outline: none;
    background: transparent;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.35;
    padding: 4px 0 6px;
    font-family: inherit;
    color: #1a1a1a;
}

.kb-edit-title-input::placeholder {
    color: #c8c8c8;
    font-weight: 700;
}

.kb-edit-body-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.kb-edit-line-wrap {
    flex: 1;
    min-height: 0;
    border: none !important;
    border-radius: 0 !important;
    background: #fff;
    box-shadow: none !important;
}

.kb-edit-line-wrap .kb-line-gutter {
    padding-top: 12px;
    padding-bottom: 24px;
    background: #f3f4f6;
    border-right: 1px solid #e5e7eb;
    font-size: 16px;
    line-height: 1.65;
}

.kb-edit-line-wrap .kb-line-num {
    min-height: calc(1.65 * 16px);
    line-height: 1.65;
}

.kb-edit-line-wrap .kb-line-editor-textarea,
.kb-edit-body-input {
    flex: 1;
    min-height: 0;
    width: auto;
    border: none;
    outline: none;
    resize: none;
    background: #fff !important;
    font-size: 16px;
    line-height: 1.65;
    padding: 12px 16px 24px 10px !important;
    font-family: inherit;
    color: #333;
    box-shadow: none !important;
}

.kb-edit-line-wrap .kb-line-editor-textarea:focus {
    box-shadow: none !important;
}

.kb-edit-body-input::placeholder,
.kb-edit-line-wrap .kb-line-editor-textarea::placeholder {
    color: #c8c8c8;
}

.kb-edit-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.2);
}

.kb-edit-menu-backdrop[hidden] {
    display: none !important;
}

.kb-edit-menu {
    position: fixed;
    top: 52px;
    right: 12px;
    z-index: 1201;
    min-width: 140px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 6px 0;
    overflow: hidden;
}

.kb-edit-menu[hidden] {
    display: none !important;
}

.kb-edit-menu-item {
    display: block;
    width: 100%;
    padding: 12px 18px;
    border: none;
    background: #fff;
    font-size: 16px;
    font-family: inherit;
    color: #1a1a1a;
    cursor: pointer;
    text-align: left;
}

.kb-edit-menu-item:hover {
    background: #f5f5f5;
}

.kb-edit-menu-item--danger {
    color: #e53935;
}

.kb-edit-menu-item[hidden] {
    display: none !important;
}
