/* ============================================
   CSS Custom Properties (Theme)
   ============================================ */
:root {
  --color-primary: #90C695;
  --color-primary-dark: #5a9c68;
  --color-primary-light: #a8d4ad;
  --color-primary-bg: #e8f5e9;
  --color-text: #2c4f3e;
  --color-text-light: #3d5c4d;
  --color-text-muted: #5a7d6a;
  --color-bg: #f5f8f5;
  --color-white: #ffffff;
  --color-gray-50: #fafafa;
  --color-gray-100: #f3f4f3;
  --color-gray-200: #e5e7e5;
  --color-gray-300: #d1d5d2;
  --color-gray-400: #9ca39d;
  --color-gray-500: #6b736c;
  --color-gray-600: #4a524b;
  --color-error: #e53935;
  --color-error-bg: #ffebee;
  --color-link: #1565c0;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.12);

  --radius-xs: 2px;
  --radius-sm: 3px;
  --radius-md: 5px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --navbar-height: 68px;
  --sidebar-width: 200px;

  --transition-fast: 0.1s ease;
  --transition-base: 0.15s ease;
  --transition-slow: 0.25s ease;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3 {
  line-height: 1.25;
  font-weight: 700;
  color: var(--color-text);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

/* ============================================
   Navbar
   ============================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--navbar-height);
  background: #90C695;
  box-shadow: var(--shadow-md);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-logo {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  text-decoration: none;
}

.navbar-logo:hover {
  text-decoration: none;
}

.navbar-logo img {
  height: 46px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.navbar-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #2c4f3e;
  line-height: 1.15;
}

.navbar-title small {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(44, 79, 62, 0.75);
}

.navbar-menu {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.navbar-link,
.admin-badge {
  padding: 0.5rem 0.85rem 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  color: var(--color-white);
  background: #3d7a4a;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--transition-base);
}

.navbar-link:hover {
  background: #2c5a38;
  text-decoration: none;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.admin-badge {
  font-weight: 700;
  background: #e67e22;
}

.admin-badge:hover {
  background: #d35400;
  text-decoration: none;
}

/* Archive Dropdown */
.archive-dropdown {
  position: relative;
}

.archive-dropdown-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  white-space: nowrap;
  cursor: pointer;
}

.archive-dropdown.is-open .archive-dropdown-btn {
  background: #d35400;
}

.archive-dropdown.is-open .chevron-icon {
  transform: rotate(180deg);
}

.chevron-icon {
  flex-shrink: 0;
  transition: transform var(--transition-base);
}

.archive-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  min-width: 140px;
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 110;
}

.archive-dropdown.is-open .archive-dropdown-menu {
  display: block;
}

.archive-dropdown-item {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  color: var(--color-text);
  white-space: nowrap;
  transition: background var(--transition-base);
}

.archive-dropdown-item:hover {
  background: #fef3e8;
  text-decoration: none;
}

.archive-dropdown-item.is-active {
  background: #fde8d4;
  font-weight: 600;
  color: #b35900;
}

.archive-dropdown-item span {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--color-text-light);
}

/* Admin Page */
.admin-page {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.admin-page-title {
  margin-bottom: 0;
}

.admin-section {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.admin-section h2 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-gray-200);
}

.admin-section.no-frame {
  background: none;
  border: none;
  padding: 0;
  box-shadow: none;
}

.admin-section.no-frame h2 {
  border-bottom: none;
  padding-bottom: 0;
}

/* Share Links */
.share-links-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
}

.share-links-section p {
  margin: 0;
  font-size: 0.85rem;
  color: #1e40af;
  line-height: 1.4;
}

.share-links-section .text-elevated {
  color: #8e44ad;
}

.share-links-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.share-copy-public {
  background: #3498db;
  border: 1px solid #2980b9;
  color: #fff;
}

.share-copy-public:hover {
  background: #2980b9;
}

.share-copy-elevated {
  background: #9b59b6;
  border: 1px solid #8e44ad;
  color: #fff;
}

.share-copy-elevated:hover {
  background: #8e44ad;
}

.share-copy-btn.is-copied {
  background: var(--color-primary);
  border-color: var(--color-primary-dark);
}

.share-passwords {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-basis: 100%;
  font-size: 0.85rem;
  padding-top: 0.5rem;
  border-top: 1px solid #bfdbfe;
}

.share-passwords-label {
  color: #1e40af;
  font-weight: 500;
}

.share-password {
  background: #fff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  font-size: 0.85rem;
  color: #1e40af;
}

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

.admin-table th,
.admin-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-gray-100);
  white-space: nowrap;
}

.admin-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table tbody tr:hover {
  background: var(--color-gray-50);
}

.admin-table tfoot td {
  border-top: 2px solid var(--color-gray-200);
  border-bottom: none;
}

.admin-table a {
  color: var(--color-primary-dark);
}

.admin-table a:hover {
  text-decoration: underline;
}

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

.admin-table .actions {
  white-space: nowrap;
}

/* Status indicators */
.status-ok {
  color: var(--color-primary-dark);
}

.status-new {
  color: #e67e22;
  font-weight: 500;
}

.status-removed {
  color: #c0392b;
  font-weight: 500;
}

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

.status-modified {
  color: #9b59b6;
  font-weight: 500;
}

.status-progress {
  color: #3498db;
  font-weight: 500;
}

.status-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 2px;
}

.status-btn:hover {
  text-decoration-style: solid;
}

/* Diff Modal */
.diff-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
}

.diff-modal.is-active {
  display: flex;
}

.diff-modal-content {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.diff-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
}

.diff-close:hover {
  color: var(--color-text);
}

.diff-title {
  font-size: 1rem;
  margin-bottom: 1rem;
  padding-right: 2rem;
}

.diff-section {
  margin-bottom: 1rem;
}

.diff-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.diff-section-title.diff-new {
  color: #e67e22;
}

.diff-section-title.diff-removed {
  color: #c0392b;
}

.diff-section-title.diff-modified {
  color: #9b59b6;
}

.diff-list {
  list-style: none;
  font-size: 0.8rem;
  max-height: 200px;
  overflow-y: auto;
  background: var(--color-gray-50);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}

.diff-list li {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--color-gray-100);
}

.diff-list li:last-child {
  border-bottom: none;
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
}

.btn-dropdown {
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  background: var(--color-gray-100);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.btn-dropdown:hover {
  background: var(--color-gray-200);
}

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 100;
  min-width: 120px;
}

.dropdown.is-open .dropdown-menu {
  display: block;
}

.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.8rem;
  color: var(--color-text);
  background: none;
  border: none;
  white-space: nowrap;
}

.dropdown-menu button:hover {
  background: var(--color-gray-100);
}

.btn-build {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--color-primary);
  color: var(--color-white);
  border: 1px solid var(--color-primary-dark);
  border-radius: var(--radius-sm);
}

.btn-build:hover {
  background: var(--color-primary-dark);
}

.btn-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
}

.btn-secondary {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--color-gray-100);
  color: var(--color-text);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
}

.btn-secondary:hover {
  background: var(--color-gray-200);
}

.btn-sync {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--color-primary);
  color: var(--color-white);
  border: 1px solid var(--color-primary-dark);
  border-radius: var(--radius-sm);
}

.btn-sync:hover {
  background: var(--color-primary-dark);
}

.btn-rebuild {
  font-weight: 600;
  background: #e67e22;
  color: var(--color-white);
  border: 1px solid #d35400;
  border-radius: var(--radius-sm);
}

.btn-rebuild:hover {
  background: #d35400;
}

.btn-danger {
  font-weight: 600;
  background: #c0392b;
  color: var(--color-white);
  border: 1px solid #a93226;
  border-radius: var(--radius-sm);
}

.btn-danger:hover {
  background: #a93226;
}

/* Clear All Section */
.clear-all-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 1.5rem;
  padding: 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
}

.clear-all-section p {
  margin: 0;
  font-size: 0.85rem;
  color: #991b1b;
  line-height: 1.4;
}

.clear-all-buttons {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.clear-all-section .btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: 1px solid var(--color-primary-dark);
}

.clear-all-section .btn-primary:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

.clear-all-section .btn-danger {
  flex-shrink: 0;
}

.btn-details {
  font-weight: 600;
  background: #3498db;
  color: #fff;
  border: 1px solid #2980b9;
  border-radius: var(--radius-sm);
}

.btn-details:hover {
  background: #2980b9;
}

/* Storage Cards */
.storage-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.storage-card {
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.storage-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.storage-card-title {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.storage-card-year {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
}

.storage-card-status {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.storage-card-status.status-ok {
  background: #d1fae5;
  color: #065f46;
}

.storage-card-status.status-new {
  background: #fed7aa;
  color: #9a3412;
}

.storage-card-status.status-modified {
  background: #e9d5ff;
  color: #6b21a8;
}

.storage-card-status.status-removed {
  background: #fecaca;
  color: #991b1b;
}

.storage-card-status.status-none {
  background: var(--color-gray-200);
  color: var(--color-text-muted);
}

.storage-card-status.status-progress {
  background: #bae6fd;
  color: #075985;
}

.storage-card-status.status-btn {
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  background: #e67e22;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  text-transform: none;
  letter-spacing: normal;
}

.storage-card-status.status-btn:hover {
  background: #d35400;
}

.storage-card-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.storage-card-stat {
  display: flex;
  flex-direction: column;
}

.storage-card-stat.is-full {
  grid-column: 1 / -1;
}

.storage-card-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
}

.storage-card-value.is-thumb {
  color: #2067b7;
}

.storage-card-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.storage-card-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-gray-100);
  margin-top: auto;
}

.storage-card-cached {
  font-size: 0.8rem;
  color: var(--color-text-light);
}

.storage-card-actions {
  display: flex;
  gap: 0.3rem;
}

.storage-card-actions .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.btn-clear {
  background: #c0392b;
  color: var(--color-white);
  border-color: #a93226;
}

.btn-clear:hover {
  background: #a93226;
}

/* Storage Totals */
.storage-totals {
  display: flex;
  justify-content: space-around;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--color-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-gray-200);
}

.storage-total {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.storage-total-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

.storage-total-value.is-thumb {
  color: #2067b7;
}

.storage-total-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.storage-warning {
  margin-top: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: var(--radius-sm);
  color: #856404;
  font-size: 0.8rem;
}

/* Details Modal */
.details-modal-content {
  max-width: 450px;
}

.details-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-gray-200);
  font-size: 0.8rem;
}

.details-summary span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.details-summary span small {
  color: var(--color-text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.details-summary strong {
  color: var(--color-text);
  font-size: 1rem;
}

.details-summary .is-thumb strong {
  color: #2067b7;
}

.details-table-wrap {
  max-height: 450px;
  overflow-y: auto;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.details-table th,
.details-table td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--color-gray-100);
}

.details-table th:nth-child(2),
.details-table th:nth-child(3),
.details-table td:nth-child(2),
.details-table td:nth-child(3) {
  text-align: right;
}

.details-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: var(--color-white);
}

.details-table code {
  font-size: 0.75rem;
  background: var(--color-gray-100);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-xs);
}

.thumb-yes {
  color: var(--color-primary-dark);
  font-weight: 700;
}

.thumb-no {
  color: #c0392b;
  font-weight: 700;
}

.details-summary .details-warning strong {
  color: #c0392b;
}

.details-name-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-gray-200);
}

.details-name-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.details-name-field input[type="text"] {
  flex: 1;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  background: var(--color-gray-50);
}

.details-name-field input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-white);
}

.storage-card-name {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.details-warning {
  color: #c0392b;
  font-weight: 600;
}

/* ============================================
   Refresh Modal
   ============================================ */
.refresh-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.refresh-modal.is-active {
  display: flex;
}

.refresh-modal-content {
  position: relative;
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 720px;
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.refresh-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  background: var(--color-gray-100);
  font-size: 1.25rem;
  line-height: 1;
  color: var(--color-gray-500);
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition-base);
}

.refresh-close:hover {
  color: var(--color-text);
  background: var(--color-gray-200);
}

.refresh-title {
  margin-bottom: 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
}

.refresh-subtitle {
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

.refresh-previews {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: flex-end;
  min-height: 180px;
  margin-bottom: 1.75rem;
}

.refresh-thumb {
  width: 64px;
  height: 64px;
  background: var(--color-gray-100);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.refresh-thumb:last-child {
  width: 160px;
  height: 160px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.refresh-info {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.refresh-progress {
  height: 10px;
  background: var(--color-gray-100);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.refresh-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  border-radius: 5px;
  transition: width var(--transition-base);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.refresh-stats {
  font-size: 1rem;
  color: var(--color-text);
  font-weight: 600;
}

/* ============================================
   Sort Order Section
   ============================================ */
.sort-order-section {
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-md);
}

.sort-order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.sort-order-title {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.sort-order-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

.sort-order-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.sort-order-status {
  font-size: 0.75rem;
  font-weight: 500;
}

.sort-order-status.is-dirty {
  color: #e67e22;
}

.sort-order-status.is-saved {
  color: var(--color-primary-dark);
}

.sort-order-content {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.sort-list-wrap {
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
}

.sort-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-gray-100);
  cursor: grab;
  user-select: none;
  font-size: 0.85rem;
}

.sort-item:last-child {
  border-bottom: none;
}

.sort-item:hover {
  background: var(--color-gray-50);
}

.sort-item.is-dragging {
  opacity: 0.4;
}

.sort-item.is-new {
  background: #fef3e8;
}

.sort-handle {
  color: var(--color-gray-400);
  font-size: 0.9rem;
  cursor: grab;
  flex-shrink: 0;
}

.sort-index {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.sort-name {
  flex: 1;
  color: var(--color-text);
}

.sort-new-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  background: #e67e22;
  color: #fff;
  border-radius: 3px;
  flex-shrink: 0;
}

.sort-matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
  max-height: 600px;
  overflow-y: auto;
}

.sort-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  white-space: nowrap;
}

.sort-matrix th,
.sort-matrix td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--color-gray-100);
  text-align: center;
}

.sort-matrix thead th {
  position: sticky;
  top: 0;
  background: var(--color-gray-50);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  border-bottom: 2px solid var(--color-gray-200);
}

.sort-matrix thead th small {
  display: block;
  font-weight: 400;
  text-transform: none;
  font-size: 0.6rem;
  color: var(--color-gray-400);
}

.sort-matrix-folder-col {
  text-align: left !important;
  min-width: 120px;
}

.sort-matrix-folder {
  text-align: left;
  font-weight: 500;
  color: var(--color-text);
}

.sort-matrix-year-col {
  min-width: 55px;
}

.sort-matrix-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
}

@media (max-width: 900px) {
  .sort-order-content {
    grid-template-columns: 1fr;
  }

  .sort-order-header {
    flex-direction: column;
  }
}

/* Generation screen (initial load without cache) */
.generation-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem;
}

.generation-content {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: 3rem;
  width: 100%;
  max-width: 720px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.generation-title {
  margin-bottom: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.generation-subtitle {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  color: var(--color-text-muted);
}

/* ============================================
   Navbar Burger (Mobile)
   ============================================ */
.navbar-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-base);
}

.navbar-burger:hover {
  background: rgba(0,0,0,0.1);
}

.navbar-burger span {
  display: block;
  height: 2px;
  background: #2c4f3e;
  border-radius: 2px;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.navbar-burger.is-active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.navbar-burger.is-active span:nth-child(2) {
  opacity: 0;
}

.navbar-burger.is-active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 768px) {
  .navbar-burger {
    display: flex;
    order: 3;
  }

  .navbar-menu {
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: #7ab583;
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    display: none;
  }

  .navbar-menu.is-active {
    display: flex;
  }

  .navbar-actions {
    margin-left: auto;
    order: 2;
    gap: 0.4rem;
  }

  .navbar-actions .navbar-logout,
  .navbar-actions .admin-badge {
    padding: 0.35rem 0.6rem;
    font-size: 0.7rem;
  }
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  flex: 1;
  margin-top: var(--navbar-height);
  padding: 1.5rem;
  min-height: calc(100vh - var(--navbar-height) - 120px);
}

/* ============================================
   Login Page
   ============================================ */
.login-container {
  max-width: 420px;
  margin: 3rem auto;
}

.login-form {
  background: var(--color-white);
  padding: 3rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  height: 110px;
  width: auto;
  margin: 0 auto;
}

.login-title {
  text-align: center;
  margin-bottom: 0.75rem;
  font-size: 1.5rem;
}

.login-description {
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  text-align: center;
  font-size: 1rem;
}

.form-field {
  margin-bottom: 1.75rem;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--color-gray-400);
  pointer-events: none;
}

.form-input {
  width: 100%;
  padding: 1rem 1rem 1rem 3rem;
  font-size: 1rem;
  border: 2px solid var(--color-gray-200);
  border-radius: var(--radius-md);
  background: var(--color-gray-50);
  transition: all var(--transition-base);
}

.form-input:hover {
  border-color: var(--color-gray-300);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-white);
  box-shadow: 0 0 0 4px rgba(124, 184, 130, 0.15);
}

.has-error .form-input {
  border-color: var(--color-error);
  background: var(--color-error-bg);
}

.has-error .form-input:focus {
  box-shadow: 0 0 0 4px rgba(229, 57, 53, 0.15);
}

.form-error {
  color: var(--color-error);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  font-weight: 500;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition-base);
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: #3d7a4a;
  color: var(--color-white);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: #2c5a38;
  box-shadow: var(--shadow-md);
}

.btn-primary.btn-full {
  width: 100%;
}

.btn-login {
  width: 100%;
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
}

.btn-secondary {
  background: var(--color-gray-100);
  color: var(--color-text);
  border: 1px solid var(--color-gray-200);
}

.btn-secondary:hover {
  background: var(--color-gray-200);
  border-color: var(--color-gray-300);
}

/* ============================================
   Policy Page
   ============================================ */
.policy-container {
  max-width: 640px;
  margin: 2rem auto;
  background: var(--color-white);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.policy-title {
  margin-bottom: 1.5rem;
}

.policy-text {
  margin-bottom: 1.25rem;
  line-height: 1.75;
  color: var(--color-text-light);
}

.policy-back {
  margin-top: 2rem;
}

/* ============================================
   Archive Navigation (Mobile)
   ============================================ */
.archive-nav-mobile {
  display: none;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.archive-nav-link {
  padding: 0.5rem 0.875rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  transition: all var(--transition-base);
}

.archive-nav-link:hover {
  background: var(--color-gray-100);
  text-decoration: none;
}

.archive-nav-link.is-active {
  background: #3d7a4a;
  border-color: #3d7a4a;
  color: var(--color-white);
}

@media (max-width: 900px) {
  .archive-nav-mobile {
    display: flex;
  }
}

/* ============================================
   Archive Banner
   ============================================ */
.archive-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--color-primary-dark);
}

.archive-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--color-text-muted);
}

.archive-year {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--color-text);
}

/* ============================================
   Search Bar
   ============================================ */
.search-bar {
  position: relative;
  max-width: 360px;
  margin-bottom: 1rem;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--color-gray-400);
  pointer-events: none;
  transition: color var(--transition-base);
}

.search-bar:focus-within .search-icon {
  color: var(--color-primary-dark);
}

.search-input {
  width: 100%;
  padding: 1rem 3rem 1rem 3rem;
  font-size: 1rem;
  border: 2px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  background: var(--color-white);
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-base);
}

.search-input:hover {
  border-color: var(--color-gray-300);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(124, 184, 130, 0.15);
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  font-size: 1.25rem;
  color: var(--color-gray-500);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
}

.search-clear:hover {
  background: var(--color-gray-100);
  color: var(--color-text);
}

/* ============================================
   Category Navigation (Mobile)
   ============================================ */
.category-nav-mobile {
  display: none;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.category-nav-mobile::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--color-white);
  border: 1px solid var(--color-gray-200);
  border-radius: var(--radius-lg);
  color: var(--color-text-light);
  white-space: nowrap;
  transition: all var(--transition-base);
  cursor: pointer;
}

.category-pill:hover {
  background: var(--color-gray-50);
  color: var(--color-text);
  text-decoration: none;
}

.category-pill.is-active {
  background: #3d7a4a;
  border-color: #3d7a4a;
  color: var(--color-white);
}

@media (max-width: 900px) {
  .category-nav-mobile {
    display: flex;
  }
}

/* ============================================
   Files Layout
   ============================================ */
.files-layout {
  display: flex;
  gap: 1.5rem;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  position: sticky;
  top: calc(var(--navbar-height) + 1rem);
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: fit-content;
  max-height: calc(100vh - var(--navbar-height) - 2rem);
  overflow-y: auto;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-gray-200);
}

.sidebar-header {
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-gray-200);
}

.sidebar-link {
  display: block;
  padding: 0.4rem 0.875rem;
  border-left: 3px solid transparent;
  transition: all var(--transition-base);
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.sidebar-link:hover {
  background: var(--color-gray-50);
  color: var(--color-text);
  text-decoration: none;
}

.sidebar-link.is-active {
  background: var(--color-primary-bg);
  border-left-color: var(--color-primary-dark);
  color: var(--color-text);
  font-weight: 600;
}

.sidebar-link-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}

.sidebar-divider {
  height: 1px;
  background: var(--color-gray-200);
  margin: 0.75rem 0;
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .files-layout {
    display: block;
  }
}

/* ============================================
   Files Content
   ============================================ */
.files-content {
  flex: 1;
  min-width: 0;
}

.folder-section {
  margin-bottom: 2rem;
}

.folder-title {
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--color-primary);
  display: inline-block;
}

.files-grid-wrap {
  padding-bottom: 50vh;
}

/* Search mode: flatten layout into single grid */
.files-grid-wrap.is-searching {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.files-grid-wrap.is-searching .folder-section,
.files-grid-wrap.is-searching .file-grid {
  display: contents;
}

.files-grid-wrap.is-searching .folder-title {
  display: none;
}

.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--color-text-muted);
  font-size: 1.15rem;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ============================================
   File Grid
   ============================================ */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* ============================================
   File Card
   ============================================ */
.file-card {
  height: fit-content;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-gray-200);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-slow);
  user-select: none;
}

.file-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--color-gray-300);
}

.file-card.is-hidden {
  display: none;
}

.file-thumb {
  position: relative;
  aspect-ratio: 1;
  background: rgb(240, 240, 240);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform var(--transition-slow);
}

.file-thumb img[src^="/img/"] {
  padding: 2.5rem;
  opacity: 0.5;
}

.duration-tag {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--color-white);
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.25px;
}

.file-info {
  padding: 1rem 1.125rem;
  border-top: 1px solid var(--color-gray-100);
}

.file-name {
  font-weight: 600;
  font-size: 0.875rem;
  word-break: break-word;
  line-height: 1.35;
  color: var(--color-text);
}

.file-langs {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--color-primary-dark);
  font-weight: 500;
}

/* ============================================
   Footer
   ============================================ */
.footer {
  background: var(--color-white);
  border-top: 1px solid var(--color-gray-200);
  padding: 2.5rem 2rem;
  margin-top: auto;
}

.footer-content {
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1rem;
}

.footer-links a {
  color: var(--color-text-light);
  font-weight: 500;
  transition: color var(--transition-base);
}

.footer-links a:hover {
  color: var(--color-primary-dark);
}

.footer-separator {
  color: var(--color-gray-300);
}

.footer-copyright {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  .footer-separator {
    display: none;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
  }
}

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

/* Tablet and below */
@media (max-width: 900px) {
  .search-bar {
    max-width: 100%;
  }
}

/* Mobile */
@media (max-width: 600px) {
  :root {
    --navbar-height: 60px;
  }

  .main-content {
    padding: 1.25rem 1rem;
  }

  .navbar {
    padding: 0 1rem;
  }

  .navbar-logo img {
    height: 38px;
  }

  .navbar-title {
    font-size: 1.15rem;
  }

  .navbar-title small {
    font-size: 0.7rem;
  }

  /* Category pills for mobile (non-admin) */
  .folder-section {
    margin-bottom: 2.5rem;
    scroll-margin-top: calc(var(--navbar-height) + 0.5rem);
  }

  .folder-title {
    position: sticky;
    top: var(--navbar-height);
    background: var(--color-bg);
    padding-top: 0.75rem;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
    z-index: 10;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.875rem;
  }

  .files-grid-wrap.is-searching {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.875rem;
  }

  .file-card {
    border-radius: var(--radius-md);
  }

  .file-card:active {
    box-shadow: var(--shadow-sm);
  }

  .file-info {
    padding: 0.75rem 0.875rem;
  }

  .file-name {
    font-size: 0.8rem;
  }

  .file-langs {
    font-size: 0.7rem;
  }

  /* Search mobile */
  .search-bar {
    margin-bottom: 0;
  }

  .category-nav-mobile {
    margin-bottom: 0.75rem;
  }

  .search-input {
    padding: 0.75rem 2.5rem;
    font-size: 0.9rem;
  }

  /* Modal as bottom sheet */
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin-top: auto;
  }

  .modal-header {
    padding: 1rem 1.25rem;
  }

  .modal-title {
    font-size: 1rem;
  }

  /* Download buttons scroll horizontally */
  .modal-downloads {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 1rem;
    gap: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .modal-downloads::-webkit-scrollbar {
    display: none;
  }

  .download-group {
    flex-shrink: 0;
  }

  .modal-preview {
    min-height: 0;
    flex: 1;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
  }

  /* Refresh modal mobile */
  .refresh-modal-content {
    padding: 2rem 1.25rem;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin-top: auto;
  }

  .refresh-title {
    font-size: 1.15rem;
    margin-bottom: 1.25rem;
  }

  .refresh-previews {
    min-height: 120px;
    gap: 0.5rem;
  }

  .refresh-thumb {
    width: 45px;
    height: 45px;
  }

  .refresh-thumb:last-child {
    width: 120px;
    height: 120px;
  }

  .refresh-info {
    font-size: 0.8rem;
  }

  .refresh-stats {
    font-size: 0.9rem;
  }

  /* Archive nav mobile - show for all when sidebar hidden */
  .archive-nav-mobile {
    margin-bottom: 1.25rem;
  }

  .archive-nav-link {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Footer mobile */
  .footer {
    padding: 2rem 1rem;
  }
}

/* Small phones */
@media (max-width: 380px) {
  .file-grid,
  .files-grid-wrap.is-searching {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .navbar-title small {
    display: none;
  }

  .refresh-thumb:not(:last-child) {
    display: none;
  }

  .refresh-thumb:last-child {
    width: 140px;
    height: 140px;
  }
}

/* ============================================
   Dense Grid + Full Preview Overlay
   ============================================ */

/* Dense grid - smaller cards */
.file-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.file-card {
  cursor: pointer;
  border-radius: var(--radius-md);
}

.file-info {
  padding: 0.5rem 0.625rem;
}

.file-name {
  font-size: 0.875rem;
  line-height: 1.3;
}

.file-langs {
  font-size: 0.65rem;
}

.duration-tag {
  font-size: 0.65rem;
  padding: 2px 5px;
  bottom: 6px;
  right: 6px;
}

/* Preview Modal - Classic design */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.panel-open .modal-overlay {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 94%;
  max-width: 1400px;
  height: 92vh;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

/* Green header bar */
.modal-header {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: #90C695;
  flex-shrink: 0;
}

.modal-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: #2c4f3e;
  margin: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  position: absolute;
  right: 0.5rem;
}

.modal-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: #e67e22;
  border-radius: 4px;
  color: #fff;
}

.modal-action-btn:hover {
  background: #d35400;
}

.modal-action-btn.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

.modal-action-btn.is-done,
.modal-action-btn.is-copied {
  background: #27ae60;
  color: #fff;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 1.5rem;
  line-height: 1;
  color: #2c4f3e;
  background: transparent;
  border-radius: 4px;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Downloads area - horizontal multi-tag buttons */
.modal-downloads {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #fff;
}

/* Multi-tag button group: [Language] [pdf|152KB] [docx|108KB] */
.download-group {
  display: flex;
  align-items: stretch;
  background: #3d7a4a;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.85rem;
  user-select: none;
}

.download-group-label {
  display: flex;
  align-items: center;
  padding: 0 0.625rem;
  color: #fff;
  font-weight: 500;
  background: #3d7a4a;
  cursor: default;
}


.download-group-files {
  display: flex;
}

.download-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.375rem 0.5rem;
  background: #5a9c68;
  color: #fff;
  text-decoration: none;
  line-height: 1.2;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.download-link:hover {
  background: #6FA474;
  text-decoration: none;
  color: #fff;
}

.download-link .ext {
  font-weight: 600;
  text-transform: lowercase;
}

.download-link .size {
  font-size: 0.7em;
  opacity: 0.85;
}

.download-link .external-icon {
  opacity: 0.85;
}

/* Preview area - light gray background */
.modal-preview {
  position: relative;
  flex: 1;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background-color: rgb(240, 240, 240);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  background-origin: content-box;
  overflow: hidden;
}

.modal-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-preview video {
  max-width: 100%;
  max-height: 100%;
}

/* Fallback preview indicator */
.preview-fallback-badge {
  position: absolute;
  bottom: 0.75rem;
  right: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.75rem;
  border-radius: 4px;
}

/* Preview footer — shows actual filename by default, turns red on CMYK */
.modal-footer {
  padding: 0.5rem 1rem;
  background: var(--color-gray-50);
  color: var(--color-text-muted);
  font-size: 0.8rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-footer.is-cmyk {
  /* Slightly darker than --color-error so white text passes WCAG AA (~5.4:1) */
  background: #c0392b;
  color: var(--color-white);
}

.modal-footer strong {
  margin-right: 0.25rem;
}

/* Tablet/Mobile adjustments */
@media (max-width: 900px) {
  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
  }

  .file-info {
    padding: 0.4rem 0.5rem;
  }

  .file-name {
    font-size: 0.8rem;
  }

  .modal-card {
    width: 95%;
    height: 95vh;
  }

  .modal-downloads {
    padding: 0.5rem;
    gap: 0.375rem;
  }

  .download-group {
    font-size: 0.8rem;
  }
}

@media (max-width: 600px) {
  .file-grid,
  .files-grid-wrap.is-searching {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }

  .file-card {
    border-radius: var(--radius-sm);
  }

  .file-info {
    padding: 0.35rem 0.4rem;
  }

  .file-name {
    font-size: 0.75rem;
  }

  .modal-overlay {
    padding: 0.5rem;
  }

  .modal-preview {
    min-height: 0;
    flex: 1;
  }

  .download-group {
    font-size: 0.75rem;
  }

  .download-group-label {
    padding: 0 0.5rem;
  }

  .download-link {
    padding: 0.25rem 0.4rem;
  }
}
