:root {
    /* Monochrome Palette */
    --bg-dark: #09090b; /* Zinc 950 */
    --bg-card: #18181b; /* Zinc 900 */
    --bg-hover: #27272a; /* Zinc 800 */
    --border: #27272a; /* Zinc 800 */
    --border-hover: #3f3f46; /* Zinc 700 */

    --text-primary: #fafafa; /* Zinc 50 */
    --text-secondary: #a1a1aa; /* Zinc 400 */
    --text-muted: #71717a; /* Zinc 500 */

    --accent: #ffffff;
    --accent-hover: #e4e4e7; /* Zinc 200 */
    --accent-text: #000000;

    /* Typography */
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Utilities */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(255, 255, 255, 0.05);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(50px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.view {
    display: none;
    min-height: 100vh;
    animation: fadeIn var(--transition) forwards;
}

.view.active {
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* ===== BUTTONS & INPUTS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn i {
    font-size: 1.1rem;
}

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

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--accent);
    background-color: rgba(255,255,255,0.03);
}

.btn-ghost {
    background-color: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--text-primary);
    background-color: var(--bg-hover);
}

.hidden-input {
    display: none;
}

input[type="text"] {
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition);
    font-family: var(--font-body);
}

input[type="text"]:focus {
    border-color: var(--accent);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* ===== LOGIN VIEW ===== */
#login-view {
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, var(--bg-card) 0%, var(--bg-dark) 100%);
}

.login-card {
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.login-header i {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 15px;
    display: inline-block;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

.input-group input {
    padding-left: 40px;
}

#login-form .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

/* ===== DASHBOARD VIEW ===== */
.app-header {
    padding: 20px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(9, 9, 11, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

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

.brand-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.dashboard-content {
    padding: 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

/* Empty State */
#empty-state {
    text-align: center;
    margin-top: 100px;
    color: var(--text-muted);
    animation: fadeIn var(--transition) forwards;
}

#empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--border-hover);
}

#empty-state p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#empty-state span {
    font-size: 0.9rem;
}

#empty-state.hidden {
    display: none;
}

/* Notes Grid */
.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.note-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    height: 160px;
    display: flex;
    flex-direction: column;
}

.note-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--text-muted), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.note-card:hover::before {
    opacity: 1;
}

.note-card h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex: 1;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

.note-card .note-meta {
    margin-top: 15px;
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* FAB */
.fab {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background-color: var(--accent);
    color: var(--accent-text);
    border: none;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.2);
}

/* ===== EDITOR VIEW ===== */
#editor-view {
    height: 100vh;
    background-color: var(--bg-dark);
}

.editor-header {
    border-bottom: 1px solid var(--border);
    padding: 15px 40px;
}

.note-title-wrapper {
    margin-left: 20px;
    padding-left: 20px;
    border-left: 1px solid var(--border);
    flex: 1;
}

#note-title {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 1.1rem;
    font-weight: 500;
    width: 300px;
}

#note-title:focus {
    border: none;
    box-shadow: none;
}

.view-toggle {
    display: flex;
    gap: 4px;
    background-color: var(--bg-dark);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.view-toggle .btn {
    padding: 6px 12px;
}

.view-toggle .btn.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.header-right {
    display: flex;
    gap: 12px;
}

/* Editor Main */
.editor-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    height: calc(100vh - 71px);
}

#markdown-textarea {
    flex: 1;
    width: 100%;
    background-color: transparent;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 40px;
    border: none;
    resize: none;
    outline: none;
}

#markdown-textarea::placeholder {
    color: var(--text-muted);
    font-family: var(--font-body);
}

.html-preview {
    flex: 1;
    width: 100%;
    padding: 40px;
    overflow-y: auto;
    color: var(--text-primary);
    line-height: 1.6;
}

.html-preview.hidden {
    display: none;
}

/* Basic HTML render for markdown */
.html-preview h1, .html-preview h2, .html-preview h3, .html-preview h4 { margin-top: 1.5em; margin-bottom: 0.5em; }
.html-preview h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.html-preview p { margin-bottom: 1em; }
.html-preview a { color: #60a5fa; text-decoration: none; }
.html-preview a:hover { text-decoration: underline; }
.html-preview ul, .html-preview ol { margin-bottom: 1em; padding-left: 2em; }
.html-preview blockquote { border-left: 4px solid var(--border-hover); padding-left: 1em; color: var(--text-secondary); margin-bottom: 1em; }
.html-preview code { font-family: var(--font-mono); background: var(--bg-card); padding: 0.2em 0.4em; border-radius: 4px; font-size: 0.9em; }
.html-preview img { max-width: 100%; border-radius: var(--radius-sm); margin-bottom: 1em; }

/* ===== TOAST NOTIFICATION ===== */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    animation: slideUp var(--transition) forwards;
}

.toast.removing {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all var(--transition);
}

.toast i {
    color: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .editor-header {
        flex-direction: column;
        gap: 15px;
    }

    .header-left, .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .note-title-wrapper {
        margin-left: 10px;
        padding-left: 10px;
        width: 100%;
    }

    #note-title {
        width: 100%;
    }

    .dashboard-content {
        padding: 20px;
    }

    .fab {
        bottom: 20px;
        right: 20px;
    }

    #markdown-textarea {
        padding: 20px;
    }
}
.note-preview {
    color: var(--text-secondary);
    font-size: 0.9rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.note-preview h1,
.note-preview h2,
.note-preview h3 {
    font-size: 1rem;
    margin: 0;
}

.note-preview p {
    margin: 0;
}

.note-preview ul {
    padding-left: 16px;
    margin: 0;
}
