:root {
    --bg-start: #1e1e2f;
    --bg-end: #2e2e4e;
    --accent: #00ff88;
    --accent-dark: #00cc66;
    --text-primary: #d4d4d8;
    --text-secondary: #a6accd;
    --text-muted: #7f849c;
    --border-color: #30363d;
    --bg-surface: #161b22;
    --link-color: #58a6ff;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-header {
    padding: 20px 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.site-main {
    flex-grow: 1;
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 20px 40px;
    box-sizing: border-box;
}

.main-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.main-nav form {
    margin: 0;
}

.main-nav a,
.link-button {
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s, transform 0.2s;
}

.main-nav a:hover,
.link-button:hover {
    color: var(--accent);
    transform: scale(1.05);
    text-decoration: none;
}

.link-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
    padding: 0;
}

.site-footer {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
}

.content-frame {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px 35px;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

h1,
h2 {
    font-family: 'Courier New', monospace;
    color: var(--accent);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5em;
}

h2 {
    font-size: 1.8em;
}

.post-preview {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.post-preview:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 255, 136, 0.2);
}

.post-preview a {
    font-family: 'Courier New', monospace;
    font-size: 1.5em;
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

.post-preview a:hover {
    color: var(--accent-dark);
}

.post-preview p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: 10px;
    max-height: 4.8em;
    overflow: hidden;
    font-size: 1em;
    flex-grow: 1;
}

form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 30px;
}

.form-narrow {
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

form label {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-bottom: -10px;
}

form input[type="text"],
form input[type="email"],
form input[type="password"],
form textarea {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s;
}

form input:focus,
form textarea:focus {
    outline: none;
    border-color: var(--link-color);
    box-shadow: 0 0 10px rgba(88, 166, 255, 0.3);
}

form input[type="submit"] {
    align-self: flex-start;
    padding: 10px 20px;
    background: var(--accent);
    color: var(--bg-start);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    transition: background-color 0.3s, transform 0.2s;
}

form input[type="submit"]:hover {
    background-color: var(--accent-dark);
    transform: scale(1.05);
}

.post-view .meta {
    color: var(--text-muted);
    font-size: 0.9em;
    margin-top: -20px;
    margin-bottom: 20px;
}

.post-view .content {
    line-height: 1.8;
}

.post-view .content > *:first-child {
    margin-top: 0;
}

.post-view .content > * + * {
    margin-top: 1em;
}

.post-view .content h1,
.post-view .content h2,
.post-view .content h3,
.post-view .content h4,
.post-view .content h5,
.post-view .content h6 {
    margin-top: 1.8em;
    margin-bottom: 0.8em;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    text-shadow: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: .3em;
}

.post-view .content h1 {
    font-size: 2em;
}

.post-view .content h2 {
    font-size: 1.5em;
}

.post-view .content h3 {
    font-size: 1.25em;
    border-bottom: none;
}

.post-view .content ul,
.post-view .content ol {
    padding-left: 2em;
    margin-top: 1em;
    margin-bottom: 1em;
}
.post-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
}
.post-view .content li + li {
    margin-top: .25em;
}

.post-view .content blockquote {
    margin-left: 0;
    padding: 0 1em;
    color: var(--text-muted);
    border-left: .25em solid var(--border-color);
}

.post-view .content hr {
    margin-top: 2em;
    margin-bottom: 2em;
    height: .25em;
    background-color: var(--border-color);
    border: 0;
}

.post-view .content a {
    color: var(--link-color);
    text-decoration: none;
}

.post-view .content a:hover {
    text-decoration: underline;
}

.post-view .content table {
    width: 100%;
    border-collapse: collapse;
    display: block;
    overflow: auto;
}

.post-view .content th,
.post-view .content td {
    padding: 6px 13px;
    border: 1px solid var(--border-color);
}

.post-view .content tr:nth-child(2n) {
    background-color: var(--bg-surface);
}

.post-view .content code {
    padding: .2em .4em;
    font-size: 85%;
    background-color: rgba(110, 118, 129, 0.4);
    border-radius: 6px;
    font-family: 'Courier New', monospace;
}

.post-view .content pre code {
    background: none;
    padding: 0;
    font-size: 100%;
}

.post-actions {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 20px;
    align-items: center;
}

.post-actions form {
    margin: 0;
}

.action-link {
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.2s, transform 0.2s;
}

.action-link:hover {
    color: var(--accent);
    transform: scale(1.05);
}

.action-link.delete-link {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.code-block-wrapper {
    position: relative;
    margin-top: 1.5em;
    margin-bottom: 1.5em;
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background-color: #2a2f38;
    color: var(--text-muted);
    padding: 6px 8px;
    font-size: 0.75em;
    font-family: 'Courier New', monospace;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    border: 1px solid var(--border-color);
    border-bottom: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    line-height: 1.2;
}

.language-label {
    text-transform: lowercase;
    font-weight: 500;
}

.code-block-buttons {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.code-toggle-button {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 6px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.65em;
    transition: all 0.2s ease;
    min-width: 24px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.code-toggle-button:hover {
    background-color: var(--accent);
    color: var(--bg-start);
    transform: scale(1.05);
}

.code-toggle-button svg {
    width: 12px;
    height: 12px;
    fill: var(--text-muted);
    transition: fill 0.2s;
}

.code-toggle-button:hover svg {
    fill: var(--bg-start);
}

.code-toggle-button[title]:hover:after {
    content: attr(title);
    position: absolute;
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7em;
    top: -28px;
    z-index: 10;
    white-space: nowrap;
}

.code-block-wrapper pre {
    margin: 0 !important;
    padding: 12px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: #282a36;
    color: #f8f8f2;
    overflow-x: auto;
    white-space: pre;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.code-block-wrapper pre::-webkit-scrollbar {
    height: 8px;
}

.code-block-wrapper pre::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.code-block-wrapper pre::-webkit-scrollbar-track {
    background: transparent;
}

@media (max-width: 768px) {
    .code-block-wrapper pre {
        padding: 8px;
    }
}

.copy-button {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 3px 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    transition: all 0.2s;
}

.copy-button:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.copy-button.copied {
    background-color: var(--accent-dark);
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.flash {
    padding: 15px;
    margin-bottom: 30px;
    border-radius: 6px;
    text-align: center;
    font-family: 'Courier New', monospace;
    animation: fadeIn 0.5s;
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.flash.success {
    background-color: rgba(0, 255, 136, 0.05);
    border: 1px solid var(--accent);
    color: var(--accent);
}

.flash.error {
    background-color: rgba(255, 77, 77, 0.05);
    border: 1px solid #ff4d4d;
    color: #ff4d4d;
}
.flash.fade-out {
    opacity: 0;
    transform: translateY(-20px);
}
.error {
    color: #ff4d4d;
    font-size: 0.9em;
    margin-top: 5px;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
    font-family: 'Courier New', monospace;
    flex-wrap: wrap;
}

.pagination-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s;
}

.pagination-link:hover {
    color: var(--accent);
    border-color: var(--accent);
    background-color: rgba(0, 255, 136, 0.1);
}

.pagination-current {
    color: var(--accent);
    padding: 8px 12px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background-color: rgba(0, 255, 136, 0.1);
}

.search-form {
    margin-bottom: 25px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.search-container {
    position: relative;
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.search-container input[type="text"] {
    flex-grow: 1;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
}

.search-container input[type="text"]:focus {
    outline: none;
    box-shadow: inset 0 0 5px rgba(88, 166, 255, 0.3);
}

.search-button {
    padding: 8px 16px;
    background: var(--accent);
    color: var(--bg-start);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    font-weight: bold;
    transition: background-color 0.2s, transform 0.2s;
}

.search-button:hover {
    background: var(--accent-dark);
    transform: scale(1.05);
}

.search-button::before {
    margin-right: 5px;
}
.autocomplete-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.suggestion-item {
    display: block;
    padding: 10px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-item:hover {
    background-color: rgba(0, 255, 136, 0.1);
    color: var(--accent);
}
.back-link {
    display: inline-block;
    font-family: 'Courier New', monospace;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 20px;
    transition: color 0.2s, transform 0.2s;
}

.back-link:hover {
    color: var(--accent);
    transform: scale(1.05);
}

.tags {
    margin-top: 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag-cloud {
    margin: 20px 0;
    padding: 15px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

.tag-cloud h2 {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: var(--accent);
    width: 100%;
    text-align: center;
}
.tag-cloud .tag-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
}
.tag-link {
    display: inline-block;
    padding: 3px 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}

.tag-link:hover {
    background: var(--accent);
    color: var(--bg-start);
    border-color: var(--accent);
    transform: scale(1.0);
}

.post-preview .tags .tag-link {
    font-size: 0.8em !important;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .site-header,
    .site-main {
        padding: 15px 20px;
    }
    .main-nav {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    .main-nav a,
    .link-button {
        font-size: 1em;
        width: 100%;
        text-align: center;
    }
    .post-preview {
        margin-bottom: 20px;
        padding: 15px;
    }
    .post-preview a {
        font-size: 1.2em;
    }
    .post-preview p {
        font-size: 0.95em;
        max-height: 4.8em;
    }
    .form-narrow {
        max-width: 100%;
    }
    .content-frame {
        padding: 15px 20px;
    }
    .search-form {
        max-width: 90%;
    }
    .search-container {
        padding: 6px;
    }
    .search-container input[type="text"] {
        font-size: 0.9em;
    }
    .search-button {
        padding: 6px 12px;
        font-size: 0.9em;
    }
    .post-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2em;
    }
    h2 {
        font-size: 1.5em;
    }
    .post-preview p {
        max-height: 3.2em;
    }
    .pagination {
        flex-wrap: wrap;
    }
    .tag-cloud {
        text-align: center;
    }
    .tag-link {
        font-size: 0.8em;
    }
}
.loading, .error, .empty-preview {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-style: italic;
}

.error {
    color: #ff4d4d;
    border: 1px solid #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
    border-radius: 4px;
}

.empty-preview {
    color: var(--text-secondary);
    border: 1px dashed var(--border-color);
    border-radius: 4px;
}

#preview {
    transition: opacity 0.3s ease-in-out;
    opacity: 1;
}

#preview[style*="display: none"] {
    opacity: 0;
}
.meta span {
    display: inline-block;
    margin-right: 20px;
}

.updated-at {
    color: var(--text-muted);
    font-size: 0.9em;
}
.editor-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
    background: var(--bg-surface);
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.editor-button {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    transition: all 0.2s;
}

.editor-button:hover {
    background: var(--accent);
    color: var(--bg-start);
    border-color: var(--accent);
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .editor-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .editor-button {
        width: 100%;
        text-align: center;
    }
}

.content iframe {
    max-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    margin: 10px 0;
    display: block;
}
.emoji-picker {
    display: none;
    position: absolute;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    margin-top: 5px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.emoji-button {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}

.emoji-button:hover {
    background: rgba(0, 255, 136, 0.1);
}

.editor-toolbar {
    display: flex;
    gap: 8px;
    margin: 10px 0;
    flex-wrap: wrap;
    background: var(--bg-surface);
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

@media (max-width: 768px) {
    .editor-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .editor-button {
        width: 100%;
        text-align: center;
    }
    .emoji-picker {
        width: 100%;
        max-width: 300px;
    }
}
/* Styles for the new single modal system */
.modal-overlay {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1001;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

.modal-content.emoji-modal {
    width: auto;
    max-width: 320px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content h3 {
    margin: 0 0 15px 0;
    color: var(--accent);
    font-family: 'Courier New', monospace;
    font-size: 1.2em;
    text-align: center;
}

.modal-content label {
    display: block;
    margin: 10px 0 5px 0;
    color: var(--text-muted);
    font-size: 0.9em;
}

.modal-input {
    width: 100%;
    padding: 10px;
    background: var(--bg-start);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 1em;
    box-sizing: border-box;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 5px rgba(0, 255, 136, 0.3);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

.modal-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    transition: all 0.2s;
}

.modal-ok {
    background: var(--accent);
    color: var(--bg-start);
}

.modal-ok:hover {
    background: var(--accent-dark);
    transform: scale(1.05);
}

.modal-cancel {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.modal-cancel:hover {
    background: var(--bg-start);
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        padding: 15px;
    }
    .modal-buttons {
        flex-direction: column;
    }
}
.emoji-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    width: 300px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
}

.emoji-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.emoji-tab {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    transition: all 0.2s;
}

.emoji-tab.active, .emoji-tab:hover {
    background: var(--accent);
    color: var(--bg-start);
    border-color: var(--accent);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

.emoji-button {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    border-radius: 50%;
    transition: background 0.2s;
    box-sizing: border-box;
}

.emoji-button:hover {
    background: rgba(0, 255, 136, 0.1);
}

@media (max-width: 768px) {
    .emoji-modal {
        width: 90%;
    }
    .emoji-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
