.cache-toggle{display:inline-flex;align-items:center;margin-left:10px;font-size:12px;color:#555}.cache-toggle input{margin-right:6px}
/* Base styles */
:root {
    --primary-color: #2d3748;
    --secondary-color: #4a5568;
    --accent-color: #4299e1;
    --bg-color: #f7fafc;
    --card-bg: #ffffff;
    --text-color: #1a202c;
    --text-light: #4a5568;
    --border-radius: 8px;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Caveat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
}

.container { max-width: 1000px; margin: 0 auto; padding: 20px; }

h1 {
    text-align: center; color: var(--primary-color); margin-bottom: 2rem; font-weight: 600; font-size: 2.5rem; letter-spacing: -0.02em;
}

/* New: topbar + auth controls */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar h1 { margin: 0; }
.auth-controls { display: flex; align-items: center; gap: 10px; }
.auth-btn {
    padding: 6px 12px; background: var(--accent-color); color: #fff; border: none; border-radius: 6px; cursor: pointer;
    font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.auth-btn:hover { background: #3182ce; }
.user-badge { display: flex; align-items: center; gap: 8px; }
.user-badge img { width: 24px; height: 24px; border-radius: 50%; }
.user-badge a { color: var(--secondary-color); text-decoration: none; font-weight: 600; }

/* Search bar */
.search-container { display: flex; gap: 10px; margin-bottom: 2rem; max-width: 700px; margin-left: auto; margin-right: auto; }

#search-input {
    flex: 1; padding: 12px 16px; font-size: 1rem; font-family: 'Caveat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; border: 1px solid #e2e8f0; border-radius: var(--border-radius); background: white; transition: all 0.2s; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
}

#search-input:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1); }

#search-btn {
    padding: 0 24px; background: var(--accent-color); color: white; border: none; border-radius: var(--border-radius); font-family: 'Caveat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; font-weight: 600; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
}

.secondary-btn {
    padding: 0 16px; background: #e2e8f0; color: #1a202c; border: none; border-radius: var(--border-radius);
    font-weight: 600; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
}
.secondary-btn:hover { background: #cbd5e1; transform: translateY(-1px); }
.secondary-btn:active { transform: translateY(1px); }

.primary-btn {
    padding: 0 16px; background: var(--accent-color); color: #fff; border: none; border-radius: var(--border-radius);
    font-weight: 700; cursor: pointer; transition: all 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.08);
}
.primary-btn:hover { background: #3182ce; transform: translateY(-1px); }
.primary-btn:active { transform: translateY(1px); }

/* Modal */
.hidden { display: none !important; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 1000; }
.modal-dialog { width: 100%; max-width: 800px; background: #fff; border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #e2e8f0; }
.modal-body { padding: 16px; max-height: 70vh; overflow-y: auto; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 1px solid #e2e8f0; background: #f8fafc; }
.icon-btn { background: transparent; border: none; color: var(--secondary-color); cursor: pointer; font-size: 16px; }

.form-row { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.form-row label { min-width: 110px; color: var(--secondary-color); }
.form-row input[type="text"], .form-row input[type="search"], .form-row textarea { flex: 1; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-family: inherit; }
.form-row textarea { min-height: 140px; resize: vertical; }
.form-row .checkbox { display: inline-flex; align-items: center; gap: 8px; }
.hint { color: #64748b; font-size: 12px; }

/* Use normal UI font for short description, not the handwriting font */
#gist-description {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
}

.files-list { display: grid; gap: 12px; }
.file-card { border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.file-card .file-header { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.file-card .file-body { padding: 10px 12px; }
.file-card .file-name { flex: 1; min-width: 0; }
.file-card .icon-btn { color: #475569; }
.files-toolbar { display: flex; justify-content: flex-end; margin-top: 10px; }

/* Larger default editor size for gist file content */
.file-card .file-body .file-content {
    width: 746px;
    height: 386px;
    max-width: 100%;
}

#search-btn:hover { background: #3182ce; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.1); }
#search-btn:active { transform: translateY(1px); }
#search-btn:disabled { background: #a0aec0; cursor: not-allowed; transform: none; }

/* Ensure handwriting font also applies to placeholders and toggle label */
#search-input::placeholder,
#search-input::-webkit-input-placeholder,
#search-input::-moz-placeholder,
#search-input:-ms-input-placeholder,
#search-input::-ms-input-placeholder { font-family: 'Caveat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; }

.search-container input,
.search-container button,
.cache-toggle,
.cache-toggle span { font-family: 'Caveat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; }

/* Results container and status messages */
#results { max-width: 700px; margin: 0 auto; }
#results p { text-align: left; color: #4a5568; margin: 1.25rem 0; padding: 1rem 1.25rem; background: #f8fafc; border-radius: 8px; max-width: 100%; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-size: 1rem; display: flex; align-items: center; justify-content: flex-start; gap: 0.75rem; }
[data-theme="dark"] #results p { background: #1e293b; color: #e2e8f0; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }

/* Loading states */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

#results p.loading { display: flex; align-items: center; justify-content: flex-start; gap: 0.75rem; padding: 1.25rem 1.5rem; color: var(--text-light); font-size: 1rem; animation: pulse 1.5s ease-in-out infinite; }
#results p.loading::before { content: ''; display: block; width: 1.5rem; height: 1.5rem; border: 2px solid var(--accent-color); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }

.no-results, .error-message { text-align: center; padding: 2rem; color: var(--text-light); max-width: 500px; margin: 0 auto; }
.no-results p, .error-message p { margin-bottom: 1rem; line-height: 1.6; }
.no-results a, .error-message a { color: var(--accent-color); text-decoration: none; font-weight: 500; transition: opacity 0.2s; }
.no-results a:hover, .error-message a:hover { opacity: 0.8; text-decoration: underline; }
.error-message { color: #e53e3e; background-color: #fff5f5; border-radius: var(--border-radius); border-left: 4px solid #feb2b2; }
.error-message code { background: rgba(0, 0, 0, 0.05); padding: 0.2em 0.4em; border-radius: 3px; font-family: monospace; font-size: 0.9em; }
[data-theme="dark"] #results p.loading { color: #cbd5e1; }
[data-theme="dark"] .error-message { background-color: rgba(254, 178, 178, 0.1); color: #feb2b2; }
[data-theme="dark"] .error-message code { background: rgba(0, 0, 0, 0.3); color: #feb2b2; }

/* Gist Cards */
.gist-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; margin-top: 1.5rem; }

.gist-card { background: var(--card-bg); border-radius: var(--border-radius); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04); overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column; height: 100%; }
.gist-card:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08); }
.gist-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 1rem; border-bottom: 1px solid #e2e8f0; }
.gist-filenames { flex: 1; min-width: 0; }
.gist-filename { display: flex; align-items: center; margin-bottom: 0.25rem; font-size: 0.9rem; color: var(--text-color); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gist-filename:last-child { margin-bottom: 0; }
.filename-text { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-icon { margin-right: 0.5rem; flex-shrink: 0; font-size: 0.9em; }
.gist-link { color: var(--accent-color); margin-left: 0.5rem; flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; transition: background-color 0.2s; }
.gist-link:hover { background-color: rgba(66, 153, 225, 0.1); }

.gist-actions { display: inline-flex; align-items: center; gap: 6px; }
.gist-edit, .gist-delete {
    background: transparent; border: none; cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; color: var(--secondary-color);
}
.gist-delete:hover { color: #e53e3e; }
.gist-edit:hover { color: #3182ce; }

/* Copy button */
.gist-copy {
    margin-left: 0.25rem;
    background: transparent;
    color: var(--accent-color);
    border: none;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}
.gist-copy:hover { background-color: rgba(66, 153, 225, 0.1); }
.gist-copy:active { transform: translateY(1px); }
.gist-description { padding: 0.75rem 1rem; font-size: 0.95rem; color: var(--text-light); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; border-bottom: 1px solid #e2e8f0; line-height: 1.4; }
.gist-preview-container { padding: 0.5rem 0; flex: 1; overflow: hidden; position: relative; background: #f8fafc; margin: 0 0.5rem 0.5rem; border-radius: 4px; }
.gist-preview { margin: 0; padding: 0.75rem 1rem; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 0.85rem; line-height: 1.5; color: #334155; white-space: pre; overflow-x: auto; max-height: 200px; border-radius: 4px; tab-size: 2; }

/* Token color classes for optional syntax highlighting libraries */
.gist-preview .token.comment, .gist-preview .token.prolog, .gist-preview .token.doctype, .gist-preview .token.cdata { color: #64748b; }
.gist-preview .token.punctuation { color: #475569; }
.gist-preview .token.property, .gist-preview .token.tag, .gist-preview .token.boolean, .gist-preview .token.number, .gist-preview .token.constant, .gist-preview .token.symbol, .gist-preview .token.deleted { color: #0ea5e9; }
.gist-preview .token.selector, .gist-preview .token.attr-name, .gist-preview .token.string, .gist-preview .token.char, .gist-preview .token.builtin, .gist-preview .token.inserted { color: #10b981; }
.gist-preview .token.operator, .gist-preview .token.entity, .gist-preview .token.url, .gist-preview .language-css .token.string, .gist-preview .style .token.string { color: #f59e0b; }
.gist-preview .token.atrule, .gist-preview .token.attr-value, .gist-preview .token.keyword { color: #8b5cf6; }
.gist-preview .token.function, .gist-preview .token.class-name { color: #3b82f6; }
.gist-preview .token.regex, .gist-preview .token.important, .gist-preview .token.variable { color: #f97316; }

.gist-meta { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; font-size: 0.8rem; color: var(--text-light); background-color: #f8fafc; border-top: 1px solid #e2e8f0; }
.gist-updated { display: flex; align-items: center; color: #64748b; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif; }
.gist-filetype { background: #e2e8f0; color: #475569; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; text-transform: lowercase; }

/* Dark mode styles */
[data-theme="dark"] .gist-card { background: #1e293b; border: 1px solid #334155; }
[data-theme="dark"] .gist-header, [data-theme="dark"] .gist-description { border-color: #334155; }
[data-theme="dark"] .gist-meta { background-color: #0f172a; border-color: #334155; }
[data-theme="dark"] .gist-filename { color: #e2e8f0; }
[data-theme="dark"] .gist-description { color: #94a3b8; }
[data-theme="dark"] .gist-preview { background: #0f172a; color: #cbd5e1; }
[data-theme="dark"] .gist-preview .token.comment, [data-theme="dark"] .gist-preview .token.prolog, [data-theme="dark"] .gist-preview .token.doctype, [data-theme="dark"] .gist-preview .token.cdata { color: #94a3b8; }
[data-theme="dark"] .gist-preview .token.punctuation { color: #cbd5e1; }
[data-theme="dark"] .gist-filetype { background: #334155; color: #e2e8f0; }

/* Highlight styles */
mark { background-color: #ffeb3b; color: #000; padding: 0 2px; border-radius: 3px; font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
[data-theme="dark"] mark { background-color: #ffd700; color: #000; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }

/* Warning message */
.warning { background: #fff5f5; color: #c53030; padding: 12px 16px; border-radius: var(--border-radius); margin-bottom: 1.5rem; text-align: center; font-weight: 500; border-left: 4px solid #feb2b2; }

/* Responsive */
@media (max-width: 768px) {
    .gist-grid { grid-template-columns: 1fr; }
    .search-container { flex-direction: column; }
    #search-btn { padding: 12px; }
}


