:root {
    --green: #2ecc71;
    --green-dark: #21a85a;
    --ink: #111827;
    --text: #243041;
    --muted: #64748b;
    --bg: #f4f7f6;
    --panel: #ffffff;
    --line: #dbe3e0;
    --soft: #edf4f0;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, Arial, sans-serif;
}

a {
    color: inherit;
}

.topbar {
    min-height: 68px;
    padding: 0 28px;
    background: #0f172a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 4px solid var(--green);
}

.logo {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 18px;
    font-weight: 900;
    text-decoration: none;
}

.logo span,
.auth-logo {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--green);
    color: #07120b;
    display: inline-grid;
    place-items: center;
    font-weight: 950;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar nav a {
    color: #dbe3ea;
    text-decoration: none;
    font-weight: 800;
    border-radius: 10px;
    padding: 9px 12px;
}

.topbar nav a:hover,
.topbar nav a.active {
    background: var(--green);
    color: #07120b;
}

.container {
    width: min(1240px, calc(100% - 36px));
    margin: 24px auto 50px;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
    gap: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #effaf4 100%);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--green-dark);
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
}

.hero h1,
.library-head h1 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(32px, 5vw, 54px);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.hero-sub,
.library-head p {
    color: var(--muted);
    font-size: 17px;
    margin: 14px 0 0;
}

.hero-search {
    margin-top: 24px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.hero-search input,
.filter-form input,
.filter-form select,
.stack-form input,
.manual-config {
    width: 100%;
    border: 1px solid var(--line);
    background: #ffffff;
    border-radius: 12px;
    padding: 13px 14px;
    font-size: 15px;
    font-family: inherit;
}

.hero-search input:focus,
.filter-form input:focus,
.filter-form select:focus,
.stack-form input:focus {
    outline: 3px solid rgba(46, 204, 113, 0.18);
    border-color: var(--green);
}

button,
.primary-btn,
.secondary-btn,
.pager a {
    border: 0;
    border-radius: 12px;
    padding: 12px 15px;
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-family: inherit;
}

button,
.primary-btn {
    background: var(--green);
    color: #07120b;
}

button:hover,
.primary-btn:hover {
    background: var(--green-dark);
}

.secondary-btn,
.pager a {
    background: #e8eeeb;
    color: var(--ink);
}

.secondary-btn:hover,
.pager a:hover {
    background: #d8e3de;
}

.hero-stats {
    display: grid;
    gap: 10px;
}

.hero-stats div,
.stat-card,
.goal-card,
.hint-panel,
.library-head,
.filter-sidebar,
.result-panel,
.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
}

.hero-stats div {
    padding: 16px;
}

.hero-stats strong {
    display: block;
    color: var(--ink);
    font-size: 28px;
    letter-spacing: -0.03em;
}

.hero-stats span {
    display: block;
    color: var(--muted);
    margin-top: 4px;
    font-weight: 700;
}

.goal-grid {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.goal-card {
    padding: 20px;
}

.goal-card h2 {
    margin: 0 0 14px;
    color: var(--ink);
    font-size: 21px;
}

.goal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.goal-links a,
.quick-chips a {
    display: inline-flex;
    text-decoration: none;
    border: 1px solid var(--line);
    background: var(--soft);
    border-radius: 999px;
    padding: 9px 12px;
    font-weight: 850;
    color: #253143;
    font-size: 14px;
}

.goal-links a:hover,
.quick-chips a:hover {
    background: var(--green);
    border-color: var(--green);
    color: #07120b;
}

.hint-panel {
    margin-top: 16px;
    padding: 20px;
}

.hint-panel h2 {
    margin: 0 0 8px;
}

.hint-panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.library-head {
    padding: 22px;
    margin-bottom: 16px;
}

.library-head h1 {
    font-size: clamp(28px, 4vw, 44px);
}

.library-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.filter-sidebar {
    padding: 18px;
    position: sticky;
    top: 18px;
}

.filter-form {
    display: grid;
    gap: 13px;
}

.filter-form label,
.stack-form label {
    display: grid;
    gap: 6px;
    font-weight: 850;
    color: #334155;
    font-size: 13px;
}

.quick-chips {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.quick-chips h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.quick-chips a {
    margin: 0 6px 8px 0;
}

.result-panel {
    padding: 0;
    overflow: hidden;
}

.result-toolbar {
    background: #f8faf9;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    color: var(--muted);
    font-weight: 800;
}

.pager {
    display: flex;
    gap: 8px;
}

.results-list {
    display: grid;
}

.result-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 96px;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.result-item:hover {
    background: #fbfdfc;
}

.result-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.result-title-row h2 {
    margin: 0;
    color: var(--ink);
    font-size: 17px;
    line-height: 1.28;
}

.score {
    white-space: nowrap;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 950;
    background: #e5e7eb;
    color: var(--ink);
}

.score-5 {
    background: var(--green);
}

.score-4 {
    background: #bbf7d0;
}

.score-3 {
    background: #dbeafe;
}

.score-2 {
    background: #fef3c7;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 9px 0;
}

.result-meta span {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 800;
}

.result-content p {
    margin: 0;
    color: #465466;
    line-height: 1.48;
}

.result-actions {
    display: grid;
    gap: 8px;
    align-content: start;
}

.hidden-prompt {
    display: none;
}

.bottom-pager {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 16px;
}

.empty-box {
    padding: 30px;
    text-align: center;
}

.notice {
    padding: 14px 16px;
    border-radius: 12px;
    margin: 14px 0;
    font-weight: 750;
}

.notice.error {
    background: #fee2e2;
    color: #991b1b;
}

.notice.success {
    background: #dcfce7;
    color: #166534;
}

.copy-toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    background: #0f172a;
    color: white;
    padding: 11px 15px;
    border-radius: 999px;
    font-weight: 900;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: 0.2s ease;
    z-index: 50;
}

.copy-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.62);
    display: none;
    padding: 24px;
    z-index: 40;
}

.modal.show {
    display: grid;
    place-items: center;
}

.modal-card {
    width: min(860px, 100%);
    max-height: 90vh;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 {
    margin: 0;
    font-size: 18px;
}

.modal-card textarea {
    width: 100%;
    min-height: 360px;
    border: 0;
    resize: vertical;
    padding: 18px;
    font-size: 15px;
    font-family: Arial, sans-serif;
    line-height: 1.55;
}

.modal-actions {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    background: #f8faf9;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at top left, rgba(46, 204, 113, 0.20), transparent 34%),
        #f4f7f6;
}

.auth-card {
    width: min(420px, 100%);
    padding: 26px;
}

.auth-card.wide {
    width: min(680px, 100%);
}

.auth-logo {
    margin-bottom: 14px;
}

.auth-card h1 {
    margin: 0 0 6px;
    color: var(--ink);
}

.auth-card p {
    margin: 0 0 16px;
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 13px;
}

.path-code {
    display: block;
    background: #f3f4f6;
    border: 1px solid #d9dee7;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.manual-config {
    font-family: monospace;
    margin-bottom: 14px;
}

@media (max-width: 900px) {
    .topbar {
        display: block;
        padding: 14px 18px;
    }

    .topbar nav {
        margin-top: 12px;
    }

    .container {
        width: min(100% - 24px, 1240px);
        margin-top: 14px;
    }

    .hero,
    .goal-grid,
    .library-shell {
        grid-template-columns: 1fr;
    }

    .filter-sidebar {
        position: relative;
        top: auto;
    }

    .hero-search,
    .result-item {
        grid-template-columns: 1fr;
    }

    .result-actions {
        display: flex;
        flex-wrap: wrap;
    }

    .result-toolbar {
        display: block;
    }

    .pager {
        margin-top: 10px;
    }
}
