/* ===== 基础重置 ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #0071e3;
    --accent-light: #e8f2ff;
    --danger: #ff3b30;
    --success: #34c759;
    --warning: #ff9500;
    --radius: 16px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text",
                 "Helvetica Neue", "PingFang SC", "Noto Sans CJK SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#app {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

/* ===== Header ===== */
#header {
    padding: 24px 20px 16px;
    text-align: center;
}

#header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

#header p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== State Views ===== */
.state-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.hidden {
    display: none !important;
}

/* ===== Loading ===== */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Error ===== */
.error-icon {
    font-size: 48px;
    color: var(--danger);
    font-weight: 700;
}

.btn-retry {
    margin-top: 16px;
    padding: 10px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
}

/* ===== Module Grid ===== */
.module-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    padding: 0 16px 20px;
}

.module-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    align-items: center;
    gap: 14px;
    -webkit-tap-highlight-color: transparent;
}

.module-card:active {
    transform: scale(0.98);
}

.module-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.module-info {
    flex: 1;
    min-width: 0;
}

.module-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 3px;
}

.module-desc {
    font-size: 13px;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.module-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
    flex-shrink: 0;
}

.badge-hot {
    background: #fff0f0;
    color: var(--danger);
}

.badge-new {
    background: var(--accent-light);
    color: var(--accent);
}

.badge-test {
    background: #f0f0f0;
    color: var(--text-secondary);
}

/* ===== Module View (iframe) ===== */
#module-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 100;
    display: flex;
    flex-direction: column;
}

#module-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: var(--card-bg);
    border-bottom: 1px solid #e5e5ea;
    height: 48px;
    flex-shrink: 0;
}

#module-toolbar button {
    background: none;
    border: none;
    font-size: 15px;
    color: var(--accent);
    cursor: pointer;
    padding: 8px;
}

.btn-back .arrow {
    font-size: 18px;
}

#module-title-bar {
    flex: 1;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px;
}

.btn-share .share-icon {
    font-size: 20px;
}

#module-frame {
    flex: 1;
    border: none;
    width: 100%;
    background: white;
}

/* ===== Footer ===== */
#footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Empty State ===== */
#empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 15px;
}

/* ===== 分享弹窗 ===== */
.share-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: 16px 16px 0 0;
    padding: 20px;
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}

.share-modal p {
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.share-modal input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e5ea;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 12px;
}

.share-modal .btn-copy {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    cursor: pointer;
}

.share-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}
