:root {
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-bg-hover: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(255, 255, 255, 0.25);
    --text-primary: #1d1d1f;
    --text-secondary: rgba(29, 29, 31, 0.6);
    --accent-blue: #0071e3;
    --shadow-light: 0 8px 32px rgba(0, 0, 0, 0.06);
    --shadow-strong: 0 12px 48px rgba(0, 0, 0, 0.12);
    --card-radius: 26px;
    --dock-radius: 22px;
    --modal-radius: 16px;
    --animation-duration: 0.35s;
}

body.dark-mode {
    --glass-bg: rgba(30, 30, 30, 0.55);
    --glass-bg-hover: rgba(40, 40, 40, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --text-primary: #f5f5f7;
    --text-secondary: rgba(245, 245, 247, 0.6);
    --shadow-light: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-strong: 0 12px 48px rgba(0, 0, 0, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 30%, #a8edea 60%, #fed6e3 100%);
    background-attachment: fixed;
    background-size: 400% 400%;
    animation: gradientShift 25s ease infinite;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body.wallpaper-ocean { background: linear-gradient(135deg, #667eea 0%, #764ba2 30%, #4facfe 60%, #00f2fe 100%); }
body.wallpaper-sunset { background: linear-gradient(135deg, #fa709a 0%, #fee140 30%, #f093fb 60%, #f5576c 100%); }
body.wallpaper-forest { background: linear-gradient(135deg, #11998e 0%, #38ef7d 30%, #56ab2f 60%, #a8e063 100%); }
body.dark-mode { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 60%, #1a1a2e 100%); }

.menu-bar {
    height: 34px;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 0.5px solid var(--glass-border);
    position: relative;
    z-index: 100;
}

body.dark-mode .menu-bar { background: rgba(40, 40, 40, 0.5); }

.menu-left { display: flex; align-items: center; gap: 4px; position: relative; }
.apple-logo { font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.apple-logo:hover { background: rgba(255, 255, 255, 0.2); }

.apple-menu {
    position: absolute; top: 34px; left: 0; min-width: 220px;
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(25px);
    border-radius: 10px; border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-strong); padding: 6px 0;
    opacity: 0; transform: translateY(-8px); pointer-events: none;
    transition: all 0.2s ease; z-index: 1000;
}

body.dark-mode .apple-menu { background: rgba(40, 40, 40, 0.9); }
.apple-menu.active { opacity: 1; transform: translateY(0); pointer-events: auto; }

.apple-menu-section { padding: 4px 0; }
.apple-menu-title { font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text-tertiary); padding: 4px 16px 6px 16px; }
.apple-menu-item { display: flex; align-items: center; gap: 10px; padding: 6px 16px; cursor: pointer; }
.apple-menu-item:hover { background: rgba(0, 0, 0, 0.05); }
body.dark-mode .apple-menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.menu-item-icon { font-size: 14px; width: 20px; text-align: center; }
.apple-menu-divider { height: 1px; background: rgba(0, 0, 0, 0.1); margin: 4px 0; }

.app-menu { display: flex; gap: 4px; margin-left: 12px; }
.menu-item-wrapper { position: relative; }
.menu-item { padding: 4px 10px; border-radius: 4px; cursor: pointer; }
.menu-item:hover { background: rgba(255, 255, 255, 0.2); }

.dropdown-menu {
    position: absolute; top: 30px; left: 0; min-width: 180px;
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(25px);
    border-radius: 10px; border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-strong); padding: 6px 0;
    opacity: 0; transform: translateY(-8px); pointer-events: none;
    transition: all 0.2s ease; z-index: 1000;
}

body.dark-mode .dropdown-menu { background: rgba(40, 40, 40, 0.9); }
.dropdown-menu.active { opacity: 1; transform: translateY(0); pointer-events: auto; }
.dropdown-item { padding: 6px 16px; cursor: pointer; font-size: 13px; }
.dropdown-item:hover { background: rgba(0, 0, 0, 0.05); }
.dropdown-divider { height: 1px; background: rgba(0, 0, 0, 0.1); margin: 4px 0; }

.menu-right { display: flex; align-items: center; gap: 12px; }
.menu-status { cursor: pointer; font-size: 14px; transition: transform 0.2s; }
.menu-status:hover { transform: scale(1.15); }

.desktop-container { height: calc(100vh - 34px - 80px); overflow: hidden; }

.container {
    display: grid; grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 180px; gap: 20px; padding: 32px;
    height: 100%; overflow-y: auto;
}

.card {
    background: var(--glass-bg); backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); border-radius: var(--card-radius);
    padding: 24px; cursor: pointer; transition: all var(--animation-duration) cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; overflow: hidden;
    animation: cardIn 0.5s ease forwards; opacity: 0; transform: translateY(20px) scale(0.95);
}

@keyframes cardIn { to { opacity: 1; transform: translateY(0) scale(1); } }

.card:hover {
    background: var(--glass-bg-hover); transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-strong); border-color: var(--glass-border-strong);
}

.card-content { height: 100%; display: flex; flex-direction: column; justify-content: center; }
.card-icon { font-size: 36px; margin-bottom: 12px; line-height: 1; }
.card-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; color: var(--text-primary); }
.card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.card-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity 0.2s; }
.card:hover .card-actions { opacity: 1; }
.card-action-btn { width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.card-action-btn.edit { background: rgba(0, 113, 227, 0.9); color: white; }
.card-action-btn.delete { background: rgba(255, 95, 87, 0.9); color: white; }

.hero-post { grid-column: span 2; grid-row: span 2; }
.hero-post .card-icon { font-size: 56px; margin-bottom: 16px; }
.hero-post .card-title { font-size: 28px; margin-bottom: 10px; }
.hero-post .card-desc { font-size: 16px; }
.wide-post { grid-column: span 2; flex-direction: row; align-items: center; }
.wide-post .card-content { flex-direction: row; align-items: center; gap: 20px; }
.wide-post .card-icon { font-size: 48px; margin-bottom: 0; }

.dock {
    position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
    height: 68px; background: rgba(255, 255, 255, 0.28); backdrop-filter: blur(25px);
    border-radius: var(--dock-radius); padding: 0 12px; display: flex;
    align-items: center; gap: 14px; border: 0.7px solid var(--glass-border);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.14); z-index: 99;
}

body.dark-mode .dock { background: rgba(40, 40, 40, 0.55); }
.dock-item {
    width: 50px; height: 50px; background: rgba(255, 255, 255, 0.9);
    border-radius: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 26px; cursor: pointer; transition: all var(--animation-duration) cubic-bezier(0.2, 0.8, 0.2, 1);
}

body.dark-mode .dock-item { background: rgba(60, 60, 60, 0.9); }
.dock-item:hover { transform: scale(1.35) translateY(-12px); margin: 0 12px; }
.dock-separator { width: 1px; height: 44px; background: rgba(255, 255, 255, 0.35); margin: 0 4px; }

.settings-panel {
    position: fixed; top: 44px; right: 20px; width: 320px;
    background: var(--glass-bg); backdrop-filter: blur(30px);
    border-radius: var(--modal-radius); border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-strong); z-index: 999;
    opacity: 0; transform: translateY(-10px) scale(0.95);
    pointer-events: none; transition: all 0.25s ease;
}

.settings-panel.active { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.settings-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--glass-border); }
.settings-title { font-size: 15px; font-weight: 600; }
.settings-close { width: 28px; height: 28px; border: none; background: rgba(0, 0, 0, 0.06); border-radius: 50%; cursor: pointer; font-size: 14px; }
.settings-content { padding: 20px; }
.setting-item { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.setting-label { font-size: 14px; font-weight: 500; }

.toggle-switch { position: relative; display: inline-block; width: 48px; height: 28px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.15); transition: 0.3s; border-radius: 28px;
}
.toggle-slider:before {
    position: absolute; content: ""; height: 22px; width: 22px; left: 3px; bottom: 3px;
    background-color: white; transition: 0.3s; border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.toggle-switch input:checked + .toggle-slider { background-color: #34c759; }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

.wallpaper-options { display: flex; gap: 8px; flex-wrap: wrap; }
.wallpaper-btn {
    padding: 8px 16px; border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.3); border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 500; transition: all 0.2s; color: var(--text-primary);
}
.wallpaper-btn:hover { background: rgba(255, 255, 255, 0.5); transform: translateY(-1px); }
.wallpaper-btn.active { background: var(--accent-blue); color: white; border-color: var(--accent-blue); }

.reset-btn {
    width: 100%; padding: 12px; background: rgba(255, 59, 48, 0.1);
    color: #ff3b30; border: 1px solid rgba(255, 59, 48, 0.3);
    border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 500;
}
.reset-btn:hover { background: rgba(255, 59, 48, 0.18); transform: translateY(-1px); }

.settings-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 998; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.settings-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(8px);
    z-index: 1000; align-items: center; justify-content: center; padding: 40px;
}
.modal.active { display: flex; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
    background: rgba(246, 246, 246, 0.95); backdrop-filter: blur(30px);
    border-radius: var(--modal-radius); width: 100%; max-width: 800px; max-height: 85vh;
    display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
    animation: slideUp var(--animation-duration) cubic-bezier(0.2, 0.8, 0.2, 1);
}
body.dark-mode .modal-content { background: rgba(30, 30, 30, 0.95); }

@keyframes slideUp { from { opacity: 0; transform: translateY(30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

.modal-header {
    height: 52px; background: linear-gradient(180deg, #f6f6f6 0%, #e8e8e8 100%);
    border-bottom: 1px solid #d1d1d1; display: flex; align-items: center;
    padding: 0 16px; border-radius: var(--modal-radius) var(--modal-radius) 0 0;
}
body.dark-mode .modal-header { background: linear-gradient(180deg, #2d2d2d 0%, #1f1f1f 100%); border-bottom-color: #3a3a3a; }

.modal-traffic-lights { display: flex; gap: 8px; margin-right: 16px; }
.modal-light { width: 12px; height: 12px; border-radius: 50%; cursor: pointer; transition: all 0.15s; border: 1px solid rgba(0, 0, 0, 0.15); }
.modal-light.red { background: #ff5f57; }
.modal-light.red:hover { background: #ff3b30; }
.modal-light.yellow { background: #ffbd2e; }
.modal-light.green { background: #28ca42; }

.modal-title { font-size: 13px; font-weight: 500; color: #333; flex: 1; text-align: center; margin-right: 60px; }
body.dark-mode .modal-title { color: #f5f5f7; }
.modal-body { flex: 1; overflow-y: auto; padding: 40px 50px; background: #ffffff; border-radius: 0 0 var(--modal-radius) var(--modal-radius); }
body.dark-mode .modal-body { background: #1a1a1a; }

.modal-body h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.modal-body h2 { font-size: 20px; font-weight: 600; margin: 28px 0 12px 0; }
.modal-body p { font-size: 16px; line-height: 1.7; color: #424245; margin-bottom: 16px; }
body.dark-mode .modal-body p { color: #a1a1a6; }
.modal-body ul, .modal-body ol { margin: 16px 0; padding-left: 24px; }
.modal-body li { margin: 8px 0; }
.modal-body code { background: rgba(0, 0, 0, 0.05); padding: 2px 6px; border-radius: 4px; font-family: monospace; }
.modal-body pre { background: #1a1a1a; padding: 16px; border-radius: 8px; overflow-x: auto; margin: 16px 0; }
.modal-body pre code { background: none; padding: 0; color: #f5f5f7; }
.modal-body blockquote { border-left: 4px solid var(--accent-blue); padding-left: 16px; margin: 16px 0; color: var(--text-secondary); }
.modal-body img { max-width: 100%; border-radius: 8px; margin: 16px 0; }
.modal-body a { color: var(--accent-blue); text-decoration: none; }
.modal-body a:hover { text-decoration: underline; }
.modal-body hr { border: none; border-top: 1px solid var(--glass-border); margin: 24px 0; }
.modal-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.modal-body th, .modal-body td { border: 1px solid var(--glass-border); padding: 8px 12px; text-align: left; }
.modal-body th { background: rgba(0, 0, 0, 0.05); }

.admin-modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(10px);
    z-index: 2000; align-items: center; justify-content: center; padding: 20px;
}
.admin-modal.active { display: flex; }

.admin-content {
    background: rgba(246, 246, 246, 0.98); backdrop-filter: blur(30px);
    border-radius: 20px; width: 100%; max-width: 1200px; height: 90vh;
    display: flex; flex-direction: column; box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
}
body.dark-mode .admin-content { background: rgba(30, 30, 30, 0.98); }

.admin-header {
    height: 52px; background: linear-gradient(180deg, #f6f6f6 0%, #e8e8e8 100%);
    border-bottom: 1px solid #d1d1d1; display: flex; align-items: center;
    padding: 0 16px; border-radius: 20px 20px 0 0;
}
body.dark-mode .admin-header { background: linear-gradient(180deg, #2d2d2d 0%, #1f1f1f 100%); border-bottom-color: #3a3a3a; }

.admin-traffic-lights { display: flex; gap: 8px; }
.admin-title { font-size: 15px; font-weight: 600; flex: 1; text-align: center; margin-right: 60px; }

.admin-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.admin-tabs { display: flex; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--glass-border); background: rgba(255, 255, 255, 0.5); }
.admin-tab {
    padding: 8px 20px; border: none; background: transparent; border-radius: 8px;
    cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-secondary); transition: all 0.2s;
}
.admin-tab:hover { background: rgba(0, 0, 0, 0.05); }
.admin-tab.active { background: var(--accent-blue); color: white; }

.admin-tab-content { flex: 1; overflow-y: auto; padding: 20px; }
.admin-tab-content.hidden { display: none; }

.posts-list { display: flex; flex-direction: column; gap: 12px; }
.post-item {
    display: flex; align-items: center; gap: 16px; padding: 16px;
    background: rgba(255, 255, 255, 0.5); border-radius: 12px; border: 1px solid var(--glass-border);
}
.post-item-icon { font-size: 32px; }
.post-item-info { flex: 1; }
.post-item-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.post-item-meta { font-size: 13px; color: var(--text-secondary); }
.post-item-actions { display: flex; gap: 8px; }

.btn-primary, .btn-secondary, .btn-danger {
    padding: 10px 20px; border: none; border-radius: 10px; cursor: pointer;
    font-size: 14px; font-weight: 500; transition: all 0.2s;
}
.btn-primary { background: var(--accent-blue); color: white; }
.btn-primary:hover { background: #0077ED; transform: translateY(-1px); }
.btn-secondary { background: rgba(0, 0, 0, 0.08); color: var(--text-primary); }
.btn-secondary:hover { background: rgba(0, 0, 0, 0.12); transform: translateY(-1px); }
.btn-danger { background: rgba(255, 59, 48, 0.1); color: #ff3b30; }
.btn-danger:hover { background: rgba(255, 59, 48, 0.18); transform: translateY(-1px); }

.editor-container { display: flex; flex-direction: column; height: 100%; gap: 16px; }
.editor-header { display: flex; flex-direction: column; gap: 12px; }
.editor-input {
    padding: 12px 16px; border: 1px solid var(--glass-border);
    border-radius: 12px; background: rgba(255, 255, 255, 0.5);
    font-size: 16px; font-family: inherit; color: var(--text-primary);
}
.editor-input:focus { outline: none; border-color: var(--accent-blue); }
.editor-input-small { width: 150px; padding: 10px 12px; font-size: 14px; }
.editor-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.editor-split { display: flex; flex: 1; gap: 16px; min-height: 400px; }
.editor-pane, .preview-pane { flex: 1; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; border: 1px solid var(--glass-border); }

.editor-toolbar {
    display: flex; gap: 4px; padding: 8px 12px; background: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid var(--glass-border); flex-wrap: wrap;
}
.editor-toolbar button {
    width: 36px; height: 36px; border: none; background: transparent;
    border-radius: 8px; cursor: pointer; font-size: 16px; font-weight: 600;
    transition: all 0.15s;
}
.editor-toolbar button:hover { background: rgba(0, 0, 0, 0.08); }

.editor-textarea {
    flex: 1; padding: 16px; border: none; background: rgba(255, 255, 255, 0.3);
    font-family: 'Monaco', 'Menlo', monospace; font-size: 14px; line-height: 1.6;
    resize: none; color: var(--text-primary);
}
.editor-textarea:focus { outline: none; }

.preview-header { padding: 12px 16px; background: rgba(255, 255, 255, 0.5); border-bottom: 1px solid var(--glass-border); font-weight: 500; }
.preview-content { flex: 1; padding: 16px; overflow-y: auto; background: rgba(255, 255, 255, 0.3); }

.editor-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 8px; }

.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 18px; font-weight: 600; margin-bottom: 16px; }
.settings-section .btn-secondary, .settings-section .btn-danger { margin-right: 12px; margin-bottom: 12px; }
.help-list { padding-left: 20px; }
.help-list li { margin: 8px 0; color: var(--text-secondary); }

@media (max-width: 1024px) {
    .container { grid-template-columns: repeat(3, 1fr); padding: 28px; gap: 18px; }
    .hero-post { grid-column: span 2; }
    .wide-post { grid-column: span 3; }
    .editor-split { flex-direction: column; }
}

@media (max-width: 768px) {
    .container { grid-template-columns: repeat(2, 1fr); padding: 20px; gap: 16px; grid-auto-rows: 160px; }
    .hero-post { grid-column: span 2; grid-row: span 2; }
    .wide-post { grid-column: span 2; flex-direction: column; }
    .app-menu { display: none; }
    .dock { height: 60px; }
    .dock-item { width: 44px; height: 44px; font-size: 22px; }
    .admin-content { height: 95vh; border-radius: 16px; }
}

@media (max-width: 480px) {
    .container { grid-template-columns: 1fr; padding: 16px; gap: 14px; }
    .hero-post, .wide-post { grid-column: span 1; }
    .hero-post { grid-row: span 2; }
}
