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

:root {
    --bg:        #0d0d0f;
    --surface:   #141416;
    --surface2:  #1c1c1f;
    --surface3:  #242428;
    --border:    #2a2a2e;
    --border2:   #333338;
    --text:      #e8e8ed;
    --text2:     #8e8e99;
    --text3:     #55555f;
    --accent:    #7c6af7;
    --accent2:   #9d8fff;
    --danger:    #e05252;
    --success:   #52c47a;
    --reminder:  #f0a04b;
    --radius:    10px;
    --radius-lg: 16px;
}

body {
    font-family: 'DM Mono', monospace;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden { display: none !important; }

/* ── NOISE OVERLAY ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 9999;
    opacity: 0.4;
}

/* ── AUTH ── */
#auth-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(124,106,247,0.08);
}

.auth-logo {
    font-family: 'Syne', sans-serif;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.auth-logo span { color: var(--accent); }

.auth-sub {
    font-size: 11px;
    color: var(--text3);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 32px;
}

.auth-tabs {
    display: flex;
    background: var(--surface2);
    border-radius: var(--radius);
    padding: 3px;
    margin-bottom: 28px;
}

.auth-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text2);
    font-family: 'DM Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s;
}

.auth-tab.active {
    background: var(--surface3);
    color: var(--text);
}

.auth-message {
    font-size: 12px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    display: none;
}

.auth-message.error  { background: rgba(224,82,82,0.1);  color: var(--danger);  display: block; }
.auth-message.success { background: rgba(82,196,122,0.1); color: var(--success); display: block; }

/* ── FORM ELEMENTS ── */
.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text3);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }

.btn {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: var(--radius);
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 8px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
}

.btn-ghost:hover { border-color: var(--border2); color: var(--text); }

/* ── APP SCREEN ── */
#app-screen {
    display: none;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

#app-screen.visible { display: flex; }

/* ── TOPBAR ── */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
}

.topbar-left  { display: flex; align-items: center; gap: 8px; }
.topbar-center { display: flex; align-items: center; justify-content: center; gap: 6px; }
.topbar-right { display: flex; align-items: center; justify-content: flex-end; }

.icon-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    background: var(--surface2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text2);
    transition: all 0.15s;
    flex-shrink: 0;
}

.icon-btn:hover { border-color: var(--border2); color: var(--text); background: var(--surface3); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-btn:disabled:hover { border-color: var(--border); color: var(--text2); background: var(--surface2); }

.breadcrumb {
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    transition: all 0.15s;
}

.user-btn:hover { transform: scale(1.05); }

/* ── CONTENT PANEL ── */
.content-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    max-height: 45vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-filename {
    flex: 1;
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-save-btn {
    padding: 6px 14px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: 'DM Mono', monospace;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.editor-save-btn:hover { background: var(--accent2); }
.editor-save-btn.saved { background: rgba(82,196,122,0.15); color: var(--success); }
.editor-save-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.editor-textarea {
    flex: 1;
    background: var(--bg);
    border: none;
    padding: 16px;
    color: var(--text);
    font-family: 'DM Mono', monospace;
    font-size: 13px;
    line-height: 1.8;
    resize: none;
    outline: none;
    overflow-y: auto;
}

.editor-meta {
    padding: 6px 16px;
    font-size: 10px;
    color: var(--text3);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 16px;
    flex-shrink: 0;
}

/* ── REMINDER FORM ── */
.reminder-form-body {
    overflow-y: auto;
    padding: 12px 16px;
    flex: 1;
}

.reminder-form-body::-webkit-scrollbar { width: 3px; }
.reminder-form-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.reminder-row { margin-bottom: 14px; }

.reminder-detail-label {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text3);
    margin-bottom: 6px;
}

.reminder-status-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-chip {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    color: var(--text2);
    transition: all 0.15s;
    background: var(--surface2);
}

.status-chip:hover { border-color: var(--border2); color: var(--text); }
.status-chip.selected { border-color: var(--accent); color: var(--accent2); background: rgba(124,106,247,0.08); }

.reminder-detail-input {
    width: 100%;
    font-size: 12px;
    color: var(--text);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: 'DM Mono', monospace;
    outline: none;
    transition: border-color 0.15s;
}

.reminder-detail-input:focus { border-color: var(--accent); }

.reminder-detail-textarea {
    width: 100%;
    font-size: 12px;
    color: var(--text);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: 'DM Mono', monospace;
    outline: none;
    resize: none;
    min-height: 60px;
    transition: border-color 0.15s;
}

.reminder-detail-textarea:focus { border-color: var(--accent); }

.context-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.context-chip {
    padding: 4px 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 11px;
    color: var(--text2);
    cursor: pointer;
    transition: all 0.15s;
}

.context-chip:hover { border-color: var(--accent); color: var(--accent2); }
.context-chip.selected { border-color: var(--accent); background: rgba(124,106,247,0.1); color: var(--accent2); }

.context-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.context-add-row .form-input {
    flex: 1;
    font-size: 12px;
    padding: 7px 12px;
}

.context-add-row .btn {
    width: auto;
    padding: 7px 12px;
    margin-top: 0;
    font-size: 11px;
    white-space: nowrap;
}

/* ── PANEL DIVIDER ── */
.panel-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.divider-line { flex: 1; height: 1px; background: var(--border); }

.divider-label {
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text3);
    white-space: nowrap;
}

/* ── FILE LIST ── */
.file-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 14px 20px 80px;
}

.file-list-container::-webkit-scrollbar { width: 4px; }
.file-list-container::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 160px;
    color: var(--text3);
    gap: 8px;
}

.empty-icon { font-size: 28px; opacity: 0.4; }
.empty-text { font-size: 12px; letter-spacing: 0.05em; }

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
    animation: slideIn 0.15s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.file-item:hover { border-color: var(--border2); background: var(--surface2); }
.file-item.active { border-color: var(--accent); background: rgba(124,106,247,0.06); }

.file-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.file-icon.text     { background: rgba(124,106,247,0.12); }
.file-icon.reminder { background: rgba(240,160,75,0.12); }

.file-info { flex: 1; min-width: 0; }

.file-name {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 10px;
    color: var(--text3);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-type-badge {
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
}

.file-type-badge.text     { background: rgba(124,106,247,0.12); color: var(--accent2); }
.file-type-badge.reminder { background: rgba(240,160,75,0.12);  color: var(--reminder); }

.file-chevron { color: var(--text3); font-size: 12px; flex-shrink: 0; }

.delete-btn {
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text3);
    font-size: 12px;
    transition: all 0.15s;
    flex-shrink: 0;
    opacity: 0;
}

.file-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--danger); border-color: rgba(224,82,82,0.3); background: rgba(224,82,82,0.08); }

/* ── FAB ── */
.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(124,106,247,0.4);
    transition: all 0.2s;
    z-index: 100;
}

.fab:hover { transform: scale(1.08) rotate(90deg); box-shadow: 0 12px 32px rgba(124,106,247,0.5); }

/* ── MODALS ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 24px 24px 36px;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-handle {
    width: 36px;
    height: 3px;
    background: var(--border2);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.modal-title {
    font-family: 'Syne', sans-serif;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 18px;
}

.type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.type-option {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.type-option:hover { border-color: var(--border2); }
.type-option.selected { border-color: var(--accent); background: rgba(124,106,247,0.08); }
.type-option-icon { font-size: 20px; margin-bottom: 6px; }

.type-option-label {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text2);
}

.type-option.selected .type-option-label { color: var(--accent2); }

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.modal-actions .btn { margin-top: 0; flex: 1; }

/* ── CONFIRM DIALOG ── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    padding: 24px;
}

.confirm-overlay.open { opacity: 1; pointer-events: all; }

.confirm-dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 100%;
    max-width: 320px;
    transform: scale(0.95);
    transition: transform 0.15s;
}

.confirm-overlay.open .confirm-dialog { transform: scale(1); }

.confirm-title {
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
}

.confirm-message {
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 20px;
    line-height: 1.6;
}

.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { margin-top: 0; flex: 1; }
.btn-confirm-delete { background: var(--danger); color: #fff; border: none; }
.btn-confirm-delete:hover { background: #c94444; transform: none; }

/* ── PROFILE PANEL ── */
.profile-overlay {
    position: fixed;
    inset: 0;
    z-index: 299;
    display: none;
}

.profile-overlay.open { display: block; }

.profile-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--border);
    z-index: 300;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.profile-panel.open { transform: translateX(0); }

.profile-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Syne', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.profile-name {
    font-family: 'Syne', sans-serif;
    font-size: 15px;
    font-weight: 700;
}

.profile-email { font-size: 11px; color: var(--text3); margin-top: 2px; }
.profile-divider { height: 1px; background: var(--border); }
.profile-actions { margin-top: auto; }

/* ── LOADING / TOAST ── */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text3);
    font-size: 12px;
    gap: 10px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface3);
    border: 1px solid var(--border2);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    color: var(--text);
    z-index: 500;
    opacity: 0;
    transition: all 0.2s;
    white-space: nowrap;
    pointer-events: none;
}

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