
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f3f4f6;
    --bg-card: #ffffff;
    --border: #e5e7eb;
    --border-soft: #f1f5f9;
    --text-main: #0f172a;
    --text-sub: #6b7280;
    --text-muted: #9ca3af;
    --primary: #4f46e5;
    --primary-soft: #eef2ff;
    --primary-deep: #4338ca;
    --danger: #ef4444;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.05);
    --shadow-hover: 0 18px 45px rgba(15, 23, 42, 0.12);
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    background: var(--bg);
    color: var(--text-main);
}

/* Layout */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */

.app-header {
    border-bottom: 1px solid var(--border);
    background: #ffffff;
}

.app-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 16px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-main);
}

.app-logo-mark {
    width: 43px;
    height: 55px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.app-logo-mark svg,
.app-logo-svg,
.app-logo svg {
    width: 43px !important;
    height: 55px !important;
    max-width: 43px !important;
    max-height: 55px !important;
    min-width: 43px !important;
    min-height: 55px !important;
}

.app-logo-text {
    font-weight: 600;
    font-size: 15px;
}

.app-nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 24px;
}

.app-nav-link {
    font-size: 15px;
    color: var(--text-sub);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 999px;
}

.app-nav-link.active,
.app-nav-link:hover {
    color: var(--primary-deep);
    background: #eef2ff;
}

.app-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search */

.search-field {
    position: relative;
    width: 240px;
}

.search-input {
    width: 100%;
    border-radius: 999px;
    border: 1px solid var(--border);
    padding: 6px 28px 6px 10px;
    font-size: 12px;
    background: #f9fafb;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.4);
    background: #ffffff;
}

.search-kbd {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
}

/* Buttons */

.btn {
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 14px;
    padding: 8px 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f9fafb;
    color: var(--text-main);
    text-decoration: none;
}

a.btn,
a.btn:hover,
a.btn:focus,
a.btn:active {
    text-decoration: none;
}

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

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

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-main);
}

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

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-sub);
}

/* Avatar placeholder */

.avatar-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #e5e7eb;
}

/* Main */

.app-main {
    flex: 1;
}

.page-container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px 16px 32px;
}

/* Footer */

.app-footer {
    border-top: 1px solid var(--border);
    background: #ffffff;
}

.app-footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    color: var(--text-sub);
}

.app-footer-left,
.app-footer-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--text-sub);
    text-decoration: none;
}

.footer-link:hover {
    color: var(--text-main);
}

/* Language pill in footer */

.footer-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    background: #f3f4f6;
    padding: 4px 10px;
}

.footer-lang select {
    border: none;
    background: transparent;
    font-size: 11px;
    color: var(--text-sub);
    outline: none;
}

/* Two-column layout */

.layout-two-column {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    gap: 20px;
}

@media (max-width: 900px) {
    .app-header-inner {
        height: auto;
        padding-top: 8px;
        padding-bottom: 8px;
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .app-nav-links {
        display: none;
    }

    .search-field {
        display: none;
    }

    .layout-two-column {
        grid-template-columns: minmax(0, 1fr);
    }
    
    /* 在小屏幕上隐藏浮动按钮组 */
    #floating-action-buttons {
        display: none !important;
    }

    .app-footer-inner {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Card */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-soft);
    padding: 16px;
    overflow-x: hidden; /* 防止内容水平溢出 */
    box-sizing: border-box; /* 确保 padding 包含在宽度计算中 */
}

.card:hover.card-hoverable {
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
    transition: box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    border-color: #e0e7ff;
}

/* Titles */

.page-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-sub);
    margin-top: 4px;
}

/* Form controls */

.field {
    margin-bottom: 12px;
}

.field-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 4px;
}

.field-input,
.field-select,
.field-textarea {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 7px 9px;
    font-size: 13px;
    outline: none;
    background: #f9fafb;
}

.field-textarea {
    resize: vertical;
    min-height: 80px;
}

.field-input:focus,
.field-select:focus,
.field-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.35);
    background: #ffffff;
}

.field-help {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Filters */

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.filter-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
}

.filter-reset {
    font-size: 11px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.filter-section-title {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
}

.filter-checklist {
    font-size: 11px;
    color: var(--text-sub);
}

.filter-checklist label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 3px;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-pill {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid transparent;
    cursor: pointer;
}

.tag-pill:hover {
    border-color: #c7d2fe;
    background: #eef2ff;
    color: #4338ca;
}

/* Prompt list */

.prompt-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.prompt-card {
    text-decoration: none;
    color: inherit;
    padding: 14px 14px 12px;
}

.prompt-card-title-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.prompt-card-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

.prompt-card-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
}

.prompt-card-desc {
    font-size: 12px;
    color: var(--text-sub);
    margin: 6px 0 4px;
}

.prompt-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.meta-pill {
    font-size: 11px;
    padding: 3px 7px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #4b5563;
}

.prompt-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.prompt-card-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-visibility {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    background: #dcfce7;
    color: #15803d;
}

/* Chips */

.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: #f3f4f6;
    font-size: 11px;
    color: #4b5563;
}

/* Tabs */

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-soft);
    gap: 12px;
    padding: 0 16px;
}

.tab-btn {
    border: none;
    background: none;
    padding: 8px 2px 8px;
    font-size: 12px;
    color: var(--text-sub);
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--text-main);
    font-weight: 600;
}

.tab-btn.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    border-radius: 999px;
    background: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Detail layout */

.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
    gap: 20px;
}

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

.prompt-header-main {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prompt-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Code block */

.code-block {
    background: #020617;
    color: #e5e7eb;
    border-radius: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    padding: 10px 12px;
    white-space: pre-wrap;
}

/* Misc */

.muted-text {
    font-size: 12px;
    color: var(--text-sub);
}

.table-row {
    padding: 8px 0;
    border-top: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    align-items: center;
}

.table-row-title {
    font-weight: 500;
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
}

.radio-group {
    font-size: 12px;
    color: var(--text-sub);
}

.radio-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 6px;
}

.radio-item-title {
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 2px;
}

.small-badge {
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 10px;
    background: #f3f4f6;
    color: #4b5563;
}

a {
    color: inherit;
}

/* Background decorative SVG - positioned at bottom left */
.bg-decorative-svg {
    position: fixed;
    bottom: 60px;
    left: 10px;
    width: 300px;
    height: auto;
    z-index: 0;
    opacity: 1;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
    isolation: isolate;
}

/* Ensure main logo SVG is not affected - explicitly protect its styles */
.app-logo-svg,
.app-logo svg,
.app-logo-mark svg {
    position: relative;
    z-index: auto;
    opacity: 1 !important;
    isolation: isolate;
    width: 43px !important;
    height: 55px !important;
    max-width: 43px !important;
    max-height: 55px !important;
}

/* Ensure other SVGs are not affected */
svg:not(.bg-decorative-svg) {
    position: relative;
    z-index: auto;
    opacity: 1 !important;
}

/* Welcome page background SVG - isolated styles */
#welcome-background.welcome-background-svg {
    isolation: isolate;
    z-index: 0;
    pointer-events: none;
}

#welcome-background .welcome-bg-cls-1 { fill: none !important; }
#welcome-background .welcome-bg-cls-2 { fill: #f8b62d !important; }
#welcome-background .welcome-bg-cls-3 { fill: #c30d23 !important; }
#welcome-background .welcome-bg-cls-4 { fill: #7f1923 !important; }
#welcome-background .welcome-bg-cls-5 { fill: #9d3824 !important; }

/* Welcome page header logo - isolated styles */
.welcome-header-logo {
    display: block;
    isolation: isolate;
    position: relative;
    z-index: 10;
}

.welcome-header-logo svg {
    display: block;
    width: 100%;
    height: 100%;
    isolation: isolate;
}

/* Ensure welcome header logo colors are preserved - scoped to welcome header only */
.welcome-header-logo svg .cls-1 { fill: #f8b62d !important; }
.welcome-header-logo svg .cls-2 { fill: #c30d23 !important; }
.welcome-header-logo svg .cls-3 { fill: #7f1923 !important; }
.welcome-header-logo svg .cls-4 { fill: #9d3824 !important; }

/* Prevent background SVG styles from affecting header logo */
.welcome-header-logo svg .welcome-bg-cls-1,
.welcome-header-logo svg .welcome-bg-cls-2,
.welcome-header-logo svg .welcome-bg-cls-3,
.welcome-header-logo svg .welcome-bg-cls-4,
.welcome-header-logo svg .welcome-bg-cls-5 {
    display: none !important;
}

/* Line clamp utility for text truncation */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* User menu dropdown */
.user-menu-item:hover {
    background-color: #f3f4f6;
}

.user-menu-item:active {
    background-color: #e5e7eb;
}

/* Rich text content from TinyMCE */
.prompt-content-html {
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden; /* 防止水平溢出 */
    max-width: 100%; /* 确保不超过容器宽度 */
    box-sizing: border-box; /* 包含 padding 和 border 在宽度计算中 */
}

.prompt-content-html h1,
.prompt-content-html h2,
.prompt-content-html h3,
.prompt-content-html h4,
.prompt-content-html h5,
.prompt-content-html h6 {
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.3;
}

.prompt-content-html h1 {
    font-size: 1.75em;
}

.prompt-content-html h2 {
    font-size: 1.5em;
}

.prompt-content-html h3 {
    font-size: 1.25em;
}

.prompt-content-html h4 {
    font-size: 1.1em;
}

.prompt-content-html p {
    margin: 0.75em 0;
}

.prompt-content-html p:first-child {
    margin-top: 0;
}

.prompt-content-html p:last-child {
    margin-bottom: 0;
}

.prompt-content-html ul,
.prompt-content-html ol {
    margin: 0.75em 0;
    padding-left: 1.5em;
}

.prompt-content-html li {
    margin: 0.25em 0;
}

.prompt-content-html img {
    max-width: 100% !important; /* 强制应用，覆盖内联样式 */
    width: auto !important;
    height: auto !important;
    display: block;
    border-radius: 8px;
    margin: 1em auto;
    box-sizing: border-box; /* 确保 padding 和 border 包含在宽度内 */
}

.prompt-content-html video {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em auto;
}

.prompt-content-html iframe {
    max-width: 100%;
    display: block;
    margin: 1em auto;
}

.prompt-content-html a {
    color: var(--primary);
    text-decoration: underline;
}

.prompt-content-html a:hover {
    color: var(--primary-deep);
}

.prompt-content-html blockquote {
    margin: 1em 0;
    padding-left: 1em;
    border-left: 3px solid var(--border);
    color: var(--text-sub);
    font-style: italic;
}

.prompt-content-html code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9em;
}

.prompt-content-html pre {
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

.prompt-content-html pre code {
    background: none;
    padding: 0;
}

.prompt-content-html table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.prompt-content-html table th,
.prompt-content-html table td {
    padding: 8px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.prompt-content-html table th {
    background: #f9fafb;
    font-weight: 600;
}

.prompt-content-html hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5em 0;
}
