/* app.css - 架空世界地图全局样式 */
:root {
    --primary: #2b6cb0;
    --primary-dark: #1e4e7c;
    --bg: #f7f8fa;
    --surface: #fff;
    --border: #e2e8f0;
    --text: #1a202c;
    --text-muted: #718096;
    --danger: #e53e3e;
    --success: #38a169;
    --warning: #d69e2e;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    --mono: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); }
img { max-width: 100%; }

/* ===== 顶栏 ===== */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 24px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--text); }
.logo-icon { font-size: 22px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.nav a:not(.btn) { color: var(--text-muted); font-weight: 500; }
.nav a:not(.btn):hover { color: var(--primary); }
.user-link { display: flex; align-items: center; gap: 8px; color: var(--text) !important; }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; font-weight: 600; font-size: 13px; }
.badge-admin { background: var(--warning); color: #fff; padding: 2px 6px; border-radius: 3px; font-size: 11px; }

/* ===== 按钮 ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.15s; font-family: inherit; background: var(--surface); color: var(--text); text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { display: block; width: 100%; }
.btn-icon { background: transparent; border: 0; cursor: pointer; color: var(--text-muted); font-size: 18px; padding: 4px 8px; border-radius: 4px; }
.btn-icon:hover { background: var(--bg); color: var(--primary); }

/* ===== 主区域 ===== */
.main { min-height: calc(100vh - 56px - 56px); }
.footer { background: var(--surface); border-top: 1px solid var(--border); padding: 16px 24px; text-align: center; color: var(--text-muted); font-size: 13px; height: 56px; display: flex; align-items: center; justify-content: center; }

/* ===== 首页 ===== */
.home-hero { text-align: center; padding: 80px 24px 60px; background: linear-gradient(135deg, #2b6cb0 0%, #4299e1 100%); color: #fff; }
.hero-title { font-size: 42px; font-weight: 700; margin-bottom: 16px; }
.hero-sub { font-size: 18px; opacity: 0.92; margin: 0 auto 32px; max-width: 640px; line-height: 1.7; }
.hero-actions { display: flex; gap: 16px; justify-content: center; }
.hero-actions .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.4); }
.hero-actions .btn-ghost:hover { background: rgba(255,255,255,0.15); }

.home-section, .home-features { max-width: 1200px; margin: 0 auto; padding: 48px 24px; }
.section-title { font-size: 24px; margin-bottom: 24px; font-weight: 600; }
.home-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; padding-top: 0; }
.feature { background: var(--surface); padding: 28px; border-radius: var(--radius); border: 1px solid var(--border); text-align: center; }
.feature-icon { font-size: 36px; margin-bottom: 12px; }
.feature h3 { font-size: 17px; margin-bottom: 8px; }
.feature p { color: var(--text-muted); font-size: 13px; }

/* ===== 世界卡片网格 ===== */
.world-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.world-card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; transition: box-shadow 0.15s, transform 0.15s; color: var(--text); }
.world-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); text-decoration: none; }
.world-thumb { height: 140px; background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.world-thumb img { width: 100%; height: 100%; object-fit: cover; }
.world-thumb-placeholder { font-size: 48px; opacity: 0.4; }
.world-card-body { padding: 12px 16px; }
.world-card-body h3 { font-size: 16px; margin-bottom: 4px; }
.world-author, .world-meta { font-size: 12px; color: var(--text-muted); margin: 2px 0; }
.world-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.vis-tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; background: var(--bg); }
.vis-private { color: var(--text-muted); }
.vis-link { color: var(--warning); }
.vis-public { color: var(--success); }

/* ===== 认证页 ===== */
.auth-wrap { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { background: var(--surface); padding: 36px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 440px; width: 100%; }
.auth-card h1 { font-size: 26px; margin-bottom: 20px; text-align: center; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; }
.auth-form input, .auth-form textarea, .auth-form select, .select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; font-family: inherit; background: var(--surface); }
.auth-form input:focus, .auth-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,108,176,0.1); }
.auth-form small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }
.form-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.checkbox { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.auth-hint { margin-top: 16px; text-align: center; color: var(--text-muted); font-size: 13px; }
.auth-hint code { background: var(--bg); padding: 2px 6px; border-radius: 3px; }
.form-hint-box { background: var(--bg); padding: 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.form-hint-box ul { margin: 6px 0 0 18px; }

/* ===== 页面通用 ===== */
.page-wrap { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-head h1, .page-wrap h1 { font-size: 28px; margin-bottom: 8px; }
.my-section { margin-bottom: 48px; }
.my-section h2 { font-size: 20px; margin-bottom: 16px; }
.empty-state { padding: 48px; text-align: center; color: var(--text-muted); background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border); }

/* ===== 编辑器布局 ===== */
.editor-layout { display: flex; height: calc(100vh - 56px); }
.editor-toolbar { width: 56px; background: #2d3748; display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 4px; }
.tool-group { display: flex; flex-direction: column; gap: 4px; }
.tool-btn { width: 40px; height: 40px; border: 0; background: transparent; color: #cbd5e0; cursor: pointer; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 18px; transition: all 0.15s; }
.tool-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.tool-btn.active { background: var(--primary); color: #fff; }
.tool-divider { width: 28px; height: 1px; background: rgba(255,255,255,0.15); margin: 6px 0; }

.editor-map-wrap { flex: 1; position: relative; display: flex; flex-direction: column; }
.map { flex: 1; background: #fafafa; }
.map-topbar { position: absolute; top: 0; left: 0; right: 0; background: rgba(255,255,255,0.95); backdrop-filter: blur(8px); padding: 8px 16px; display: flex; justify-content: space-between; align-items: center; z-index: 10; border-bottom: 1px solid var(--border); }
.map-title { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.link-back { color: var(--text-muted); }
.sep { color: var(--border); }
.world-name { font-weight: 600; }
.badge-draft { background: var(--warning); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.map-actions { display: flex; gap: 6px; }
.presence-bar { position: absolute; top: 50px; right: 16px; display: flex; gap: 4px; z-index: 5; }
.presence-chip { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; border: 2px solid #fff; box-shadow: var(--shadow); }
.zoom-indicator { position: absolute; bottom: 40px; right: 16px; background: rgba(45,55,72,0.85); color: #fff; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-family: var(--mono); z-index: 5; }
.map-statusbar { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(45,55,72,0.85); color: #cbd5e0; padding: 4px 12px; display: flex; justify-content: space-between; font-size: 11px; font-family: var(--mono); z-index: 5; }

.editor-panel { width: 280px; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.panel-tabs { display: flex; border-bottom: 1px solid var(--border); }
.panel-tab { flex: 1; padding: 10px; background: transparent; border: 0; cursor: pointer; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; }
.panel-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.panel-content { display: none; overflow-y: auto; flex: 1; }
.panel-content.active { display: block; }
.panel-section { padding: 14px; border-bottom: 1px solid var(--border); }
.panel-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel-section-header h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
.hint, .empty-hint { font-size: 12px; color: var(--text-muted); }

.layer-list, .type-list { list-style: none; }
.layer-item, .type-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; border-bottom: 1px solid var(--bg); }
.layer-visible input { cursor: pointer; }
.layer-name { flex: 1; }
.layer-name[contenteditable]:focus { outline: 1px solid var(--primary); padding: 2px 4px; border-radius: 3px; }
.layer-type-tag { font-size: 10px; background: var(--bg); padding: 1px 5px; border-radius: 3px; color: var(--text-muted); }
.type-color { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); }
.type-geom { font-size: 10px; color: var(--text-muted); margin-left: auto; }

.prop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.prop-head .badge { background: var(--bg); padding: 2px 6px; border-radius: 3px; font-size: 11px; color: var(--text-muted); }
.tag-row { display: flex; gap: 4px; margin-bottom: 6px; }
.tag-key, .tag-val { flex: 1; padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; font-size: 12px; }
.prop-actions { margin-top: 12px; }

/* ===== 世界查看页 ===== */
.world-view-wrap { max-width: 1400px; margin: 0 auto; padding: 20px 24px; }
.world-view-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; gap: 16px; }
.world-view-title h1 { font-size: 24px; margin-bottom: 4px; }
.world-view-meta { color: var(--text-muted); font-size: 13px; }
.world-view-desc { color: var(--text); margin-top: 8px; font-size: 14px; }
.world-view-actions { display: flex; gap: 8px; }
.world-view-body { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.world-map-wrap { position: relative; height: 70vh; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.world-sidebar { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; overflow-y: auto; max-height: 70vh; }
.layer-toggle { position: absolute; top: 12px; right: 12px; background: rgba(255,255,255,0.95); padding: 10px; border-radius: 6px; box-shadow: var(--shadow); z-index: 5; font-size: 12px; }
.layer-toggle label { display: block; cursor: pointer; }
.sidebar-section h3 { font-size: 15px; margin-bottom: 12px; }
.comment-form textarea { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 4px; resize: vertical; margin-bottom: 8px; font-family: inherit; }
.comment-list { list-style: none; margin-top: 16px; }
.comment-item { padding: 10px 0; border-bottom: 1px solid var(--bg); }
.comment-author { display: flex; justify-content: space-between; margin-bottom: 4px; }
.comment-time { color: var(--text-muted); font-size: 11px; }
.comment-content { font-size: 13px; color: var(--text); }

/* ===== 设置页 ===== */
.settings-form { background: var(--surface); padding: 24px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 24px; }
.settings-form .form-group { margin-bottom: 16px; }
.settings-form label { display: block; margin-bottom: 6px; font-weight: 500; }
.settings-form input, .settings-form textarea, .settings-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 120px; }
.settings-section { background: var(--surface); padding: 24px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 24px; }
.settings-section h2 { font-size: 18px; margin-bottom: 16px; }
.share-url-box { display: flex; gap: 8px; align-items: center; }
.share-url-box code { flex: 1; background: var(--bg); padding: 8px 12px; border-radius: 4px; font-size: 12px; overflow-x: auto; }
.collab-list { list-style: none; margin-bottom: 16px; }
.collab-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--bg); }
.badge-role { background: var(--bg); padding: 2px 8px; border-radius: 10px; font-size: 11px; color: var(--text-muted); }
.danger-zone { border-color: #fed7d7; }
.danger-zone h2 { color: var(--danger); }

/* ===== 版本历史 ===== */
.milestone-list { list-style: none; margin: 16px 0; }
.milestone-item { padding: 14px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 10px; }
.ms-head { display: flex; align-items: center; gap: 8px; }
.ms-head .badge { background: var(--bg); padding: 2px 6px; border-radius: 3px; font-size: 11px; color: var(--text-muted); }
.ms-head .muted { margin-left: auto; font-size: 12px; }
.ms-desc { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.ms-actions { margin-top: 8px; }
.changes-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.changes-table th, .changes-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.changes-table th { background: var(--bg); font-weight: 600; }
.op-tag { padding: 2px 6px; border-radius: 3px; font-size: 11px; }
.op-create { background: #c6f6d5; color: #22543d; }
.op-modify { background: #bee3f8; color: #2a4365; }
.op-delete { background: #fed7d7; color: #742a2a; }

/* ===== 广场 ===== */
.explore-filters { display: flex; gap: 12px; margin-bottom: 24px; align-items: center; }
.explore-filters input, .explore-filters select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px; }

/* ===== 用户页 ===== */
.user-profile-head { display: flex; align-items: center; gap: 20px; margin-bottom: 32px; }
.user-profile-head .avatar-lg { width: 80px; height: 80px; border-radius: 50%; }

/* ===== 提示 ===== */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; transition: opacity 0.5s; }
.alert-error { background: #fed7d7; color: #742a2a; }
.alert-ok { background: #c6f6d5; color: #22543d; }
.muted { color: var(--text-muted); }
.link { color: var(--primary); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .editor-layout { flex-direction: column; }
    .editor-panel { width: 100%; max-height: 240px; }
    .world-view-body { grid-template-columns: 1fr; }
    .hero-title { font-size: 28px; }
    .home-hero { padding: 40px 16px; }
}
