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

:root {
    --ink: #1a1a1a;
    --paper: #f8f6f1;
    --paper-light: #fffef9;
    --accent: #c45d35;
    --accent-hover: #a84d2a;
    --muted: #8a8580;
    --border: #e5e2db;
    --code-bg: #2d2a26;
    --code-text: #e8e6e1;
    --shadow: rgba(26, 26, 26, 0.08);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Literata', Georgia, serif;
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--paper-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--ink);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--paper);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    font-size: 0.9rem;
}

.logo-text {
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
}

.actions {
    display: flex;
    gap: 0.75rem;
}

.btn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.btn-secondary {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(196, 93, 53, 0.3);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Main Layout */
main {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex: 1;
    min-height: 0;
}

/* Editor Panel */
.editor-panel {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
}

.panel-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--paper-light);
}

.panel-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.char-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--muted);
}

.editor-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#editor {
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    border: none;
    resize: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.8;
    background: var(--paper-light);
    color: var(--ink);
    outline: none;
}

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

/* Drop Zone */
.drop-zone {
    position: absolute;
    inset: 0;
    background: rgba(248, 246, 241, 0.97);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    border: 3px dashed var(--border);
    margin: 1rem;
    border-radius: 12px;
}

.drop-zone.active {
    opacity: 1;
    visibility: visible;
    border-color: var(--accent);
    background: rgba(196, 93, 53, 0.05);
}

.drop-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    animation: pulse 2s infinite;
}

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

.drop-text {
    font-size: 1.1rem;
    color: var(--ink);
}

.drop-hint {
    font-size: 0.85rem;
    color: var(--muted);
}

/* Preview Panel */
.preview-panel {
    display: flex;
    flex-direction: column;
    background: var(--paper-light);
}

.preview-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
}

/* Markdown Styles */
#preview {
    max-width: 720px;
    margin: 0 auto;
}

#preview h1 {
    font-size: 2.2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.75rem;
}

#preview h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
    color: var(--accent);
}

#preview h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

#preview h4, #preview h5, #preview h6 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

#preview p {
    margin-bottom: 1.25rem;
}

#preview a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color var(--transition);
}

#preview a:hover {
    color: var(--accent-hover);
}

#preview strong {
    font-weight: 600;
}

#preview em {
    font-style: italic;
}

#preview ul, #preview ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

#preview li {
    margin-bottom: 0.4rem;
}

#preview li::marker {
    color: var(--accent);
}

#preview blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: var(--muted);
}

#preview code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

#preview pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

#preview pre code {
    background: none;
    padding: 0;
    font-size: 0.85rem;
    line-height: 1.6;
}

#preview hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 2.5rem 0;
}

#preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

#preview th, #preview td {
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    text-align: left;
}

#preview th {
    background: var(--paper);
    font-weight: 600;
}

#preview img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--muted);
    text-align: center;
    padding: 2rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.empty-state-hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

/* File Input */
.file-input {
    display: none;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--ink);
    color: var(--paper);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    opacity: 0;
    transition: all 300ms ease;
    z-index: 1000;
}

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

/* Footer */
footer {
    background: var(--ink);
    color: var(--paper);
    padding: 3rem 2rem 1.5rem;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 3rem;
}

.footer-column {
    display: flex;
    flex-direction: column;
}

.footer-brand {
    font-family: 'Literata', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.footer-author {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--muted);
}

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

.footer-author a:hover {
    color: var(--accent);
}

.footer-copyright {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 1rem;
}

.footer-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 1rem;
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.footer-links a {
    color: var(--paper);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .editor-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    header {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .actions {
        width: 100%;
        justify-content: flex-end;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }

    .footer-column {
        align-items: center;
    }
}

@media (max-width: 600px) {
    header {
        padding: 1rem;
    }

    .preview-wrapper {
        padding: 1.5rem;
    }

    .btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }

    .btn span:not(.icon) {
        display: none;
    }
}

/* PDF Export Styles (hidden, used for rendering) */
.pdf-export {
    font-family: Georgia, serif;
    padding: 40px;
    max-width: 800px;
    line-height: 1.6;
}
