/* Apple-inspired Modern Blog — v3 (dual theme + refined UI) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ===== Theme Variables ===== */
:root,
[data-theme="dark"] {
    --bg: #000000;
    --bg-gradient: radial-gradient(ellipse at top, #0a0a14 0%, #000000 55%);
    --bg-elevated: #1c1c1e;
    --bg-card: rgba(28,28,30,0.72);
    --bg-card-solid: #1c1c1e;
    --bg-subtle: rgba(255,255,255,0.04);
    --bg-subtle-hover: rgba(255,255,255,0.07);
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.14);
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #6e6e73;
    --accent: #2997ff;
    --accent-hover: #0077ed;
    --accent-soft: rgba(41,151,255,0.12);
    --accent-gradient: linear-gradient(135deg, #2997ff 0%, #a855f7 100%);
    --green: #30d158;
    --red: #ff453a;
    --yellow: #ffd60a;
    --purple: #bf5af2;
    --pink: #ff375f;
    --orange: #ff9f0a;
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.35);
}

[data-theme="light"] {
    --bg: #f5f5f7;
    --bg-gradient: radial-gradient(ellipse at top, #ffffff 0%, #ececef 60%);
    --bg-elevated: #ffffff;
    --bg-card: rgba(255,255,255,0.75);
    --bg-card-solid: #ffffff;
    --bg-subtle: rgba(0,0,0,0.035);
    --bg-subtle-hover: rgba(0,0,0,0.06);
    --border: rgba(0,0,0,0.08);
    --border-strong: rgba(0,0,0,0.14);
    --text-primary: #1d1d1f;
    --text-secondary: #515154;
    --text-tertiary: #86868b;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-soft: rgba(0,113,227,0.10);
    --accent-gradient: linear-gradient(135deg, #0071e3 0%, #8e47d8 100%);
    --green: #1a9c3f;
    --red: #d70015;
    --yellow: #b25000;
    --purple: #8944ab;
    --pink: #d30f45;
    --orange: #c2410c;
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.10);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.08);
}

:root {
    --radius: 18px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-fast: 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    min-height: 100vh;
    background: var(--bg);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition), color var(--transition);
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 20px 80px;
}

/* ===== Glass Card ===== */
.glass {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.glass:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

/* ===== Navigation ===== */
nav.glass {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    margin-bottom: 36px;
    position: sticky;
    top: 12px;
    z-index: 100;
}

nav.glass:hover { transform: none; box-shadow: none; }

nav .logo {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

nav .nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88em;
    font-weight: 500;
    transition: color var(--transition-fast);
    position: relative;
}

nav a:hover { color: var(--text-primary); }

nav .nav-chip {
    font-size: 0.8em;
    color: var(--text-tertiary);
    padding: 4px 10px;
    background: var(--bg-subtle);
    border-radius: 999px;
    border: 1px solid var(--border);
}

/* Theme toggle button */
.theme-toggle {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1em;
    transition: all var(--transition-fast);
}
.theme-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-subtle-hover);
    transform: rotate(15deg);
}

/* ===== Post Cards ===== */
.post-card { cursor: pointer; padding: 28px 32px; position: relative; overflow: hidden; }
.post-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition);
}
.post-card:hover::before { opacity: 1; }

.post-card h2 {
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.post-card .meta {
    font-size: 0.82em;
    color: var(--text-tertiary);
    margin-bottom: 10px;
    font-weight: 400;
}
.post-card .summary {
    color: var(--text-secondary);
    font-size: 0.94em;
    line-height: 1.65;
}
.post-card a { text-decoration: none; color: inherit; display: block; }

/* ===== Post Detail ===== */
.post-content { color: var(--text-secondary); font-size: 1.05em; line-height: 1.85; }
.post-content h1, .post-content h2, .post-content h3 {
    color: var(--text-primary);
    margin: 32px 0 14px;
    letter-spacing: -0.02em;
}
.post-content h1 { font-size: 1.65em; font-weight: 700; }
.post-content h2 { font-size: 1.32em; font-weight: 600; }
.post-content h3 { font-size: 1.12em; font-weight: 600; }
.post-content p { margin-bottom: 16px; }

.post-content pre {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    overflow-x: auto;
    margin: 20px 0;
}
.post-content code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
    font-size: 0.88em;
}
.post-content p code {
    background: var(--bg-subtle-hover);
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    color: var(--accent);
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 14px 22px;
    margin: 20px 0;
    color: var(--text-secondary);
    background: var(--accent-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.post-content img { max-width: 100%; border-radius: var(--radius-sm); margin: 16px 0; }
.post-content a { color: var(--accent); text-decoration: none; transition: color var(--transition-fast); }
.post-content a:hover { color: var(--accent-hover); text-decoration: underline; }
.post-content ul, .post-content ol { padding-left: 24px; margin: 12px 0; }
.post-content li { margin-bottom: 4px; }

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.92em;
}
.post-content th, .post-content td {
    border: 1px solid var(--border);
    padding: 10px 16px;
    color: var(--text-secondary);
    text-align: left;
}
.post-content th {
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.post-content tr:hover td { background: var(--bg-subtle); }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }

.post-title {
    font-size: 2.4em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.03em;
    line-height: 1.2;
}
.post-meta { color: var(--text-tertiary); font-size: 0.88em; margin-bottom: 32px; font-weight: 400; }

/* ===== Comments ===== */
.comments-section h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}
.comment {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    margin-bottom: 12px;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.comment:hover { background: var(--bg-subtle-hover); border-color: var(--border-strong); }
.comment.pinned { background: rgba(255,214,10,0.06); border-color: rgba(255,214,10,0.22); }
.comment .author { font-weight: 600; color: var(--text-primary); font-size: 0.92em; }
.comment .time { font-size: 0.78em; color: var(--text-tertiary); margin-left: 10px; }
.comment .body {
    color: var(--text-secondary);
    margin-top: 8px;
    white-space: pre-wrap;
    font-size: 0.94em;
    line-height: 1.65;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-size: 0.85em;
    font-weight: 500;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], select, textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.95em;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="url"]:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }
textarea { resize: vertical; min-height: 100px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 26px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 980px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    letter-spacing: -0.01em;
}
.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px var(--accent-soft);
}
.btn:active { transform: translateY(0) scale(0.98); }
.btn.btn-ghost {
    background: var(--bg-subtle);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn.btn-ghost:hover { background: var(--bg-subtle-hover); box-shadow: none; }
.btn.btn-sm { padding: 7px 16px; font-size: 0.82em; }

.back-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 24px;
    font-size: 0.9em;
    font-weight: 500;
    transition: color var(--transition-fast);
}
.back-link:hover { color: var(--accent-hover); }

/* ===== Empty / Messages ===== */
.empty { text-align: center; color: var(--text-tertiary); padding: 60px 20px; font-size: 1.05em; }
.empty a { color: var(--accent); }

.msg {
    padding: 13px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 0.88em;
    font-weight: 500;
}
.msg.success { background: rgba(48,209,88,0.10); color: var(--green); border: 1px solid rgba(48,209,88,0.22); }
.msg.error   { background: rgba(255,69,58,0.10); color: var(--red); border: 1px solid rgba(255,69,58,0.22); }

.auth-box { max-width: 420px; margin: 60px auto; }

/* ===== Hero (首页/工具中心可选) ===== */
.hero {
    text-align: center;
    padding: 60px 24px 40px;
    margin-bottom: 24px;
}
.hero h1 {
    font-size: 2.8em;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
    line-height: 1.1;
}
.hero p { color: var(--text-secondary); font-size: 1.05em; max-width: 560px; margin: 0 auto; }

/* ===== Tools Grid ===== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    cursor: pointer;
    transition: all var(--transition);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    position: relative;
    overflow: hidden;
}
.tool-card:hover {
    transform: translateY(-3px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}
.tool-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.tool-card .icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    margin-bottom: 12px;
    background: var(--accent-soft);
    color: var(--accent);
}
.tool-card h3 {
    color: var(--text-primary);
    font-size: 1.02em;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}
.tool-card p { color: var(--text-tertiary); font-size: 0.85em; line-height: 1.5; }

/* Tool color variants */
.tool-card[data-color="purple"] .icon { background: rgba(191,90,242,0.12); color: var(--purple); }
.tool-card[data-color="green"]  .icon { background: rgba(48,209,88,0.12); color: var(--green); }
.tool-card[data-color="orange"] .icon { background: rgba(255,159,10,0.12); color: var(--orange); }
.tool-card[data-color="pink"]   .icon { background: rgba(255,55,95,0.12); color: var(--pink); }
.tool-card[data-color="yellow"] .icon { background: rgba(255,214,10,0.14); color: var(--yellow); }
.tool-card[data-color="red"]    .icon { background: rgba(255,69,58,0.12); color: var(--red); }

/* Tool workspace */
.tool-panel { display: none; animation: fadeIn 0.3s ease; }
.tool-panel.active { display: block; }
.tool-panel h2 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}
.tool-panel .desc {
    color: var(--text-tertiary);
    font-size: 0.9em;
    margin-bottom: 22px;
}
.tool-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.tool-row .btn { padding: 9px 18px; font-size: 0.85em; }

.result-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-family: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.88em;
    color: var(--text-primary);
    word-break: break-all;
    min-height: 44px;
    margin-top: 8px;
    white-space: pre-wrap;
    overflow-x: auto;
}
.result-box:empty::before {
    content: '结果将显示在这里…';
    color: var(--text-tertiary);
    font-style: italic;
}

.kv-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px 16px;
    font-size: 0.9em;
    align-items: center;
}
.kv-grid .k { color: var(--text-tertiary); font-weight: 500; }
.kv-grid .v {
    color: var(--text-primary);
    font-family: 'SF Mono', monospace;
    background: var(--bg-subtle);
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    word-break: break-all;
}

.color-preview {
    width: 100%;
    height: 80px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    transition: background var(--transition);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}
.stat-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}
.stat-card .num {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
    font-family: 'SF Mono', monospace;
}
.stat-card .lbl {
    color: var(--text-tertiary);
    font-size: 0.78em;
    margin-top: 2px;
}

.back-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.88em;
    font-weight: 500;
    margin-bottom: 18px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}
.back-tools:hover { color: var(--accent-hover); }

/* Toast */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card-solid);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    z-index: 1000;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
    .container { padding: 12px 14px 40px; }
    .glass { padding: 22px 20px; }
    nav.glass {
        flex-direction: column;
        gap: 10px;
        padding: 14px 18px;
    }
    nav .nav-right { flex-wrap: wrap; justify-content: center; gap: 14px; }
    .post-title { font-size: 1.7em; }
    .hero h1 { font-size: 2em; }
    .auth-box { margin: 30px 10px; }
    .post-card { padding: 22px 20px; }
    .tools-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .tool-card { padding: 18px; }
    .kv-grid { grid-template-columns: 1fr; }
    .kv-grid .k { font-size: 0.8em; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ===== Selection ===== */
::selection { background: var(--accent-soft); color: var(--text-primary); }
