/* ── Reset & Tokens ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #0a0f1e;
    --surface:      #111827;
    --surface-2:    #1f2937;
    --border:       #1f2937;
    --text:         #f9fafb;
    --text-muted:   #9ca3af;
    --primary:      #3b82f6;
    --green:        #10b981;
    --yellow:       #f59e0b;
    --gray:         #6b7280;
    --radius:       14px;
    --transition:   .18s ease;
}

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ── Header ── */
.site-header {
    background: rgba(17,24,39,.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-title {
    font-weight: 700;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.logo-icon { font-size: 1.3rem; }

.main-nav { display: flex; gap: .5rem; flex: 1; padding-left: 1.5rem; }

.nav-link {
    color: var(--text-muted);
    font-size: .875rem;
    padding: .3rem .65rem;
    border-radius: 6px;
    transition: color var(--transition), background var(--transition);
}
.nav-link:hover, .nav-link.active {
    color: var(--text);
    background: var(--surface-2);
}

.logout-link {
    color: var(--text-muted);
    font-size: .85rem;
    transition: color var(--transition);
}
.logout-link:hover { color: var(--text); }

/* ── Main ── */
.site-main {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    flex: 1;
}

/* ── Page intro ── */
.page-intro { margin-bottom: 2.5rem; }

.page-heading {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.page-sub {
    color: var(--text-muted);
    margin-top: .25rem;
    font-size: 1rem;
}

/* ── Sections ── */
.idea-section { margin-bottom: 3rem; }

.section-heading {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

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

/* ── Card ── */
.idea-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    position: relative;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.idea-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(59,130,246,.12);
}

.idea-icon { font-size: 2rem; line-height: 1; }

.idea-body { flex: 1; }

.idea-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: .2rem;
}

.idea-tagline {
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1.4;
}

.idea-desc {
    color: var(--text-muted);
    font-size: .85rem;
    margin-top: .4rem;
    line-height: 1.5;
}

/* ── Badge ── */
.idea-badge {
    font-size: .72rem;
    font-weight: 600;
    padding: .2rem .55rem;
    border-radius: 20px;
    align-self: flex-start;
    letter-spacing: .03em;
}

.status-active .idea-badge {
    background: rgba(16,185,129,.15);
    color: var(--green);
}

.status-exploration .idea-badge {
    background: rgba(59,130,246,.15);
    color: var(--primary);
}

.status-paused .idea-badge {
    background: rgba(245,158,11,.12);
    color: var(--yellow);
}

.status-archived .idea-badge {
    background: rgba(107,114,128,.15);
    color: var(--gray);
}

/* ── Status border accent ── */
.status-active { border-left: 3px solid var(--green); }
.status-exploration { border-left: 3px solid var(--primary); }
.status-paused { border-left: 3px solid var(--yellow); }
.status-archived { border-left: 3px solid var(--gray); }

/* ── Empty hint ── */
.empty-hint {
    color: var(--text-muted);
    padding: 3rem;
    text-align: center;
}
.empty-hint a { color: var(--primary); text-decoration: underline; }

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: .8rem;
    border-top: 1px solid var(--border);
}

/* ── Login page ── */
body.login {
    align-items: center;
    justify-content: center;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-logo { font-size: 2.5rem; margin-bottom: .5rem; }

.login-card h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: .25rem; }

.login-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 2rem; }

.login-card input[type="password"] {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid #374151;
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    padding: .75rem 1rem;
    outline: none;
    margin-bottom: .75rem;
    transition: border-color .15s;
}
.login-card input[type="password"]:focus { border-color: var(--primary); }

.login-card button {
    width: 100%;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    padding: .75rem;
    transition: background .15s;
}
.login-card button:hover { background: #2563eb; }

.login-error { color: #f87171; font-size: .85rem; margin-top: .75rem; }

/* ── Notebook ── */
.notebook-layout {
    display: flex;
    height: calc(100dvh - 56px);
    overflow: hidden;
}

.notebook-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: .85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.btn-new {
    background: var(--primary);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    padding: .25rem .65rem;
    transition: background var(--transition);
}
.btn-new:hover { background: #2563eb; }

.note-list {
    flex: 1;
    overflow-y: auto;
    padding: .4rem 0;
}

.note-item {
    padding: .7rem 1rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}
.note-item:hover { background: var(--surface-2); }
.note-item.active {
    background: var(--surface-2);
    border-left-color: var(--primary);
}

.note-item-title {
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-item-date {
    font-size: .72rem;
    color: var(--text-muted);
    margin-top: .1rem;
}

/* ── Note content ── */
.notebook-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* The hidden attribute must always win, even over display:flex below. */
[hidden] { display: none !important; }

/* Panels must fill the content area so .note-main can scroll inside them.
   :not([hidden]) so we don't override the hidden attribute. */
#panel-view:not([hidden]),
#panel-edit:not([hidden]) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.note-toolbar {
    padding: .65rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: .5rem;
    align-items: center;
    min-height: 48px;
}

.btn-toolbar {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    font-size: .82rem;
    padding: .35rem .75rem;
    transition: background var(--transition);
}
.btn-toolbar:hover { background: #374151; }
.btn-toolbar.primary { background: var(--primary); border-color: var(--primary); }
.btn-toolbar.primary:hover { background: #2563eb; }
.btn-toolbar.danger { color: #f87171; }
.btn-toolbar.danger:hover { background: rgba(248,113,113,.08); }

.note-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}
/* Title + body share one centered, comfortably wide column */
.note-title-display,
.note-body-display,
.note-title-input,
.note-body-input {
    width: 100%;
    max-width: 72rem;
}

.note-title-display {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -.025em;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.note-body-display {
    line-height: 1.7;
    font-size: .95rem;
    color: var(--text);
    flex: 1;
}

/* ── Rendered markdown ── */
.note-body-display > *:first-child { margin-top: 0; }
.note-body-display h1,
.note-body-display h2,
.note-body-display h3,
.note-body-display h4 {
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -.01em;
    margin: 2rem 0 .75rem;
}
.note-body-display h1 { font-size: 1.5rem; }
.note-body-display h2 {
    font-size: 1.25rem;
    padding-bottom: .3rem;
    border-bottom: 1px solid var(--border);
}
.note-body-display h3 { font-size: 1.08rem; }
.note-body-display h4 { font-size: .95rem; color: var(--text-muted); }
.note-body-display p { margin: .75rem 0; }
.note-body-display ul,
.note-body-display ol { margin: .75rem 0; padding-left: 1.4rem; }
.note-body-display li { margin: .3rem 0; }
.note-body-display li > ul,
.note-body-display li > ol { margin: .3rem 0; }
.note-body-display a { color: var(--primary); text-decoration: none; }
.note-body-display a:hover { text-decoration: underline; }
.note-body-display strong { font-weight: 700; color: #fff; }
.note-body-display hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.75rem 0;
}
.note-body-display blockquote {
    margin: 1rem 0;
    padding: .4rem 0 .4rem 1rem;
    border-left: 3px solid var(--primary);
    color: var(--text-muted);
}
.note-body-display code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85em;
    background: var(--surface-2);
    padding: .12em .4em;
    border-radius: 4px;
}
.note-body-display pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}
.note-body-display pre code { background: none; padding: 0; font-size: .85rem; }
.note-body-display table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.25rem 0;
    font-size: .9rem;
}
.note-body-display th,
.note-body-display td {
    border: 1px solid var(--border);
    padding: .5rem .75rem;
    text-align: left;
    vertical-align: top;
}
.note-body-display th {
    background: var(--surface-2);
    font-weight: 600;
}
.note-body-display tbody tr:nth-child(even) { background: rgba(255,255,255,.02); }

.note-title-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--primary);
    color: var(--text);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -.025em;
    margin-bottom: 1.5rem;
    outline: none;
    padding: .2rem 0 .4rem;
    line-height: 1.2;
}

.note-body-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: .95rem;
    line-height: 1.85;
    flex: 1;
    min-height: 50vh;
    outline: none;
    resize: none;
    font-family: inherit;
}

.note-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: .95rem;
}

.sidebar-empty {
    padding: 1rem;
    color: var(--text-muted);
    font-size: .82rem;
}
