:root {
    --green: #215732;
    --green-mid: #4d8f5c;
    --green-light: #eef5f0;
    --bg: #f4f5f4;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #5a6460;
    --border: #d6ded8;
    --input-border: #808c86;
    --open: #166534;
    --open-bg: #dcfce7;
    --closed: #b91c1c;
    --closed-bg: #fee2e2;
    --radius: 4px;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    z-index: 200;
    padding: 8px 16px;
    background: var(--green);
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    text-decoration: none;
}
.skip-link:focus {
    position: fixed;
    top: 8px;
    left: 8px;
    width: auto;
    height: auto;
}

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

button, input { font-family: inherit; font-size: inherit; }
a { text-decoration: none; color: inherit; }

.htmx-indicator { display: none !important; }

/* =================================
   NAV
   ================================= */
.topnav-wrap {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 8px 24px;
}

.topnav {
    max-width: 1100px;
    margin: 0 auto;
    background: var(--green);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 14px;
    height: 44px;
    border-radius: var(--radius);
    gap: 14px;
    font-size: 14px;
}

.brand {
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    gap: 1px;
    flex: 1;
}
.nav-links a {
    color: rgba(255,255,255,0.6);
    padding: 3px 9px;
    border-radius: 3px;
    font-size: 13px;
    transition: background 0.12s, color 0.12s;
}
.nav-links a:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-links a.active { background: rgba(255,255,255,0.15); color: white; }

.nav-spacer { flex: 1; }
.nav-auth {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.nav-link {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    padding: 3px 9px;
    border-radius: 3px;
    transition: background 0.12s, color 0.12s;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: rgba(255,255,255,0.15); color: white; }
.nav-alerts {
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    padding: 3px 9px;
    border-radius: 3px;
    transition: background 0.12s, color 0.12s;
}
.nav-alerts:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-alerts.active { background: rgba(255,255,255,0.15); color: white; }
.alert-count {
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.15);
    padding: 1px 5px;
    border-radius: 2px;
    font-size: 11px;
    margin-left: 3px;
}
.nav-user { font-size: 13px; color: rgba(255,255,255,0.85); }
.nav-btn {
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    border: 1px solid rgba(255,255,255,0.2);
    transition: background 0.12s;
}
.nav-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-btn-primary {
    background: white;
    color: var(--green) !important;
    border-color: white;
    font-weight: 600;
}
.nav-btn-primary:hover { background: #eef5f0; }

/* =================================
   LAYOUT
   ================================= */
.main {
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px 40px;
    flex: 1;
}

.site-footer {
    width: 100%;
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    text-align: center;
    margin-top: auto;
}
.site-footer a {
    color: var(--text-secondary);
    margin-left: 8px;
}
.site-footer a:hover {
    color: var(--green);
}

/* =================================
   SEARCH
   ================================= */
.page-intro {
    text-align: center;
    padding: 20px 0 16px;
    color: var(--text-secondary);
    font-size: 14px;
}

.term-tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 14px;
}
.term-tab {
    padding: 4px 14px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.12s;
}
.term-tab:hover { border-color: var(--green); color: var(--green); }
.term-tab.active { background: var(--green); color: white; border-color: var(--green); }

.term-group-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 14px 0 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.two-col-search {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

.search-col { min-width: 0; }

.col-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.search-bar {
    position: relative;
    margin: 0 0 10px;
}
.search-bar .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 7px 10px 7px 32px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    transition: border-color 0.12s;
}
.search-input:focus {
    outline: 2px solid var(--green-mid);
    outline-offset: -1px;
    border-color: var(--green-mid);
}

#course-results, #prof-results {
    min-height: 80px;
}

.col-empty {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-secondary);
    font-size: 13px;
}

.empty-state {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* =================================
   COURSE CARDS — flat, left-border accent
   ================================= */
.course-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.course-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 12px;
    gap: 10px;
    border-bottom: 1px solid var(--border);
}

.course-code {
    font-weight: 600;
    font-size: 14px;
    color: var(--green);
}
.course-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.clickable {
    cursor: pointer;
    transition: color 0.12s;
}
.clickable:hover {
    color: var(--green);
    text-decoration: underline;
}

.desc-details { margin-top: 3px; }
.desc-details summary {
    font-size: 12px;
    color: var(--green);
    cursor: pointer;
    user-select: none;
    list-style: none;
    width: fit-content;
    transition: color 0.12s;
}
.desc-details summary::-webkit-details-marker { display: none; }
.desc-details summary:hover { text-decoration: underline; }
.desc-details summary:focus-visible { outline: 2px solid var(--green-mid); outline-offset: 1px; border-radius: 2px; }
.desc-text {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.course-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
    white-space: nowrap;
}

.credits-badge {
    font-size: 12px;
    color: var(--text-secondary);
}

.seats-badge {
    font-size: 12px;
    font-weight: 600;
}
.seats-badge.open  { color: var(--open); }
.seats-badge.closed { color: var(--closed); }

/* =================================
   SECTIONS — compact rows
   ================================= */
.section-row {
    padding: 6px 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.section-row:last-of-type { border-bottom: none; }
.section-extra.hidden { display: none; }

.section-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px;
}

.section-left {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}
.section-code {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}
.section-instructor {
    font-size: 13px;
    color: var(--green);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    cursor: default;
}
.section-instructor.clickable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: var(--green-mid);
    text-underline-offset: 2px;
}
.section-instructor.clickable:hover {
    text-decoration-style: solid;
    text-decoration-color: var(--green);
}

.seat-badge {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.seat-badge.open   { color: var(--open); }
.seat-badge.closed { color: var(--closed); }

.section-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.section-meetings {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    flex: 1;
    min-width: 0;
}
.meeting-chip {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg);
    border-radius: 2px;
    padding: 1px 5px;
}

.show-more-btn {
    width: 100%;
    padding: 5px;
    border: none;
    border-top: 1px solid var(--border);
    background: transparent;
    color: var(--green);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s;
}
.show-more-btn:hover { background: var(--green-light); }

/* =================================
   SECTION ACTIONS ROW
   ================================= */
.section-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =================================
   BOOKS
   ================================= */
.books-toggle {
    font-size: 12px;
    color: var(--green);
    cursor: pointer;
    white-space: nowrap;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
}
.books-toggle:hover {
    text-decoration: underline;
}

.books-panel {
    padding: 6px 12px 10px;
    border-top: 1px solid var(--border);
}
.books-panel.hidden {
    display: none;
}

.books-loading {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.books-empty {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.books-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.book-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.book-main {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}

.book-title {
    font-size: 13px;
    font-weight: 500;
}

.book-author {
    font-size: 12px;
    color: var(--text-secondary);
}

.book-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.book-req {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
}
.book-req.req {
    background: #fee2e2;
    color: #991b1b;
}
.book-req.opt {
    background: #f0f0f0;
    color: var(--text-secondary);
}

.book-isbn, .book-edition, .book-price {
    font-size: 11px;
    color: var(--text-secondary);
}

.book-price {
    font-weight: 600;
}

/* =================================
   ALERT BUTTON — minimal
   ================================= */
.alert-btn {
    padding: 2px 7px;
    border: 1px solid var(--input-border);
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.12s, color 0.12s;
}
.alert-btn:hover { border-color: var(--green); color: var(--green); }
.alert-btn.active {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

/* =================================
   PROFESSOR CARDS — same flat style
   ================================= */
.prof-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 3px solid var(--green);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.prof-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}

.prof-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--green);
}

.prof-short-name {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.rmp-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 1px;
}

.rmp-line {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.rmp-line-link {
    color: var(--green);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}
.rmp-line-link:hover {
    text-decoration: underline;
}
.rmp-line-link .rmp-line {
    color: var(--green);
}

.rmp-score {
    font-weight: 600;
}
.rmp-high { color: #166534; }
.rmp-mid  { color: #92400e; }
.rmp-low  { color: #991b1b; }
.rmp-none { color: var(--text-secondary); }

.rmp-line-link .rmp-sub {
    color: var(--green);
}

.rmp-sub {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.rmp-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    background: #f0f0f0;
}
.section-left .rmp-badge {
    margin-left: 4px;
}
.rmp-badge.rmp-high { background: #dcfce7; color: #166534; }
.rmp-badge.rmp-mid  { background: #fef3c7; color: #92400e; }
.rmp-badge.rmp-low  { background: #fee2e2; color: #991b1b; }

.rmp-inline {
    font-size: 13px;
    white-space: nowrap;
}
.rmp-inline-link {
    color: var(--green);
    text-decoration: none;
}
.rmp-inline-link:hover {
    text-decoration: underline;
}

.prof-sections { padding: 0; }

.prof-section-row {
    padding: 5px 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.prof-section-row:last-child { border-bottom: none; }

.prof-section-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 4px;
}

.prof-section-left {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.prof-course-title {
    font-size: 13px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* =================================
   FAVORITES
   ================================= */
.page-header {
    padding: 20px 0 14px;
}
.page-header h1 { font-size: 16px; font-weight: 600; color: var(--green); }
.page-header p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.fav-count {
    color: var(--text-secondary);
    font-weight: 600;
}

.chart-toggle {
    width: 100%;
    padding: 5px;
    border: none;
    border-top: 1px solid var(--border);
    background: transparent;
    color: var(--green);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s;
}
.chart-toggle:hover { background: var(--green-light); }

.chart-wrap {
    height: 200px;
    padding: 8px 12px 12px;
    border-top: 1px solid var(--border);
}
.chart-wrap.hidden { display: none; }

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 13px;
}

.alert-btn.limit-hit {
    color: var(--closed);
    border-color: var(--closed);
    cursor: pointer;
}

.alert-signin-wrap {
    position: relative;
}
.signin-tip {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    z-index: 50;
    animation: tip-in 0.12s ease-out;
}
.signin-tip a {
    color: var(--green);
    font-weight: 600;
}
.signin-tip a:hover {
    text-decoration: underline;
}
@keyframes tip-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =================================
   AUTH PAGES
   ================================= */
.auth-box {
    max-width: 360px;
    margin: 60px auto;
    text-align: center;
}
.auth-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--green);
    margin-bottom: 6px;
}
.auth-sub {
    font-size: 13px;
    color: var(--text-secondary);
}
.auth-error {
    font-size: 13px;
    color: var(--closed);
    margin: 12px 0;
}
.auth-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: left;
    margin-top: 16px;
    margin-bottom: 4px;
}
.auth-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    margin: 0 0 10px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    font-size: 14px;
}
.auth-input:focus {
    outline: 2px solid var(--green-mid);
    outline-offset: -1px;
    border-color: var(--green-mid);
}
.auth-submit {
    display: block;
    width: 100%;
    padding: 9px;
    background: var(--green);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.12s;
}
.auth-submit:hover { background: #1a4528; }
.auth-back {
    display: inline-block;
    margin-top: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}
.auth-back:hover { color: var(--green); }

/* =================================
   LEGAL / PRIVACY
   ================================= */
.legal-page {
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 0 40px;
}
.legal-page h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--green);
    margin-bottom: 4px;
}
.legal-updated {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}
.legal-page h2 {
    font-size: 14px;
    font-weight: 600;
    margin: 20px 0 6px;
}
.legal-page p,
.legal-page li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.legal-page ul {
    padding-left: 20px;
    margin: 6px 0;
}
.legal-page li {
    margin-bottom: 4px;
}
.legal-page a {
    color: var(--green);
}
.legal-page a:hover {
    text-decoration: underline;
}
.delete-account-btn {
    margin-top: 8px;
    padding: 7px 16px;
    background: transparent;
    color: var(--closed);
    border: 1px solid var(--closed);
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.delete-account-btn:hover {
    background: var(--closed);
    color: white;
}

/* =================================
   MOBILE
   ================================= */
@media (max-width: 768px) {
    .two-col-search { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 640px) {
    .topnav-wrap { padding: 6px 10px; }
    .main { padding: 0 12px 28px; }
    .section-left { overflow: hidden; flex: 1 1 0; flex-wrap: wrap; }
    .section-instructor { font-size: 12px; }
    .rmp-inline { white-space: normal; font-size: 12px; }
    .nav-alerts-label { display: none; }
    .nav-link { display: none; }
    .nav-user { display: none; }
    .signin-tip { white-space: normal; }
}

@media (pointer: coarse) {
    .alert-btn { padding: 7px 12px; font-size: 13px; }
    .nav-btn { padding: 8px 12px; }
    .nav-alerts { padding: 8px 10px; }
    .books-toggle { padding: 4px 0; }
}
