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

html, body {
    margin: 0;
    padding: 0;
    touch-action: pan-x pan-y;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background-color: var(--bg-page);
}

/* ===== CSS Variables ===== */
:root {
    --bg-page: #f5f5f5;
    --bg-container: #ffffff;
    --bg-container-hover: #f8f9fa;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --link-color: #1a73e8;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-strong: 0 2px 8px rgba(0, 0, 0, 0.2);
    --tag-bg: #e8f0fe;
    --tag-color: #1a73e8;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #121212;
        --bg-container: #1e1e1e;
        --bg-container-hover: #2a2a2a;
        --text-primary: #e0e0e0;
        --text-secondary: #aaaaaa;
        --text-muted: #777777;
        --border-color: #333333;
        --link-color: #6ea8fe;
        --shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-strong: 0 2px 8px rgba(0, 0, 0, 0.5);
        --tag-bg: rgba(110, 168, 254, 0.15);
        --tag-color: #6ea8fe;
    }
}

/* ===== Base Typography ===== */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding: calc(48px + env(safe-area-inset-top)) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a {
    color: var(--link-color);
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== Fixed Header ===== */
.fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 48px;
    padding: 0 12px;
    padding-top: env(safe-area-inset-top);
    background-color: var(--bg-container);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.back-btn:active {
    background-color: var(--bg-container-hover);
}

.fixed-header-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 120px);
}

/* ===== Article Common Styles ===== */
.article-container {
    background-color: var(--bg-container);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 768px) {
    .article-container {
        border-radius: 0;
        padding: 20px;
        box-shadow: none;
    }
}

.article-header {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.article-title {
    font-size: 24px;
    font-weight: bold;
    margin: 0 0 15px 0;
    color: var(--text-primary);
}

.article-meta {
    color: var(--text-secondary);
    font-size: 14px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.article-author {
    font-weight: 500;
    color: var(--link-color);
    text-decoration: none;
}

.article-author:hover {
    text-decoration: underline;
}

.article-content {
    line-height: 1.8;
    color: var(--text-primary);
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.article-content img {
    max-width: 100%;
    height: auto;
}

/* ===== Tags ===== */
.tag {
    display: inline-block;
    background-color: var(--tag-bg);
    color: var(--tag-color);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ===== Floating Buttons ===== */
.floating-buttons {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    max-width: 800px;
    width: calc(100% - 40px);
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.floating-btn {
    flex: 1;
    padding: 14px 0;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: block;
    box-shadow: var(--shadow-strong);
    color: white;
}

.btn-deeplink {
    background-color: #5865F2;
}

.btn-deeplink:active {
    background-color: #4752c4;
}

.btn-original {
    background-color: #03C75A;
}

.btn-original:active {
    background-color: #02b050;
}

/* ===== Address ===== */
.address {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.address:empty {
    display: none;
}

/* ===== Article Info ===== */
.article-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.article-info:empty {
    display: none;
}

/* ===== LaraLife App ===== */
body.laralife .fixed-header,
body.laralife .floating-buttons {
    display: none !important;
}

body.laralife {
    padding-top: env(safe-area-inset-top);
}
