/* ==========================================================================
   CSS Custom Properties - Editorial Marketplace
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Base Colors */
  --white: #ffffff;
  --cream: #faf8f5;
  --cream-dark: #f5f2ed;

  /* Grays */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #2d3748;
  --gray-900: #1a2332;

  /* Brand Colors - Sophisticated Palette */
  --primary: #d97757;
  --primary-dark: #c5633f;
  --primary-light: #e69579;
  --primary-pale: #f9ede8;

  --secondary: #7c9885;
  --secondary-dark: #658770;
  --secondary-light: #a4bdab;

  --accent: #b8956a;
  --accent-dark: #9a7a52;

  /* Semantic Colors */
  --text-color: var(--gray-900);
  --text-muted: var(--gray-600);
  --text-light: var(--gray-400);

  /* Surface Colors */
  --bg-color: var(--cream);
  --surface-color: var(--white);
  --surface-elevated: var(--white);
  --footer-bg: var(--gray-900);
  --hover-bg: var(--cream-dark);

  /* Border Colors */
  --border-color: var(--gray-200);
  --border-medium: var(--gray-300);
  --border-dark: var(--gray-400);

  /* Interactive States */
  --active-bg-color: var(--primary-pale);
  --active-border-color: var(--primary);
  --required-color: var(--primary);

  /* Component Colors */
  --action-button-color: var(--primary);
  --submit-button-color: var(--primary);
  --submit-button-hover: var(--primary-dark);

  /* Table Colors */
  --table-head-background-color: var(--gray-100);
  --table-head-text-color: var(--gray-900);
  --table-row-head-background-color: var(--gray-50);
  --table-row-background-color-even: var(--white);
  --table-row-background-color-odd: var(--gray-50);
  --table-row-background-color-hover: var(--cream-dark);
  --table-row-background-color-disabled: var(--gray-100);

  /* Status Colors */
  --success-color: var(--secondary);
  --warning-color: #f59e0b;
  --banned-color: #dc2626;
  --primary-color: var(--primary);

  /* Error/Danger Colors */
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --error-border: #fca5a5;
  --danger-color: #dc2626;
  --danger-hover: #b91c1c;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(26, 35, 50, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(26, 35, 50, 0.08), 0 2px 4px -2px rgba(26, 35, 50, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(26, 35, 50, 0.1), 0 4px 6px -4px rgba(26, 35, 50, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(26, 35, 50, 0.1), 0 8px 10px -6px rgba(26, 35, 50, 0.05);

  /* Overlay Colors */
  --overlay-bg: rgba(26, 35, 50, 0.4);
  --overlay-bg-dark: rgba(26, 35, 50, 0.7);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.25rem;
  --space-2xl: 1.5rem;
  --space-3xl: 2rem;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  margin: 0;
  padding: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.action,
button,
[hx-delete],
:not(form)[hx-post],
[hx-get] {
  cursor: pointer;
  transition: all 0.2s ease;
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  margin: 0 0 var(--space-lg) 0;
  color: var(--gray-900);
}

h1 {
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.75rem;
  text-align: center;
  padding: var(--space-xl) 0 var(--space-md) 0;
  margin-bottom: var(--space-lg);
  position: relative;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: var(--primary);
}

h3 {
  font-size: 1.5rem;
  text-align: center;
  font-weight: 600;
}

/* Add spacing between multiple table sections */
table + h3 {
  margin-top: var(--space-3xl);
}

h4 {
  font-size: 1.125rem;
  text-align: center;
  font-weight: 600;
}

h3 ul {
  list-style: none;
}

p.note {
  font-size: 0.875rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-md);
  margin-top: var(--space-lg);
  line-height: 1.6;
}

/* ==========================================================================
   Layout
   ========================================================================== */

#app-container {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  background: var(--bg-color);
}

/* When sidebar exists (logged in) */
#app-container:has(> header.menu) {
  grid-template-areas:
    'header header'
    'sidebar main'
    'footer footer';
  grid-template-columns: auto 1fr;
}

/* When no sidebar (logged out) */
#app-container:not(:has(> header.menu)) {
  grid-template-areas:
    'header'
    'welcome'
    'main'
    'footer';
  grid-template-rows: auto auto 1fr auto;
}

#app-container > header.user {
  grid-area: header;
}

#app-container > header.menu {
  grid-area: sidebar;
}

#app-container > main {
  grid-area: main;
}

#app-container > footer {
  grid-area: footer;
}

/* Welcome message (pinned message when logged out) */
#app-container > h3 {
  grid-area: welcome;
  background: var(--primary-pale);
  border-bottom: 2px solid var(--primary);
  padding: var(--space-lg);
  margin: 0;
}

main {
  padding: var(--space-xl) var(--space-lg);
  flex: 1;
  overflow-y: auto;
  background: var(--bg-color);
}

/* Item Layout */
item-header {
  display: block;
  border-bottom: 1px solid var(--border-color);
  max-width: 900px;
  margin: 0 auto var(--space-2xl) auto;
  padding-bottom: var(--space-lg);
}

item {
  display: block;
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-2xl);
  background: var(--surface-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

header.menu {
  padding: var(--space-md);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background: var(--surface-color);
  width: fit-content;
  min-width: 120px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) var(--gray-100);

  nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;

    ul {
      list-style: none;
      padding: 0;
      margin: 0;
      display: flex;
      flex-direction: column;
      gap: var(--space-xs);
      width: 100%;
    }

    li {
      background: transparent;
      text-align: center;
      padding: var(--space-sm);
      border-radius: var(--radius-md);
      transition: all 0.2s ease;
      cursor: pointer;
      position: relative;

      div {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-xs);
      }

      p {
        white-space: nowrap;
        font-size: 0.6875rem;
        font-weight: 600;
        letter-spacing: 0.01em;
        margin: 0;
        font-family: var(--font-body);
        color: var(--text-muted);
        opacity: 0;
        max-height: 0;
        overflow: hidden;
        transition:
          opacity 0.2s ease,
          max-height 0.2s ease;
      }

      img {
        margin: 0;
        width: 2.5rem;
        height: 2.5rem;
        display: block;
        opacity: 0.7;
        transition: opacity 0.2s ease;
      }
    }

    li:hover {
      background: var(--hover-bg);

      p {
        color: var(--text-color);
        opacity: 1;
        max-height: 2rem;
      }

      img {
        opacity: 1;
      }
    }

    .active {
      background: var(--primary-pale);

      p {
        color: var(--primary-dark);
        font-weight: 600;
        opacity: 1;
        max-height: 2rem;
      }

      img {
        opacity: 1;
      }
    }
  }
}

/* Webkit scrollbar for sidebar */
header.menu::-webkit-scrollbar {
  width: 6px;
}

header.menu::-webkit-scrollbar-track {
  background: var(--gray-100);
}

header.menu::-webkit-scrollbar-thumb {
  background: var(--primary-light);
  border-radius: 3px;
}

header.menu::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

header.user {
  padding: 0.5rem 1rem;
  justify-content: space-between;
  background: var(--primary-pale);
  color: var(--gray-900);
  font-weight: 500;
  font-size: 0.8125rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  border-bottom: 1px solid var(--primary);

  div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    min-width: 0;
  }

  span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    max-width: 200px;
  }

  icon {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    flex-shrink: 0;
  }

  icon:hover {
    background: var(--gray-100);
  }

  button {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.75rem;
    background: transparent;
    color: var(--gray-700);
    border: 1px solid var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
  }

  button:hover {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
  }
}

#all-form {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
  padding: var(--space-xl) 0;

  div {
    min-width: 160px;
    background: var(--surface-color);
    text-align: center;
    padding: var(--space-xl);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-color);
  }

  div:hover {
    background: var(--surface-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--primary);
  }

  img {
    margin: 0 auto var(--space-md) auto;
    width: 4rem;
    height: 4rem;
    display: block;
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  font-family: var(--font-body);
  background: var(--footer-bg);
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-dark);
  color: var(--gray-400);
  gap: var(--space-md);

  a {
    color: var(--cream);
    text-decoration: none;
    transition: color 0.2s ease;
  }

  a:hover {
    color: var(--primary-light);
  }

  button {
    font-family: var(--font-body);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: var(--space-xs) var(--space-sm);
    background: transparent;
    color: var(--cream);
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
  }

  button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
  }
}

/* ==========================================================================
   Forms
   ========================================================================== */

hr {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-xl) 0;
}

form {
  padding: var(--space-xl);
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);

  .form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-lg);
  }
}

fieldset {
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: var(--space-lg);

  legend {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-color);
    margin-right: var(--space-md);
    margin-bottom: var(--space-sm);
  }
}

label {
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-color);
  gap: var(--space-sm);
}

label:has(input:required) span::after,
label:has(textarea:required) span::after,
label:has(select:required) span::after {
  content: ' *';
  color: var(--required-color);
}

fieldset:has(input:required) legend::after,
fieldset:has(select:required) legend::after,
fieldset:has(textarea:required) legend::after {
  content: ' *';
  color: var(--required-color);
}

label:has(input[type='radio']),
label:has(input[type='checkbox']) {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
}

label p {
  font-weight: 400;
  font-size: 0.875rem;
  font-family: var(--font-body);
  margin-top: var(--space-xs);
  margin-bottom: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

input[type='text'],
input[type='email'],
input[type='password'],
textarea,
select {
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: var(--font-body);
  background: var(--white);
  transition: all 0.2s ease;
  color: var(--text-color);
}

input[type='text']:focus,
input[type='email']:focus,
input[type='password']:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}

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

/* ==========================================================================
   Buttons
   ========================================================================== */

button {
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: var(--radius-md);
}

button.action {
  background: var(--white);
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: var(--space-md) var(--space-xl);
  font-size: 0.9375rem;
  box-shadow: var(--shadow-sm);
}

button.action:hover {
  background: var(--primary-pale);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

button[type='submit'] {
  background: var(--submit-button-color);
  color: var(--white);
  border: none;
  padding: var(--space-md) var(--space-2xl);
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
  width: 100%;
  margin-top: var(--space-lg);
}

button[type='submit']:hover {
  background: var(--submit-button-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Add Item Buttons */
button.add-mine {
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 0.125rem;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.6875rem;
  width: 100%;
  white-space: nowrap;

  .text-icon {
    margin: 0;
    padding: 0;
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1;
  }
}

button.add-mine:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

/* Filter Buttons */
.filter-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--surface-color);
  box-shadow: var(--shadow-sm);
}

.filter-buttons button {
  font-family: var(--font-body);
  font-size: 0.625rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--white);
  width: 100%;
  transition: all 0.2s ease;
  line-height: 1.2;
  white-space: nowrap;
}

.filter-buttons button:hover {
  background: var(--hover-bg);
  border-color: var(--border-medium);
}

.filter-buttons button.active {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

icon.warning {
  color: var(--banned-color);
}

/* ==========================================================================
   Tables
   ========================================================================== */

table {
  table-layout: auto;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: var(--space-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  box-shadow: var(--shadow-md);
  background: var(--white);
  overflow: visible;
}

th,
td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

th:last-child,
td:last-child {
  border-right: none;
}

td.empty {
  background: var(--table-row-background-color-disabled);
  text-align: center;
  font-family: var(--font-body);
  font-weight: 500;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

th {
  font-weight: 600;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--gray-700);
}

span.user-banned {
  color: var(--banned-color);
  font-weight: 600;
}

thead {
  background: var(--table-head-background-color);
  color: var(--table-head-text-color);

  th {
    border-bottom: 2px solid var(--primary);
    font-weight: 600;
    letter-spacing: 0.01em;
  }
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr.odd {
  background: var(--table-row-background-color-odd);
}

tbody tr.even {
  background: var(--table-row-background-color-even);
}

tbody tr:hover {
  background: var(--table-row-background-color-hover);
}

tbody tr:last-child td {
  border-bottom: none;
}

thead th:first-child,
tbody th:first-child {
  width: 1%;
  white-space: nowrap;
}

/* Sticky Column Header */
thead th {
  position: -webkit-sticky; /* Safari */
  position: sticky;
  z-index: 20;
  background: var(--table-head-background-color);
  /* Account for container padding so we stick at the top*/
  top: calc(-1 * var(--space-xl));
}

/* Sticky Row Header */
thead th:first-child {
  left: 0;
  z-index: 30;
}

tbody th {
  position: -webkit-sticky; /* Safari */
  position: sticky;
  left: 0;
  z-index: 10;
  border-right: 1px solid var(--border-color);
  background: var(--table-row-head-background-color);
  text-align: center;
  font-weight: 600;
}

/* Table Search */
.table-search {
  margin-bottom: var(--space-md);
}

.table-search input {
  width: 100%;
  max-width: 400px;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-body);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.table-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}

.table-search input::placeholder {
  color: var(--text-light);
}

/* Column Header Filter */
.th-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  position: relative;
}

/* Sort Indicators */
thead th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease;
}

thead th:hover {
  background: var(--gray-200);
}

.sort-indicator {
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.sort-indicator.sorted {
  opacity: 1;
}

thead th:hover .sort-indicator {
  opacity: 1;
}

/* Filter Icons */
.filter-icon {
  opacity: 0.6;
  transition: all 0.2s ease;
  padding: var(--space-xs);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.filter-icon.active {
  opacity: 1;
  background: var(--primary-pale);
}

.filter-icon:hover {
  opacity: 1;
  background: var(--gray-200);
}

.column-filter-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  text-align: left;
  font-weight: normal;
  color: var(--text-color);
  font-family: var(--font-body);
  font-size: 0.875rem;
}

.column-filter-dropdown.open {
  display: block;
}

.column-filter-dropdown .dropdown-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm);
  cursor: pointer;
  font-weight: normal;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.column-filter-dropdown .dropdown-option:hover {
  background: var(--hover-bg);
}

.column-filter-dropdown .dropdown-option input[type='checkbox'] {
  margin: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Reset Button in Table Header */
th.reset-col {
  text-align: center;
  width: 60px;
}

th.reset-col icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: all 0.2s ease;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
}

th.reset-col icon:hover {
  opacity: 1;
  background: var(--gray-200);
}

th.reset-col icon.hidden {
  display: none;
}

th.col-shrink {
  width: 1%;
  white-space: nowrap;
}

/* ==========================================================================
   Dialogs & Modals
   ========================================================================== */

dialog[open] {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: var(--overlay-bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;

  div {
    background: var(--white);
    padding: var(--space-3xl);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    min-width: 500px;
    max-width: 600px;

    h3 {
      margin-top: 0;
      color: var(--text-color);
    }
  }

  .dialog-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-xl);

    button {
      font-family: var(--font-body);
      font-weight: 600;
      padding: var(--space-md) var(--space-lg);
      cursor: pointer;
      font-size: 0.9375rem;
      border: 1px solid var(--border-color);
      border-radius: var(--radius-md);
      transition: all 0.2s ease;
    }

    button[type='button']:nth-child(1) {
      background: var(--gray-100);
      color: var(--text-color);
    }

    button[type='button']:nth-child(1):hover {
      background: var(--gray-200);
    }

    button[type='button']:nth-child(2) {
      background: var(--danger-color);
      color: var(--white);
      border-color: var(--danger-color);
    }

    button[type='button']:nth-child(2):hover {
      background: var(--danger-hover);
      border-color: var(--danger-hover);
    }

    button[type='button']:nth-child(3) {
      background: var(--white);
      border: 1px solid var(--border-color);
    }

    button[type='button']:nth-child(3):hover {
      background: var(--gray-50);
    }
  }
}

/* File Modal */
.file-modal[open] {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: var(--overlay-bg-dark);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.file-modal[open] .modal-content {
  background: var(--white);
  padding: var(--space-2xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.file-modal[open] .modal-close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  background: var(--gray-900);
  color: var(--white);
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.file-modal[open] .modal-close:hover {
  background: var(--gray-700);
}

.file-modal[open] .modal-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   Alerts & Errors
   ========================================================================== */

alerts {
  position: fixed;
  right: var(--space-2xl);
  bottom: var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  z-index: 2000;

  div {
    opacity: 0;
    transform: translateY(10px);
    animation: alert-in 0.3s ease forwards;
  }

  div.is-removing {
    animation: alert-out 0.2s ease forwards;
  }
}

.error {
  padding: var(--space-md) var(--space-lg);
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
  border-left: 4px solid var(--danger-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 320px;
  max-width: 420px;
  margin: 0 auto;
  font-family: var(--font-body);
  font-weight: 500;

  span {
    flex: 1;
  }

  icon {
    font-size: 1.125rem;
    align-self: flex-start;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
  }

  icon:hover {
    background: var(--error-text);
    color: var(--white);
  }
}

@keyframes alert-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes alert-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ==========================================================================
   File Gallery
   ========================================================================== */

file-gallery {
  display: block;
  padding: var(--space-xl) 0;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-xl);
  padding: var(--space-xl) 0;
}

file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface-color);
  transition: all 0.3s ease;
}

file-item:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--primary);
}

.file-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  background: var(--gray-100);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}

.thumbnail-button {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: none;
  border: none;
}

.thumbnail-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-icon-thumbnail {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--gray-100);
  font-size: 2.5rem;
  color: var(--text-muted);
}

.file-info {
  text-align: center;
  width: 100%;
  word-break: break-word;
}

.file-name {
  font-weight: 600;
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--text-color);
  margin-bottom: var(--space-xs);
  line-height: 1.4;
}

.file-size {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.file-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-color);
  text-decoration: none;
}

.action-icon:hover {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
}

.action-icon.delete-button {
  color: var(--banned-color);
  border-color: var(--border-color);
}

.action-icon.delete-button:hover {
  background: var(--banned-color);
  color: var(--white);
  border-color: var(--banned-color);
}

file-upload {
  display: block;
  margin-top: var(--space-xl);
}

file-upload form {
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
}

.drop-zone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 5rem;
  border: 2px dashed var(--shade-3);
  border-radius: var(--br);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background-color 0.15s;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background-color: var(--primary-pale);
}

.htmx-request .drop-zone-text {
  display: none;
}
.htmx-request .drop-zone-spinner {
  display: inline !important;
}

file-upload button[type='submit'] {
  display: none;
}

/* ==========================================================================
   Contact Info
   ========================================================================== */

.contact-info {
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  width: fit-content;
  background: var(--surface-color);
  font-family: var(--font-body);
  margin: var(--space-2xl) auto;

  ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  li {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-color);
  }

  li:last-child {
    border-bottom: none;
  }
}

/* ==========================================================================
   TOS
   ========================================================================== */

div.tos {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface-color);
  padding: var(--space-xl);
  margin: var(--space-xl) 0;
  font-size: 0.9375rem;
  line-height: 1.7;
}

/* ==========================================================================
   Video
   ========================================================================== */

.video-container {
  text-align: center;
  margin: var(--space-3xl) 0;

  video {
    max-width: 100%;
    height: auto;
  }

  p {
    max-width: 640px;
    margin: var(--space-lg) auto 0 auto;
    text-align: left;
    line-height: 1.6;
    color: var(--text-muted);
  }
}

/* Intro Video Toggle */
div.center {
  text-align: center;
  margin: var(--space-2xl) 0;
}

.intro-video-toggle {
  display: inline-block;
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  padding: var(--space-md) var(--space-xl);
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  background: var(--white);
  transition: all 0.2s ease;
  cursor: pointer;
}

.intro-video-toggle:hover {
  background: var(--primary-pale);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.collapsible {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease-in-out;
  margin-top: 0;
}

.collapsible.expanded {
  max-height: 1000px;
  margin-top: var(--space-lg);
}

/* ==========================================================================
   Badges & Notices
   ========================================================================== */

.badge-expired {
  display: inline-block;
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid var(--error-border);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: var(--space-sm);
  vertical-align: middle;
}

.notice-info {
  background: var(--primary-pale);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  color: var(--primary-dark);
  font-weight: 500;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Mobile Landscape - Compact sidebar when height is limited */
@media (max-width: 900px) and (max-height: 600px) {
  header.menu {
    padding: var(--space-xs);
  }

  header.menu nav li {
    padding: var(--space-xs);
  }

  header.menu nav li img {
    width: 2rem;
    height: 2rem;
  }

  header.menu nav li p {
    font-size: 0.625rem;
  }

  button.add-mine {
    padding: var(--space-xs);
    font-size: 0.625rem;
  }

  button.add-mine .text-icon {
    font-size: 1.25rem;
  }

  .filter-buttons {
    padding: var(--space-xs);
    gap: 0.125rem;
  }

  .filter-buttons button {
    padding: 0.125rem var(--space-xs);
    font-size: 0.5625rem;
  }

  footer {
    padding: var(--space-xs) var(--space-md);
    font-size: 0.75rem;
    gap: var(--space-xs);
  }

  footer button {
    font-size: 0.6875rem;
    padding: 0.125rem var(--space-xs);
  }
}

/* Collapse sidebar to horizontal nav on smaller screens */
@media (max-width: 1024px) {
  #app-container:has(> header.menu) {
    grid-template-areas:
      'header'
      'sidebar'
      'main'
      'footer';
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }

  header.menu {
    width: auto;
    min-width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-md);
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
  }

  header.menu nav {
    flex: none;
  }

  header.menu nav ul {
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
    width: auto;
  }

  header.menu nav li {
    padding: var(--space-sm);
    min-width: 70px;
  }

  header.menu nav li img {
    width: 2rem;
    height: 2rem;
  }

  header.menu nav li p {
    font-size: 0.6875rem;
  }
}

@media (max-width: 768px) {
  :root {
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
    --space-3xl: 2.5rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.75rem;
    padding: var(--space-xl) 0;
  }

  h3 {
    font-size: 1.375rem;
  }

  main {
    padding: var(--space-xl) var(--space-md);
  }

  form {
    max-width: 100%;
    padding: var(--space-xl);

    .form-grid {
      grid-template-columns: 1fr;
      gap: var(--space-lg);
    }
  }

  header.user {
    flex-direction: row;
    padding: var(--space-md) var(--space-lg);
    font-size: 0.875rem;
  }

  .filter-buttons {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .filter-buttons button {
    flex: 1;
    min-width: 70px;
  }

  button.add-mine {
    width: 100%;
  }

  table {
    font-size: 0.875rem;
    margin-top: var(--space-md);
  }

  th,
  td {
    padding: var(--space-sm) var(--space-md);
  }

  .table-search input {
    max-width: 100%;
  }

  dialog[open] div {
    min-width: auto;
    max-width: 90vw;
    padding: var(--space-xl);
  }

  #all-form {
    gap: var(--space-md);
    padding: var(--space-lg) 0;
  }

  #all-form div {
    min-width: 140px;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-lg);
  }

  .file-thumbnail {
    width: 140px;
    height: 140px;
  }

  alerts {
    right: var(--space-md);
    bottom: var(--space-md);
    left: var(--space-md);
  }

  .error {
    min-width: auto;
    max-width: 100%;
  }
}

/* Truncated text tooltip */
.tooltip {
  position: relative;
  cursor: default;
}

.tooltip::after {
  content: attr(data-full-text);
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 100;
  max-width: 360px;
  padding: var(--space-xs) var(--space-sm);
  background: var(--gray-900);
  color: var(--white);
  font-size: var(--text-sm);
  line-height: 1.4;
  border-radius: var(--radius-sm);
  white-space: pre-line;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateY(0);
}
