/* allcampus UI system. Loaded after structural styles; no page or data changes. */
@font-face {
  font-family: "DM Sans";
  src: url("fonts/dm-sans-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
}
:root {
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-title: clamp(1.75rem, 3vw, 2.25rem);
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --bg: #fafaf9;
  --surface: #fff;
  --surface-muted: #f3f4f5;
  --ink: #22272e;
  --muted: #626972;
  --border: #e2e4e7;
  --border-strong: #a5abb3;
  --primary: #1c2e4a;
  --primary-dark: #101b2e;
  --nav-control: #394960;
  --nav-control-hover: #4a5970;
  --primary-soft: #edf1f6;
  --accent: #526d91;
  --accent-soft: #eef2f7;
  --danger: #b42318;
  --radius-sm: 8px;
  --radius-control: 12px;
  --radius-card: 20px;
  --radius-panel: 24px;
  --radius-pill: 999px;
  --radius: var(--radius-control);
  --shadow-sm: 0 2px 6px rgb(16 27 46 / 5%);
  --shadow-card: 0 8px 24px rgb(16 27 46 / 8%);
  --shadow-overlay: 0 16px 48px rgb(16 27 46 / 14%);
  --surface-hover: #ebebeb;
  --shadow-hover: 0 6px 18px rgb(16 27 46 / 10%), 0 2px 4px rgb(16 27 46 / 4%);
  --shadow: var(--shadow-card);
  --focus-ring: 0 0 0 4px rgb(82 109 145 / 18%);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 280ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
}

[hidden] { display: none !important; }
.guest-actions { display: flex; align-items: center; gap: 10px; }
.session-login, .session-signup, .session-logout { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: var(--weight-semibold); white-space: nowrap; cursor: pointer; }
.session-login, .session-logout { color: white; background: var(--nav-control); border: 1px solid rgb(255 255 255 / 28%); }
.session-signup { background: white; color: var(--primary); border: 1px solid white; }
.session-logout svg { width: 20px; height: 20px; flex-shrink: 0; }
.session-login:hover, .session-logout:hover { background: var(--nav-control-hover); }
.session-signup:hover { background: var(--surface-hover); }
.auth-panel > .session-logout { margin-top: 20px; background: var(--primary); }
.session-error { color: inherit; font-size: var(--text-sm); }
@media (max-width: 880px) { .session-logout { width: 40px; min-height: 40px; padding: 8px; flex-shrink: 0; } .session-logout span { display: none; } }
@media (max-width: 620px) { .guest-actions { gap: 6px; } .session-login, .session-signup { min-height: 40px; padding: 8px 10px; font-size: 13px; } }
body { font-family: var(--font-sans); font-optical-sizing: auto; line-height: 1.55; letter-spacing: -.01em; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-weight: var(--weight-semibold); line-height: 1.25; letter-spacing: -.025em; }
h1, .section-heading h1 { font-size: var(--text-title); }
h2, .section-heading h2 { font-size: var(--text-xl); }
strong, b, th { font-weight: var(--weight-semibold); }
button, input, select, textarea { font-family: var(--font-sans); }
button, a, input, select, textarea, .email-input-wrapper, .avatar-choice-image, .avatar-choice-initials {
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration-normal) var(--ease-out), color var(--duration-normal) var(--ease-out), border-color var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out), transform var(--duration-normal) var(--ease-out);
}
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}
.avatar-choice:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 5px; }

/* Shared button primitives, used on every existing journey. */
.primary-button, .secondary-button, .ghost-button, .danger-button, .back-button {
  min-height: 48px;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.4;
}
.primary-button, .auth-panel .primary-button { background: var(--primary); }
.secondary-button { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.ghost-button { background: transparent; border-color: var(--border); color: var(--ink); }
.back-button { background: var(--surface); border-color: var(--border); color: var(--primary); }
.compact { min-height: 40px; padding: var(--space-2) var(--space-4); }
.icon-button, .profile-button { width: 44px; height: 44px; border-radius: var(--radius-pill); }
.tab-button, .major-button, .condition-current { font-weight: var(--weight-medium); }
.primary-button:active, .secondary-button:active, .ghost-button:active, .danger-button:active,
.back-button:active, .icon-button:active, .profile-button:active, .tab-button:active { transform: scale(.97); transition-duration: var(--duration-fast); }
:is(button, a):is(:disabled, .disabled, [aria-disabled="true"]) { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* Fields retain native select semantics and all existing validation. */
label { gap: var(--space-2); }
label > span:first-child, .condition-field > span { font-weight: var(--weight-medium); font-size: var(--text-sm); }
input, select, textarea { min-height: 50px; padding: var(--space-3) var(--space-4); border-color: var(--border-strong); border-radius: var(--radius-control); }
input:focus, select:focus, textarea:focus, .email-input-wrapper:focus-within { border-color: var(--primary); box-shadow: var(--focus-ring); }
.email-input-wrapper { border-color: var(--border-strong); }
.email-input-wrapper input { min-width: 0; }
.email-domain { font-size: var(--text-sm); padding-inline: var(--space-3); }
.password-toggle { background: transparent; border-color: transparent; font-size: var(--text-xs); font-weight: var(--weight-semibold); }
input[type="file"] { background: var(--surface-muted); border: 1px dashed var(--border-strong); padding: var(--space-4); }
input::file-selector-button { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 8px 12px; margin-right: 12px; color: var(--primary); font: inherit; cursor: pointer; }
.auth-form.active, .listing-form, .avatar-form { gap: var(--space-6); }
#login-form label > span:first-child::after { content: none; }
/* A soft focus halo replaces the dark outline while keeping focus visible. */
.search-wrap :is(input, select):focus,
.auth-form :is(input, select):focus:not(.input-error),
.auth-form .email-input-wrapper:focus-within {
  outline: none;
  border-color: var(--border);
  box-shadow: var(--focus-ring);
}
.auth-form .email-input-wrapper input:focus { box-shadow: none; }
#login-form.credentials-invalid .password-control input {
  border-color: #d93025;
  outline: none;
  box-shadow: inset 0 0 0 1px #d93025;
  animation: credential-border 360ms ease-out;
}
#login-form.credentials-invalid label:has(.password-control) > span:first-child {
  color: #d93025;
}
#login-form.credentials-invalid #login-error {
  color: #d93025;
  margin-top: -16px;
  padding: 0;
  border: 0;
  background: transparent;
  animation: errorSlideIn 160ms ease-out;
}
#login-form.credentials-invalid #login-error::before { background: #d93025; }
@keyframes credential-border {
  from { box-shadow: inset 0 0 0 1px #d93025, 0 0 0 4px rgb(217 48 37 / 18%); }
  to { box-shadow: inset 0 0 0 1px #d93025, 0 0 0 0 rgb(217 48 37 / 0%); }
}
@media (prefers-reduced-motion: reduce) {
  #login-form.credentials-invalid .password-control input,
  #login-form.credentials-invalid #login-error { animation: none; }
}
.auth-tabs { border: 0; border-radius: var(--radius-control); padding: var(--space-1); margin-bottom: var(--space-8); }
.tab-button { border-radius: var(--radius-sm); min-height: 44px; }
.tab-button.active { font-weight: var(--weight-semibold); box-shadow: var(--shadow-sm); }
.auth-link-row a { text-decoration: underline; text-underline-offset: 4px; font-size: var(--text-sm); }
.auth-shell { padding: var(--space-12) var(--space-4); background: radial-gradient(ellipse at 15% 0%, #edf1f6, transparent 55%), var(--bg); }
.auth-panel { padding: clamp(24px, 5vw, 48px); border-radius: var(--radius-panel); box-shadow: var(--shadow-card); }
body[data-page="auth"] .auth-panel { width: min(600px, 100%); }
.brand-lockup { margin-bottom: var(--space-8); }
.brand-wordmark-large { font-size: clamp(2.6rem, 8vw, 4rem); letter-spacing: -.055em; }
.brand-wordmark { letter-spacing: -.045em; }

/* Original navy navigation surface, with white labels and controls. */
.topbar { min-height: 88px; background: var(--primary); border-bottom-color: var(--primary-dark); box-shadow: 0 10px 26px rgb(28 46 74 / 14%); }
.topbar .brand-wordmark, .topbar .page-title { color: white; }
.topbar :is(a, button):focus-visible { outline-color: white; }
.page-title { font-weight: var(--weight-medium); font-size: var(--text-sm); }
.page-title:empty { display: none; }
.top-actions { grid-column: -2 / -1; gap: var(--space-2); }
.market-topbar { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: clamp(28px, 4vw, 64px); }
.market-service-links { display: flex; align-self: stretch; align-items: stretch; gap: 40px; padding-left: 12px; }
.market-service-links a { position: relative; display: flex; align-items: center; color: white; font-size: 18px; font-weight: var(--weight-medium); }
.market-service-links a:hover { color: #9dceff; }
.market-service-links [aria-current="page"]::after { content: ''; position: absolute; left: -12px; right: -12px; bottom: -14px; height: 4px; border-radius: 4px; background: #9dceff; }
@media (max-width: 880px) {
  .topbar.market-topbar { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; }
  .market-service-links { grid-row: 2; grid-column: 1 / -1; justify-content: center; min-height: 40px; padding-left: 0; }
  .market-service-links a { font-size: 16px; }
  .market-service-links [aria-current="page"]::after { bottom: -14px; }
  .market-topbar .top-actions { grid-row: 1; grid-column: 2; }
}
.icon-button, .profile-button { color: var(--primary); background: var(--surface); border-color: var(--border); }
.message-icon::after { background: var(--surface); }
.bell-icon { display: block; width: 24px; height: 24px; border: 0; border-radius: 0; background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9M10 21h4M12 2V1'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat; }
.bell-icon::before, .bell-icon::after { content: none; }
.campus-header, .auth-panel { position: relative; }
.campus-header { z-index: 20; }
.notification-popover { color: var(--ink); line-height: 1.5; max-width: calc(100vw - 24px); }
.notification-popover .empty-state h2 { color: var(--ink); font-family: var(--font-sans); font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: 1.25; letter-spacing: -.025em; }
.notification-count { background: var(--primary); color: white; border: 2px solid var(--surface); font-weight: var(--weight-semibold); }
:is(.topbar, .campus-header) :is(.icon-button, .profile-button) { color: white; background: var(--nav-control); border-color: rgb(255 255 255 / 28%); }
:is(.topbar, .campus-header) .message-icon::after { background: var(--nav-control); }
.topbar .notification-count { background: white; color: var(--primary); border-color: var(--primary); }
.notification-popover { top: calc(100% + 8px); border-radius: var(--radius-card); padding: var(--space-2); box-shadow: var(--shadow-overlay); }
.notification-item { border-radius: var(--radius-control); padding: var(--space-4); }
.notification-popover:not([hidden]), .condition-menu:not([hidden]), .contact-panel:not([hidden]) { animation: surface-enter var(--duration-normal) var(--ease-out); }

/* Marketplace keeps its major sidebar and its own search/filter controls. */
.market-shell { width: calc(100% - 72px); gap: var(--space-8); margin-block: var(--space-10) 64px; }
.sidebar { top: 112px; border-radius: var(--radius-card); padding: var(--space-6) var(--space-4); }
.sidebar h2 { font-size: var(--text-lg); padding-inline: var(--space-3); }
.major-list { gap: var(--space-1); margin-top: var(--space-5); }
.major-button { min-height: 44px; border-radius: var(--radius-control); }
.major-button.active { color: var(--primary); background: var(--primary-soft); font-weight: var(--weight-semibold); }
.section-heading { margin-bottom: var(--space-6); }
.marketplace-heading { gap: var(--space-6); }
.search-wrap { gap: var(--space-3); }
.search-wrap input, .search-wrap select { border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface); padding-inline: var(--space-5); font-size: var(--text-sm); }
.listing-grid { gap: var(--space-6); }
.listing-card { border-radius: var(--radius-card); box-shadow: var(--shadow-sm); transition: transform var(--duration-normal) var(--ease-out), box-shadow var(--duration-normal) var(--ease-out), border-color var(--duration-normal) var(--ease-out); }
.listing-photo { background: #f3f3f1; }
.listing-photo img { transition: transform var(--duration-slow) var(--ease-out); }
.listing-body { padding: var(--space-4); }
.listing-body h3 { font-weight: var(--weight-semibold); line-height: 1.4; }
.listing-body p { line-height: 1.6; }
.status-pill { min-height: 28px; padding-inline: var(--space-3); font-weight: var(--weight-medium); }
.empty-state { padding: var(--space-10) var(--space-6); border-style: dashed; border-radius: var(--radius-card); }

/* Detail, account, listing editor and messaging surfaces share the same family. */
.item-gallery, .item-info, .listing-form, .purchase-panel, .chat-panel, .profile-summary, .dashboard-section, .messages-inbox, .home-panel { border-radius: var(--radius-card); box-shadow: var(--shadow-sm); }
.item-info, .listing-form, .purchase-panel, .profile-summary, .dashboard-section, .messages-inbox { padding: var(--space-8); }
.detail-shell, .form-shell, .dashboard-shell, .messages-shell { margin-top: var(--space-10); }
.dashboard-shell, .item-layout { gap: var(--space-6); }
.hero-photo, .thumb-row img, .photo-preview-tile img { border-radius: var(--radius-control); }
.profile-summary { gap: var(--space-5); }
.profile-row { padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.compact-item { padding: var(--space-4); border-radius: var(--radius-control); }
.conversation-row { padding: var(--space-4); border-radius: var(--radius-control); }
.conversation-main h3 { font-size: var(--text-base); }
.chat-context, .message-form { padding: var(--space-5) var(--space-6); }
.messages { padding: var(--space-6); gap: var(--space-3); }
.message { padding: var(--space-3) var(--space-4); border-radius: 18px 18px 18px 5px; overflow-wrap: anywhere; }
.message.own { border-radius: 18px 18px 5px 18px; }
.message.system { border-radius: var(--radius-control); font-size: var(--text-sm); }
.condition-current { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-color: var(--border-strong); min-height: 50px; }
.condition-current::after { content: "⌄"; font-size: 1.2rem; }
.condition-current[aria-expanded="true"]::after { transform: rotate(180deg); }
.condition-menu { border-radius: var(--radius-control); box-shadow: var(--shadow-card); }
.condition-option { padding: var(--space-3); border-radius: var(--radius-sm); }
.feature-button { border-radius: var(--radius-card); }
.photo-modal-overlay { background: rgb(16 22 31 / 88%); backdrop-filter: blur(6px); }
.photo-modal:not([hidden]) { animation: surface-enter var(--duration-normal) var(--ease-out); }
.photo-modal-content { max-width: 84vw; max-height: 80dvh; }
.photo-modal-content img { max-width: 84vw; max-height: 75dvh; border-radius: var(--radius-control); }
.photo-modal-close { top: -48px; width: 44px; height: 44px; font-size: 1.5rem; }
.photo-modal button:focus-visible { outline-color: white; }
@keyframes surface-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (hover: hover) {
  .primary-button:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow-card); transform: translateY(-1px); }
  .secondary-button:hover:not(.disabled), .ghost-button:hover:not(:disabled), .back-button:hover { background: var(--surface-muted); border-color: var(--ink); color: var(--ink); box-shadow: var(--shadow-sm); }
  .icon-button:hover, .profile-button:hover { background: var(--surface-muted); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
  .icon-button:hover .message-icon::after { background: var(--surface-muted); }
  .listing-card:hover, .listing-card:focus-within { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-card); }
  .major-button:hover, .tab-button:not(.active):hover { background: var(--primary-soft); color: var(--primary); }
  .conversation-row:hover, .compact-item:hover { background: var(--bg); border-color: var(--border-strong); }
  .password-toggle:hover { background: var(--surface-muted); }
  :is(button, .primary-button, .secondary-button, .ghost-button, .danger-button, .back-button, .icon-button, .profile-button, .feature-button):hover:not(:disabled):not(.disabled):not([aria-disabled="true"]) {
    box-shadow: var(--shadow-hover);
  }
  :is(input, select, textarea):hover:not(:disabled):not([type="radio"]):not([type="checkbox"]), .email-input-wrapper:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-hover);
  }
  .email-input-wrapper input:hover { box-shadow: none; }
  :is(input, select, textarea):focus:hover, .email-input-wrapper:focus-within:hover { box-shadow: var(--focus-ring), var(--shadow-hover); }
  .email-input-wrapper input:focus:hover { box-shadow: none; }
  input::file-selector-button:hover { box-shadow: var(--shadow-hover); }
  :is(.topbar, .campus-header) :is(.icon-button, .profile-button):hover { background: var(--nav-control-hover); border-color: rgb(255 255 255 / 60%); box-shadow: 0 5px 16px rgb(0 0 0 / 32%), 0 0 0 1px rgb(255 255 255 / 15%); }
  :is(.topbar, .campus-header) .icon-button:hover .message-icon::after { background: var(--nav-control-hover); }
  /* Reference treatment: a stationary, rounded surface that fades to gray. */
  .search-wrap :is(input, select):hover:not(:disabled):not([type="radio"]):not([type="checkbox"]) {
    background-color: var(--surface-hover);
    border-color: transparent;
    box-shadow: var(--shadow-hover);
    transform: none;
  }
  .search-wrap :is(input, select):focus:hover:not(:disabled) {
    border-color: transparent;
    box-shadow: var(--focus-ring), var(--shadow-hover);
  }
  .auth-form :is(input, select):hover:not(:disabled):not(.input-error),
  .auth-form .email-input-wrapper:hover {
    background-color: var(--surface-hover);
    border-color: transparent;
    box-shadow: var(--shadow-hover);
  }
  .auth-form :is(input, select):focus:hover:not(:disabled):not(.input-error),
  .auth-form .email-input-wrapper:focus-within:hover {
    box-shadow: var(--focus-ring), var(--shadow-hover);
  }
  .auth-form .email-input-wrapper input:hover,
  .auth-form .email-input-wrapper input:focus:hover { background: transparent; box-shadow: none; }
  :is(.secondary-button, .ghost-button, .back-button, .tab-button, .major-button, .condition-current, .condition-option, .password-toggle):hover:not(:disabled):not(.disabled):not([aria-disabled="true"]) {
    background-color: var(--surface-hover);
    color: var(--ink);
    border-color: transparent;
    box-shadow: var(--shadow-hover);
  }
  :is(.primary-button, .secondary-button, .ghost-button, .danger-button, .back-button, .icon-button, .profile-button):hover:not(:disabled):not(.disabled) { transform: none; }
}
@media (max-width: 880px) {
  .topbar { gap: var(--space-3); min-height: 80px; }
  .sidebar { position: static; }
  .major-list { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .market-shell { width: calc(100% - 32px); gap: var(--space-6); }
}
@media (max-width: 620px) {
  .topbar { padding: var(--space-4); grid-template-columns: minmax(0, 1fr) auto; }
  .top-actions { gap: 6px; }
  .topbar .brand-wordmark { font-size: 1.5rem; }
  .icon-button, .profile-button { width: 40px; height: 40px; min-height: 40px; }
  .topbar .compact { padding-inline: 10px; }
  .auth-shell { padding-block: var(--space-8); }
  .auth-panel, .item-info, .listing-form, .purchase-panel, .profile-summary, .dashboard-section, .messages-inbox { padding: var(--space-6); }
  .brand-wordmark-large { font-size: 2.8rem; }
  .market-shell, .detail-shell, .form-shell, .dashboard-shell, .messages-shell { margin-top: var(--space-6); }
  .section-heading { flex-wrap: wrap; }
  .search-wrap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-wrap input { grid-column: 1 / -1; }
  .search-wrap select { min-width: 0; padding-inline: 12px; }
  .listing-grid { gap: var(--space-3); }
  .listing-card { border-radius: var(--radius-control); }
  .listing-body { padding: var(--space-3); }
  .listing-body p { font-size: var(--text-xs); }
  .email-domain { font-size: .75rem; padding-inline: 8px; }
  .conversation-row { gap: var(--space-2); padding: var(--space-3); grid-template-columns: 40px minmax(0, 1fr) auto; }
  .conversation-row .avatar { width: 40px; height: 40px; }
  .message-form, .messages, .chat-context { padding: var(--space-4); }
}
@media (max-width: 360px) {
  .topbar { padding-inline: 10px; }
  .topbar .brand-wordmark { font-size: 1.3rem; }
  .top-actions { gap: 4px; }
  .auth-panel { padding: var(--space-5); }
}
:is(.primary-button, .secondary-button, .ghost-button, .danger-button, .back-button, .icon-button, .profile-button):active:not(:disabled):not(.disabled) { transform: scale(.97); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .listing-card:hover, .listing-card:hover .listing-photo img, .feature-button:hover { transform: none; }
}
