:root {
    --bg-base: #faf9f6;
    --surface: #ffffff;
    --surface-hover: #f3f2ee;
    --text-main: #1c1b18;
    --text-muted: #6e6c65;
    --border: rgba(28, 27, 24, 0.12);
    --accent: #1c1b18;
    --accent-text: #faf9f6;
    --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04);
    --radius: 12px;
    --font-editorial: 'Playfair Display', Georgia, serif;
    --font-note: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    --tint-emerald-bg: #ecfdf5;
    --tint-emerald-border: #6ee7b7;
    --tint-sapphire-bg: #eff6ff;
    --tint-sapphire-border: #93c5fd;
    --tint-sunset-bg: #fff7ed;
    --tint-sunset-border: #fdba74;
    --tint-amethyst-bg: #faf5ff;
    --tint-amethyst-border: #d8b4fe;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-base: #111110;
        --surface: #1a1a18;
        --surface-hover: #242421;
        --text-main: #f2f1ed;
        --text-muted: #9c9a92;
        --border: rgba(242, 241, 237, 0.12);
        --accent: #f2f1ed;
        --accent-text: #111110;
        --shadow: 0 6px 24px -2px rgba(0, 0, 0, 0.35);

        --tint-emerald-bg: #11241d;
        --tint-emerald-border: #065f46;
        --tint-sapphire-bg: #131d2e;
        --tint-sapphire-border: #1e40af;
        --tint-sunset-bg: #291911;
        --tint-sunset-border: #9a3412;
        --tint-amethyst-bg: #21152b;
        --tint-amethyst-border: #6b21a8;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-editorial);
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 64px;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.hidden {
    display: none !important;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 36px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-family: var(--font-editorial);
    font-weight: 700;
    font-size: 1.55rem;
    letter-spacing: -0.03em;
    color: var(--text-main);
    text-decoration: none;
    flex-shrink: 0;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 99px;
    width: 100%;
    max-width: 380px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    border-color: var(--text-muted);
    box-shadow: var(--shadow);
}

.search-box input {
    border: none;
    background: transparent;
    width: 100%;
    color: var(--text-main);
    font-family: var(--font-editorial);
    font-size: 0.92rem;
    outline: none;
}

.app-container {
    max-width: 680px;
    margin: 36px auto 0;
    padding: 0 16px;
}

.composer-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
    margin-bottom: 36px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.composer-card input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-family: var(--font-note);
    font-weight: 600;
    font-size: 1.05rem;
    margin-bottom: 8px;
    outline: none;
}

.editable-area {
    width: 100%;
    min-height: 24px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-family: var(--font-note);
    font-size: 0.95rem;
    line-height: 1.5;
    outline: none;
    word-break: break-word;
    overflow-wrap: break-word;
}

.editable-area:empty:before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    opacity: 0.7;
    pointer-events: none;
    display: block;
}

.modal-editable {
    min-height: 120px;
}

.composer-footer,
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.color-picker {
    display: flex;
    align-items: center;
    gap: 7px;
}

.c-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s;
}

.c-dot:hover {
    transform: scale(1.18);
}

.c-dot.active {
    border-color: var(--text-main);
    transform: scale(1.1);
}

.c-dot[data-color="default"] {
    background: var(--surface);
    box-shadow: inset 0 0 0 1px var(--border);
}

.c-dot[data-color="emerald"] {
    background: #10b981;
}

.c-dot[data-color="sapphire"] {
    background: #3b82f6;
}

.c-dot[data-color="sunset"] {
    background: #f97316;
}

.c-dot[data-color="amethyst"] {
    background: #a855f7;
}

.format-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.fmt-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-note);
    font-size: 0.82rem;
    font-weight: 600;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.fmt-btn:hover {
    background: var(--surface-hover);
    color: var(--text-main);
}

.composer-card.theme-emerald,
.modal-box.theme-emerald,
.note-item.theme-emerald {
    background-color: var(--tint-emerald-bg);
    border-color: var(--tint-emerald-border);
}

.composer-card.theme-sapphire,
.modal-box.theme-sapphire,
.note-item.theme-sapphire {
    background-color: var(--tint-sapphire-bg);
    border-color: var(--tint-sapphire-border);
}

.composer-card.theme-sunset,
.modal-box.theme-sunset,
.note-item.theme-sunset {
    background-color: var(--tint-sunset-bg);
    border-color: var(--tint-sunset-border);
}

.composer-card.theme-amethyst,
.modal-box.theme-amethyst,
.note-item.theme-amethyst {
    background-color: var(--tint-amethyst-bg);
    border-color: var(--tint-amethyst-border);
}

.submit-btn {
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    padding: 7px 18px;
    border-radius: 8px;
    font-family: var(--font-editorial);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.submit-btn:hover {
    opacity: 0.85;
}

.feed-section {
    margin-bottom: 32px;
}

.section-heading {
    font-family: var(--font-editorial);
    font-size: 0.95rem;
    font-weight: 500;
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 4px;
}

.notes-feed {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.note-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    box-shadow: var(--shadow);
    cursor: grab;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s, background-color 0.2s;
    word-break: break-word;
}

.note-item:hover {
    transform: translateY(-2px);
}

.note-item.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.note-item h3 {
    font-family: var(--font-note);
    font-size: 1.02rem;
    font-weight: 600;
    margin-bottom: 6px;
    padding-right: 96px;
}

.note-body {
    font-family: var(--font-note);
    font-size: 0.93rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.note-body b, .note-body strong {
    color: var(--text-main);
    font-weight: 700;
}

.note-body i, .note-body em {
    font-style: italic;
}

.note-body s, .note-body strike {
    text-decoration: line-through;
    opacity: 0.7;
}

.note-body ul {
    margin-left: 20px;
}

.note-actions {
    position: absolute;
    top: 16px;
    right: 18px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

.note-item:hover .note-actions {
    opacity: 1;
}

.action-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: var(--font-editorial);
    font-size: 0.78rem;
    cursor: pointer;
    color: var(--text-main);
    transition: background 0.15s;
}

.action-btn:hover {
    background: var(--surface-hover);
}

.action-btn.pinned {
    background: var(--accent);
    color: var(--accent-text);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 520px;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.modal-box input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-family: var(--font-note);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    outline: none;
}

@media (max-width: 600px) {
    .app-header {
        padding: 14px 16px;
    }

    .brand {
        font-size: 1.3rem;
    }

    .note-actions {
        opacity: 1;
    }
}
