/* Submarine — Dark App UI Stylesheet (Desktop + Mobile Responsive) */

@layer base, components, utilities;

:root {
  color-scheme: dark;

  --bg: #0d0e12;
  --surface: #1b1e25;
  --surface-elevated: #262a34;
  --surface-hover: #313644;
  --surface-input: #14171d;
  --nav-bg: #16181e;

  --text: #f5f7fa;
  --text-secondary: #c5cbd8;
  --text-muted: #9aa3b5;

  --border: #3a404f;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-input: #4b5563;

  --accent: #005bff;
  --accent-hover: #1a6dff;
  --accent-soft: rgba(0, 91, 255, 0.18);
  --accent-text: #5b9dff;

  --green: #16a34a;
  --green-active: #15803d;
  --green-active-hover: #166534;
  --green-pill-bg: #163826;
  --green-pill-text: #4ade80;

  --danger: #f91155;
  --danger-bg: rgba(249, 17, 85, 0.16);
  --danger-text: #ff6b93;

  --warn-bg: rgba(245, 158, 11, 0.16);
  --warn-text: #fbbf24;

  --radius-card: 20px;
  --radius-media: 14px;
  --radius-control: 12px;
  --radius-pill: 8px;
  --max-width: 960px;
}

@layer base {
  html {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
  }

  body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
  }

  a,
  button,
  input,
  select,
  textarea,
  article,
  section,
  div,
  header,
  footer,
  nav,
  main,
  dialog {
    box-sizing: border-box;
  }

  a {
    color: var(--accent-text);
    text-decoration: none;
  }

  a:hover {
    text-decoration: underline;
  }

  :focus-visible {
    outline: 3px solid var(--accent-text);
    outline-offset: 2px;
  }

  h1,
  h2,
  h3,
  h4 {
    color: var(--text);
    letter-spacing: -0.015em;
  }

  hr {
    border: 0;
    border-top: 1px solid var(--border-subtle);
  }
}

@layer utilities {
  .visually-hidden:where(:not(:focus-within, :active)) {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
  }

  .stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
  }

  .row-between {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .muted {
    color: var(--text-muted);
  }

  .small {
    font-size: 0.85rem;
  }
}

@layer components {
  /* Header (Desktop top bar + Mobile profile bar) */
  .site-header {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    white-space: nowrap;
  }

  .brand:hover {
    text-decoration: none;
    color: var(--accent-text);
  }

  .main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }

  .main-nav a {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius-control);
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    transition: background-color 0.14s ease, color 0.14s ease;
  }

  .main-nav a:hover {
    background: var(--surface-elevated);
    color: var(--text);
    text-decoration: none;
  }

  .main-nav a[aria-current="page"] {
    background: var(--surface-elevated);
    color: var(--text);
    font-weight: 600;
  }

  .user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
  }

  .header-profile-link {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text);
    min-width: 0;
  }

  .header-profile-link:hover {
    text-decoration: none;
  }

  .header-profile-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    min-width: 0;
  }

  .header-profile-name {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }

  .user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 600;
  }

  .user-chip:hover {
    text-decoration: none;
    color: var(--accent-text);
  }

  /* Mobile Bottom Navigation (hidden on desktop) */
  .bottom-nav {
    display: none;
  }

  /* Layout */
  .container {
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 1.25rem 1rem 2.5rem;
    flex: 1;
  }

  .auth-container {
    max-width: 440px;
    margin: 2.5rem auto;
  }

  .site-footer {
    border-top: 1px solid var(--border-subtle);
    background: var(--nav-bg);
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 1rem;
    text-align: center;
  }

  .page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-block-end: 1rem;
  }

  .page-header h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
  }

  .page-subtitle {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
  }

  /* Cards */
  .card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 1.1rem 1.2rem;
    margin-block-end: 1rem;
  }

  .card-pinned {
    border-color: rgba(0, 91, 255, 0.55);
  }

  .card-cancelled {
    opacity: 0.76;
  }

  .meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.84rem;
    color: var(--text-muted);
  }

  /* Avatars — Rounded-square squircle style (Screenshot 2) */
  .avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    corner-shape: squircle;
    object-fit: cover;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
    display: block;
  }

  .avatar-md {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .avatar-lg {
    width: 72px;
    height: 72px;
    border-radius: 18px;
  }

  .avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
    background: var(--surface-elevated);
  }

  .avatar-fallback svg {
    width: 55%;
    height: 55%;
    fill: currentColor;
  }

  /* Badges & Role Pills (Screenshot 1 & 2) */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.22rem 0.55rem;
    border-radius: var(--radius-pill);
    background: var(--surface-elevated);
    color: var(--text-secondary);
    line-height: 1.25;
  }

  .role-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.22rem 0.55rem;
    border-radius: 7px;
    background: var(--surface-elevated);
    color: var(--text-secondary);
    line-height: 1.2;
  }

  .role-pill-icon {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    color: var(--text-secondary);
  }

  .badge-accent {
    background: var(--accent-soft);
    color: var(--accent-text);
  }

  .badge-success {
    background: var(--green-pill-bg);
    color: var(--green-pill-text);
  }

  .badge-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
  }

  .badge-warn {
    background: var(--surface-elevated);
    color: var(--text);
  }

  .star-icon {
    color: var(--warn-text);
  }

  .meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.26rem 0.58rem;
    border-radius: var(--radius-pill);
    background: var(--surface-elevated);
    color: var(--text-secondary);
  }

  .meta-chip-upper {
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
  }

  .date-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.65rem;
    border-radius: var(--radius-pill);
    background: var(--green-pill-bg);
    color: var(--green-pill-text);
    font-size: 0.82rem;
    font-weight: 600;
  }

  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.55rem 1rem;
    min-height: 44px;
    border-radius: var(--radius-control);
    border: 1px solid transparent;
    background: var(--surface-elevated);
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
  }

  .btn:hover:not(:disabled) {
    background: var(--surface-hover);
    text-decoration: none;
  }

  .btn:active:not(:disabled) {
    transform: scale(0.99);
  }

  .btn-primary {
    background: var(--accent);
    color: #ffffff;
  }

  .btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    color: #ffffff;
  }

  .btn-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: rgba(249, 17, 85, 0.35);
  }

  .btn-danger:hover:not(:disabled) {
    background: rgba(249, 17, 85, 0.26);
  }

  .btn-sm {
    min-height: 36px;
    padding: 0.35rem 0.75rem;
    font-size: 0.84rem;
    border-radius: 10px;
  }

  .btn-ghost {
    background: transparent;
    color: var(--text-muted);
  }

  .btn-ghost:hover:not(:disabled) {
    background: var(--surface-elevated);
    color: var(--text);
  }

  .btn-icon {
    min-height: 38px;
    min-width: 38px;
    padding: 0.4rem;
    border-radius: 10px;
  }

  /* RSVP Button ("Записаться" = electric blue, "Вы записаны" = emerald green) */
  .btn-rsvp-going {
    background: var(--accent);
    color: #ffffff;
    min-height: 46px;
    font-size: 0.94rem;
    font-weight: 600;
    border-radius: var(--radius-control);
  }

  .btn-rsvp-going:hover:not(:disabled) {
    background: var(--accent-hover);
    color: #ffffff;
  }

  .btn-rsvp-going.is-active {
    background: var(--green-active);
    color: #ffffff;
  }

  .btn-rsvp-going.is-active:hover:not(:disabled) {
    background: var(--green-active-hover);
    color: #ffffff;
  }

  /* Interactive Monthly Calendar (Events page) */
  .calendar-wrap {
    display: flex;
    justify-content: center;
    margin-block-end: 1.15rem;
  }

  .calendar-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 0.9rem 1rem 1rem;
  }

  .cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-block-end: 0.7rem;
  }

  .cal-month-title {
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.98rem;
    font-weight: 700;
    padding: 0.3rem 0.65rem;
    border-radius: 10px;
    cursor: pointer;
    text-transform: capitalize;
  }

  .cal-month-title:hover {
    background: var(--surface-elevated);
  }

  .cal-nav-btn {
    background: var(--surface-elevated);
    color: var(--text);
  }

  .cal-weekdays,
  .cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    text-align: center;
  }

  .cal-weekdays {
    margin-block-end: 0.35rem;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
  }

  .cal-weekdays span {
    padding-block: 0.2rem;
  }

  .cal-day {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    aspect-ratio: 1 / 1;
    min-height: 38px;
    border-radius: 10px;
    font: inherit;
    font-size: 0.88rem;
    line-height: 1;
    padding: 0;
  }

  .cal-day-spacer {
    visibility: hidden;
  }

  .cal-day.is-empty {
    color: var(--text-muted);
    opacity: 0.55;
    user-select: none;
  }

  .cal-day.is-today {
    box-shadow: inset 0 0 0 1.5px var(--accent-text);
    color: var(--text);
    opacity: 1;
  }

  .cal-day.has-events {
    border: 1px solid transparent;
    background: var(--surface-elevated);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.14s ease, transform 0.08s ease;
  }

  .cal-day.has-events:hover {
    background: var(--surface-hover);
  }

  .cal-day.has-events:active {
    transform: scale(0.95);
  }

  .cal-day.is-selected {
    background: var(--accent);
    color: #ffffff;
    box-shadow: none;
  }

  .cal-day.is-selected:hover {
    background: var(--accent-hover);
  }

  .cal-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green-pill-text);
    flex-shrink: 0;
  }

  .cal-day.is-selected .cal-dot {
    background: #ffffff;
  }

  .cal-selected-bar {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-control);
    padding: 0.55rem 0.9rem;
    margin-block-end: 0.9rem;
  }

  /* Filter Pills / Tabs (Screenshot 1 top filter chips) */
  .tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-block-end: 0.25rem;
    margin-block-end: 1.15rem;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs a {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-control);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
  }

  .tabs a:hover {
    background: var(--surface-elevated);
    color: var(--text);
    text-decoration: none;
  }

  .tabs a[aria-current="page"] {
    background: var(--surface-elevated);
    border-color: var(--accent);
    color: var(--text);
    font-weight: 600;
  }

  /* Events Layout (Screenshot 1) */
  .events-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(410px, 1fr));
    gap: 1rem;
  }

  .event-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .event-card-banner {
    position: relative;
    border-radius: var(--radius-media);
    overflow: hidden;
    aspect-ratio: 16 / 8;
    background: var(--surface-elevated);
  }

  .event-card-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .event-banner-chips {
    position: absolute;
    inset-block-start: 0.65rem;
    inset-inline-start: 0.65rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .event-banner-chip {
    background: rgba(13, 14, 18, 0.82);
    backdrop-filter: blur(6px);
    color: var(--text);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
  }

  .event-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .event-card-title {
    margin: 0;
    font-size: 1.18rem;
    font-weight: 700;
    line-height: 1.25;
  }

  .event-card-title a {
    color: var(--text);
  }

  .event-card-title a:hover {
    color: var(--accent-text);
    text-decoration: none;
  }

  .event-count-accent {
    flex-shrink: 0;
    text-align: end;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--green-pill-text);
    line-height: 1.2;
  }

  .event-card-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .event-card-location {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.4;
  }

  .event-dates-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
  }

  .event-dates-label {
    color: var(--text-secondary);
    font-weight: 500;
  }

  .event-card-actions {
    margin-block-start: auto;
    padding-block-start: 0.25rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    align-items: stretch;
  }

  .event-card-actions .rsvp-wrap,
  .event-card-actions .rsvp-wrap form,
  .event-card-actions .rsvp-wrap button {
    width: 100%;
    height: 100%;
  }

  .event-card-actions .btn-details {
    width: 100%;
    min-height: 46px;
    background: var(--surface-elevated);
    color: var(--text);
    border-radius: var(--radius-control);
    font-weight: 600;
  }

  .event-card-actions .btn-details:hover {
    background: var(--surface-hover);
  }

  /* Profile Hero Card (Screenshot 2) */
  .profile-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .profile-identity {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
  }

  .profile-name {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
  }

  .profile-status-text {
    margin: 0.45rem 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
  }

  /* Forms */
  .field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-block-end: 1rem;
  }

  .field label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
  }

  .field .hint {
    font-size: 0.82rem;
    color: var(--text-muted);
  }

  .error-msg {
    display: none;
    color: var(--danger-text);
    font-size: 0.84rem;
  }

  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="datetime-local"],
  input[type="file"],
  select,
  textarea {
    font: inherit;
    font-size: max(1rem, 1em);
    padding: 0.6rem 0.8rem;
    min-height: 46px;
    width: 100%;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-control);
    background: var(--surface-input);
    color: var(--text);
  }

  textarea {
    min-height: 110px;
    resize: vertical;
  }

  input[type="checkbox"],
  input[type="radio"] {
    accent-color: var(--accent);
    width: 1.15rem;
    height: 1.15rem;
  }

  .checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-block-end: 1rem;
  }

  .checkbox-row label {
    font-weight: 400;
    color: var(--text-secondary);
    cursor: pointer;
  }

  .password-wrap {
    display: flex;
    gap: 0.45rem;
    align-items: stretch;
  }

  .password-wrap input {
    flex: 1;
  }

  :is(input, select, textarea):is(:user-invalid, .user-invalid-fallback) {
    border-color: var(--danger);
    background: rgba(249, 17, 85, 0.08);
  }

  :is(input, select, textarea):is(:user-invalid, .user-invalid-fallback) + .error-msg,
  .password-wrap:has(input:is(:user-invalid, .user-invalid-fallback)) + .error-msg {
    display: block;
  }

  .alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius-control);
    margin-block-end: 1rem;
    font-size: 0.92rem;
  }

  .alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid rgba(249, 17, 85, 0.35);
  }

  .alert-success {
    background: var(--green-pill-bg);
    color: var(--green-pill-text);
    border: 1px solid rgba(74, 222, 128, 0.3);
  }

  /* Feed & Prose */
  .prose {
    overflow-wrap: anywhere;
    color: var(--text-secondary);
  }

  .prose > :first-child {
    margin-top: 0;
  }

  .prose > :last-child {
    margin-bottom: 0;
  }

  .prose pre {
    background: var(--surface-input);
    padding: 0.8rem;
    border-radius: var(--radius-control);
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
  }

  .prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
    color: var(--text);
  }

  .prose blockquote {
    margin: 0.75rem 0;
    padding-inline-start: 0.9rem;
    border-inline-start: 3px solid var(--accent);
    color: var(--text-muted);
  }

  .post-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.55rem;
    margin-block: 0.85rem;
  }

  .post-images-grid img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius-media);
    display: block;
    border: 1px solid var(--border-subtle);
  }

  /* Albums & Photos */
  .albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
  }

  .album-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .album-cover {
    aspect-ratio: 16 / 10;
    background: var(--surface-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 0.85rem;
  }

  .album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .album-card-body {
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
  }

  .photo-tile {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-media);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .photo-tile-btn {
    padding: 0;
    border: 0;
    background: var(--surface-elevated);
    cursor: pointer;
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
  }

  .photo-tile-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .photo-tile-meta {
    padding: 0.5rem 0.65rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
  }

  /* Event Detail Cover & Ratings */
  .event-cover {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: var(--radius-media);
    margin-block-end: 0.95rem;
    display: block;
  }

  .rating-stars {
    display: inline-flex;
    gap: 0.3rem;
  }

  .star-btn {
    min-height: 36px;
    min-width: 38px;
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--surface-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
  }

  .star-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
  }

  .star-btn.is-selected {
    background: var(--warn-bg);
    border-color: rgba(251, 191, 36, 0.55);
    color: var(--warn-text);
  }

  /* Reactions */
  .reactions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-block-start: 0.65rem;
  }

  .reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    min-height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-elevated);
    color: var(--text);
    font: inherit;
    font-size: 0.84rem;
    cursor: pointer;
  }

  .reaction-pill.is-mine {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
    font-weight: 600;
  }

  .reaction-picker {
    position: relative;
    display: inline-block;
  }

  .reaction-picker summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.6rem;
    min-height: 32px;
    border-radius: 999px;
    border: 1px dashed var(--border);
    font-size: 0.82rem;
    color: var(--text-muted);
  }

  .reaction-picker summary::-webkit-details-marker {
    display: none;
  }

  .reaction-picker-menu {
    position: absolute;
    inset-inline-start: 0;
    inset-block-end: calc(100% + 6px);
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 0.35rem;
    display: flex;
    gap: 0.2rem;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    z-index: 20;
  }

  .reaction-picker-btn {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 1.15rem;
    padding: 0.25rem 0.35rem;
    border-radius: 8px;
  }

  .reaction-picker-btn:hover {
    background: var(--surface-hover);
  }

  /* Comments */
  .comments-section {
    margin-block-start: 0.25rem;
  }

  .comments-section h2 {
    margin-top: 0;
    font-size: 1.1rem;
  }

  .comment-node {
    padding: 0.8rem 0;
    border-top: 1px solid var(--border-subtle);
  }

  .comment-children {
    margin-inline-start: 1.15rem;
    padding-inline-start: 0.85rem;
    border-inline-start: 2px solid var(--surface-elevated);
  }

  .comment-deleted {
    font-style: italic;
    color: var(--text-muted);
  }

  .comment-audit {
    background: var(--warn-bg);
    color: var(--warn-text);
    padding: 0.5rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.84rem;
    margin-block: 0.4rem;
  }

  .reply-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background: var(--accent-soft);
    color: var(--accent-text);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    margin-block-end: 0.55rem;
  }

  /* Tables (Admin) */
  .table-wrap {
    overflow-x: auto;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
  }

  th,
  td {
    text-align: start;
    padding: 0.65rem 0.65rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
  }

  th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  /* Native Modal Dialog (Photo Lightbox) */
  dialog.lightbox-dialog {
    width: min(920px, 95vw);
    max-height: 92dvh;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    background: var(--surface);
    color: var(--text);
    overflow: auto;
  }

  dialog.lightbox-dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(4px);
  }

  .lightbox-inner {
    padding: 1rem 1.2rem 1.25rem;
  }

  .lightbox-image {
    width: 100%;
    max-height: 62dvh;
    object-fit: contain;
    background: #090a0d;
    border-radius: var(--radius-media);
    display: block;
  }

  /* Users Directory Grid */
  .users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 0.85rem;
  }

  .user-dir-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
  }
}

/* Mobile adaptation (matches Screenshot 1 & 2 app chrome) */
@media (max-width: 767px) {
  .site-header {
    background: var(--surface);
    border-radius: 0 0 22px 22px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .header-inner {
    padding: 0.75rem 1rem;
  }

  .brand,
  .main-nav {
    display: none;
  }

  .user-menu {
    width: 100%;
    justify-content: space-between;
  }

  .header-profile-name {
    max-width: 55vw;
    font-size: 1rem;
  }

  .container {
    padding: 1rem 0.75rem calc(5.5rem + env(safe-area-inset-bottom));
  }

  .events-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    display: none;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 40;
    background: var(--nav-bg);
    border-top: 1px solid var(--border-subtle);
    padding: 0.45rem 0.25rem calc(0.45rem + env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
  }

  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.2rem 0.25rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    text-decoration: none;
    min-height: 46px;
  }

  .bottom-nav a svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .bottom-nav a[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
  }

  .comment-children {
    margin-inline-start: 0.55rem;
    padding-inline-start: 0.55rem;
  }
}

@media (forced-colors: active) {
  .card,
  .event-card,
  .album-card,
  .user-dir-card,
  .btn,
  .tabs a {
    border: 1px solid CanvasText;
  }
}
