/* 哎呦笔记 - 编辑器样式 */
/* CSS 变量 */
:root {
    --bg: #f9fafb;
    --card: #fff;
    --text: #1f2937;
    --border: #e5e7eb;
    --primary: #6366f1;
    --danger: #ef4444;
    --sub-text: #6b7280;
}

html.dark {
    --bg: #111827;
    --card: #1f2937;
    --text: #f3f4f6;
    --border: #374151;
}

body {
    margin: 0;
    padding: 20px;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

/* ── 容器 ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ── 头部 ── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── 按钮 ── */
.btn {
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
    background: #e5e7eb;
    color: #374151;
    transition: filter 0.2s, transform 0.2s;
    font-weight: 500;
    text-decoration: none;
}

html.dark body .btn {
    background: #374151;
    color: #e5e7eb;
}

.btn:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-danger {
    background: #e5e7eb;
    color: var(--danger);
}

html.dark body .btn-danger {
    background: #374151;
}

.btn-danger:hover {
    background: #d1d5db;
    filter: none;
}

html.dark body .btn-danger:hover {
    background: #4b5563;
}

/* ── 标题区域 ── */
.title-area {
    text-align: right;
}

.title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.meta {
    font-size: 0.85rem;
    opacity: 0.6;
}

/* ── 编辑器 ── */
textarea {
    width: 100%;
    height: 75vh;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    resize: vertical;
    outline: none;
    background: var(--card);
    color: var(--text);
    font-family: 'Consolas', 'Monaco', monospace;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea.limit-exceeded {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* ── Markdown 预览 ── */
.preview-content {
    width: 100%;
    min-height: 75vh;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    overflow: auto;
    box-sizing: border-box;
    display: none;
}

.preview-content h1,
.preview-content h2,
.preview-content h3 {
    margin-top: 1.2em;
    margin-bottom: 0.6em;
}

.preview-content p {
    margin: 0.8em 0;
}

.preview-content ul,
.preview-content ol {
    padding-left: 2em;
    margin: 0.8em 0;
}

.preview-content pre {
    background: var(--bg);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

.preview-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 16px;
    margin: 1em 0;
    color: var(--sub-text);
}

.preview-content a {
    color: var(--primary);
    text-decoration: underline;
}

/* ── 模态框 ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--card);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 320px;
    text-align: center;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
}

.modal input {
    width: 100%;
    padding: 10px;
    margin: 15px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-sizing: border-box;
    background: var(--bg);
    color: var(--text);
}

#qrcode {
    margin: 20px auto;
    display: flex;
    justify-content: center;
}

/* ── Toast 提示 ── */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 2000;
}

.toast.show {
    opacity: 1;
}

.toast.error {
    background: var(--danger);
}

/* ── 自动保存指示器 ── */
.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s;
    color: var(--primary);
}

.auto-save-indicator.show {
    opacity: 0.7;
}

.auto-save-indicator.error {
    color: var(--danger);
}

/* ── 帮助链接 ── */
.help-link {
    margin-top: 30px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--sub-text);
}

.help-link a,
.help-link-hover {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0.7;
}

.help-link a:hover,
.help-link-hover:hover {
    opacity: 1;
}

/* ── 响应式 ── */
@media (max-width: 600px) {
    .header {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .title-area {
        text-align: left;
    }
    .actions {
        justify-content: center;
    }
}
