:root {
    --primary: #4A90D9;
    --primary-hover: #357ABD;
    --primary-light: #E8F2FC;
    --bg: #F5F7FA;
    --card-bg: #FFFFFF;
    --text: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --border: #E8ECEF;
    --border-hover: #D0D7DE;
    --hover: #F0F4F8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-sm: 6px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px;
}

.header {
    text-align: center;
    margin-bottom: 24px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.main {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.editor-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: #FAFBFC;
}

.section-header h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.char-count {
    font-size: 12px;
    color: var(--text-light);
}

.sample-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: var(--primary);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.sample-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.sample-btn:active {
    transform: translateY(0);
}

.sample-icon {
    font-size: 14px;
}

.toolbar {
    padding: 10px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: #FAFBFC;
}

.toolbar-templates {
    border-bottom: none;
    padding-bottom: 4px;
}

.toolbar-label {
    font-size: 12px;
    color: var(--text-light);
    margin-right: 4px;
    white-space: nowrap;
}

.template-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    font-family: inherit;
}

.template-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.template-btn:active {
    transform: scale(0.98);
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: var(--hover);
    border-color: var(--primary);
    color: var(--primary);
}

.toolbar-btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

.btn-text {
    font-size: 13px;
}

.editor-wrapper {
    padding: 16px;
    position: relative;
}

#editor {
    width: 100%;
    min-height: calc(100vh - 260px);
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 14px;
    line-height: 1.8;
    resize: none;
    transition: var(--transition);
    color: var(--text);
    background: #FAFBFC;
}

#editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
    background: #FFFFFF;
}

#editor::placeholder {
    color: var(--text-light);
}

.safe-width-guide {
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: calc(16px + 14px + 375px);
    width: 1px;
    border-left: 1px dashed #C0C0C0;
    z-index: 10;
    pointer-events: none;
    transition: left 0.2s ease;
}

.safe-width-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 4px;
    z-index: 11;
}

.safe-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 4px 10px 2px;
    border: 1px solid #E0E0E0;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.8);
    color: #B0B0B0;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    line-height: 1.2;
}

.safe-mode-btn:hover {
    border-color: #C0C0C0;
    color: #909090;
}

.safe-mode-btn.active {
    border-color: #B0B0B0;
    background: rgba(0, 0, 0, 0.04);
    color: #808080;
}

.safe-width-label {
    font-size: 9px;
    color: #C0C0C0;
    line-height: 1;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--primary);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-icon {
    font-size: 15px;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    background: var(--hover);
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.section-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Style Options */
.style-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.style-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    background: var(--card-bg);
    min-width: auto;
    flex-shrink: 0;
}

.style-option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.style-option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.2);
}

.style-option .option-preview {
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    white-space: nowrap;
}

/* Input Fields */
.input-field {
    margin-bottom: 12px;
}

.input-field:last-child {
    margin-bottom: 0;
}

.input-field label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-field input,
.input-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: var(--transition);
    background: #FAFBFC;
}

.input-field input:focus,
.input-field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
    background: #FFFFFF;
}

.input-field textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.6;
}

.input-field input::placeholder,
.input-field textarea::placeholder {
    color: var(--text-light);
}

/* Todo List Inputs */
.todo-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.todo-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.todo-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.todo-item input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: var(--transition);
    background: #FAFBFC;
}

.todo-item input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
    background: #FFFFFF;
}

.todo-item input[type="text"]::placeholder {
    color: var(--text-light);
}

.todo-remove {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    background: none;
    color: var(--text-light);
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.todo-remove:hover {
    background: #FEE2E2;
    color: #EF4444;
}

.todo-add {
    width: 100%;
    padding: 8px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--primary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.todo-add:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* @ Mention Inputs */
.at-section-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.at-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.at-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.at-symbol {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.at-item input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    transition: var(--transition);
    background: #FAFBFC;
}

.at-item input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
    background: #FFFFFF;
}

.at-item input::placeholder {
    color: var(--text-light);
}

.at-remove {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 4px;
    background: none;
    color: var(--text-light);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.at-remove:hover {
    background: #FEE2E2;
    color: #EF4444;
}

.at-divider {
    height: 1px;
    background: var(--border);
    margin: 14px 0;
}

.at-add {
    width: 100%;
    padding: 7px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: none;
    color: var(--primary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
}

.at-add:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: #FAFBFC;
}

.modal-btn {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.modal-btn-cancel {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text-secondary);
}

.modal-btn-cancel:hover {
    background: var(--hover);
    border-color: var(--border-hover);
}

.modal-btn-confirm {
    background: var(--primary);
    color: #FFFFFF;
}

.modal-btn-confirm:hover {
    background: var(--primary-hover);
}

/* Template Picker */
.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    background: var(--card-bg);
}

.template-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.15);
}

.template-card .template-icon {
    font-size: 28px;
    line-height: 1;
}

.template-card .template-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    text-align: center;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: #fff;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 2000;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px 16px;
    margin-top: 16px;
    color: var(--text-light);
    font-size: 13px;
}

.footer a {
    color: var(--text-light);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 16px 12px;
    }

    .header h1 {
        font-size: 20px;
    }

    .toolbar {
        padding: 10px 12px;
        gap: 6px;
    }

    .toolbar-btn {
        padding: 6px 10px;
    }

    .btn-text {
        display: none;
    }

    .btn-icon {
        font-size: 18px;
    }

    .toolbar-divider {
        margin: 0 2px;
    }

    .style-options {
        flex-wrap: wrap;
    }

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .sample-text,
    .copy-text {
        display: none;
    }
}
