/* ===== CSS RESET & BASE STYLES ===== */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
      line-height: 1.5;
      background: #f8fafc;
      color: #1a1a1a;
    }

    /* ===== HEADER STYLES ===== */
    header {
      background: #ffffff;
      border-bottom: 1px solid #e5e7eb;
      padding: 24px;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    header h1 {
      font-size: 28px;
      font-weight: 700;
      color: #1a1a1a;
      max-width: 1400px;
      margin: 0 auto;
    }

    /* ===== MAIN LAYOUT ===== */
    main {
      padding: 24px;
      min-height: calc(100vh - 100px);
    }

    /* ===== LOADING STATE ===== */
    .loading {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      min-height: 400px;
      gap: 16px;
    }

    .loading.hidden {
      display: none;
    }

    .spinner {
      width: 40px;
      height: 40px;
      border: 4px solid #e0e7ff;
      border-top-color: #4f46e5;
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    .loading p {
      color: #666;
      font-size: 14px;
    }

    /* ===== ERROR STATE ===== */
    .error {
      max-width: 600px;
      margin: 40px auto;
      padding: 20px;
      background: #fef2f2;
      border: 1px solid #fecaca;
      border-radius: 12px;
      text-align: center;
    }

    .error.hidden {
      display: none;
    }

    .error-message {
      color: #991b1b;
      font-size: 14px;
    }

    /* ===== BOOKMARKS GRID ===== */
    .bookmarks-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
      gap: 22px;
      max-width: 1400px;
      margin: 0 auto;
    }

    .bookmarks-grid.hidden {
      display: none;
    }

    /* ===== EMPTY STATE ===== */
    .empty-state {
      grid-column: 1 / -1;
      text-align: center;
      padding: 80px 20px;
      color: #666;
      font-size: 16px;
    }

    /* ===== BOOKMARK CARD ===== */
    .bookmark-card {
      background: #ffffff;
      border-radius: 5px;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      overflow: hidden;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
      display: flex;
      flex-direction: column;
      position: relative;
    }

    .bookmark-card.clickable {
      cursor: pointer;
    }

    .bookmark-card.clickable:hover {
      transform: translateY(-4px);
      box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    }

    .bookmark-card:not(.clickable) {
      cursor: default;
    }

    /* ===== CARD IMAGE ===== */
    .card-image-container {
      width: 100%;
      height: 200px;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      position: relative;
      overflow: hidden;
    }

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

    /* ===== CARD CONTENT ===== */
    .card-content {
      padding: 16px;
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .card-title {
      font-size: 18px;
      font-weight: 600;
      margin: 0 0 4px 0;
      color: #1a1a1a;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      line-height: 1.4;
    }

    .card-domain {
      font-size: 12px;
      color: #666;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .card-domain::before {
      content: '🔗';
      font-size: 11px;
    }

    /* ===== CARD TAGS ===== */
    .card-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
      margin-top: 4px;
    }

    .tag-badge {
      display: inline-block;
      padding: 4px 10px;
      background: #e0e7ff;
      color: #4f46e5;
      border-radius: 5px;
      font-size: 11px;
      font-weight: 500;
      white-space: nowrap;
    }

    /* ===== CARD DATE ===== */
    .card-date {
      font-size: 12px;
      color: #999;
      margin-top: auto;
      padding-top: 8px;
    }

    /* ===== CARD LOADING OVERLAY ===== */
    .card-loading-overlay {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(255, 255, 255, 0.9);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10;
      border-radius: 12px;
    }

    .card-loading-overlay .spinner {
      width: 32px;
      height: 32px;
      border-width: 3px;
    }

    /* ===== TOAST NOTIFICATIONS ===== */
    .toast {
      position: fixed;
      bottom: 24px;
      right: 24px;
      background: #991b1b;
      color: #ffffff;
      padding: 16px 24px;
      border-radius: 8px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      font-size: 14px;
      z-index: 1000;
      animation: slideIn 0.3s ease;
    }

    @keyframes slideIn {
      from {
        transform: translateX(400px);
        opacity: 0;
      }
      to {
        transform: translateX(0);
        opacity: 1;
      }
    }

    /* ===== SEARCH BAR ===== */
    .search-container {
      max-width: 1400px;
      margin: 0 auto 24px auto;
    }

    .tag-row {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 12px;
    }

    .tag-row.hidden {
      display: none;
    }

    .tag-pill {
      border: 1px solid #e5e7eb;
      background: #ffffff;
      color: #374151;
      border-radius: 5px;
      padding: 6px 12px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.1s ease;
    }

    .tag-pill:hover {
      border-color: #4f46e5;
      color: #4f46e5;
      background: #eef2ff;
    }

    .tag-pill:active {
      transform: scale(0.98);
    }

    .tag-pill.selected {
      background: #4f46e5;
      border-color: #4f46e5;
      color: #ffffff;
    }

    .search-input-wrapper {
      position: relative;
      width: 100%;
    }

    .search-input {
      width: 100%;
      padding: 12px 40px 12px 16px;
      font-size: 14px;
      border: 1px solid #e5e7eb;
      border-radius: 8px;
      background: #ffffff;
      color: #1a1a1a;
      outline: none;
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .search-input:focus {
      border-color: #4f46e5;
      box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    }

    .search-input::placeholder {
      color: #9ca3af;
    }

    .search-clear-btn {
      position: absolute;
      right: 8px;
      top: 50%;
      transform: translateY(-50%);
      width: 24px;
      height: 24px;
      border: none;
      background: transparent;
      color: #9ca3af;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 4px;
      transition: color 0.2s ease, background 0.2s ease;
    }

    .search-clear-btn:hover {
      color: #6b7280;
      background: #f3f4f6;
    }

    .search-clear-btn.hidden {
      display: none;
    }

    /* ===== MODAL STYLES ===== */
    .modal-backdrop {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.6);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 2000;
      padding: 20px;
      animation: fadeIn 0.2s ease;
    }

    .modal-backdrop.hidden {
      display: none;
    }

    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }

    .modal-container {
      background: #ffffff;
      border-radius: 16px;
      max-width: 700px;
      width: 100%;
      max-height: 90vh;
      overflow: hidden;
      position: relative;
      box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
      animation: slideUp 0.2s ease;
    }

    @keyframes slideUp {
      from {
        transform: translateY(20px);
        opacity: 0;
      }
      to {
        transform: translateY(0);
        opacity: 1;
      }
    }

    .modal-close-btn {
      position: absolute;
      top: 16px;
      right: 16px;
      width: 36px;
      height: 36px;
      border: none;
      background: rgba(255, 255, 255, 0.9);
      border-radius: 50%;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 10;
      transition: background 0.2s ease, transform 0.2s ease;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    .modal-close-btn:hover {
      background: #ffffff;
      transform: scale(1.1);
    }

    .modal-close-btn svg {
      color: #1a1a1a;
    }

    .modal-scroll-content {
      max-height: 90vh;
      overflow-y: auto;
    }

    .modal-image-section {
      width: 100%;
      max-height: 300px;
      overflow: hidden;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    .modal-image-section.hidden {
      display: none;
    }

    .modal-image {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .modal-body {
      padding: 24px;
    }

    .modal-title {
      font-size: 24px;
      font-weight: 700;
      color: #1a1a1a;
      margin: 0 0 12px 0;
      line-height: 1.3;
    }

    .modal-meta {
      display: flex;
      flex-wrap: wrap;
      gap: 12px;
      margin-bottom: 16px;
      font-size: 13px;
      color: #666;
    }

    .modal-domain {
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .modal-domain::before {
      content: '🔗';
      font-size: 12px;
    }

    .modal-domain.hidden {
      display: none;
    }

    .modal-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 16px;
    }

    .modal-tags.hidden {
      display: none;
    }

    .modal-tags .tag-badge {
      padding: 6px 12px;
      font-size: 12px;
    }

    .modal-section {
      margin-bottom: 20px;
      padding-bottom: 20px;
      border-bottom: 1px solid #e5e7eb;
    }

    .modal-section:last-child {
      border-bottom: none;
      margin-bottom: 0;
      padding-bottom: 0;
    }

    .modal-section-title {
      font-size: 12px;
      font-weight: 600;
      color: #666;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      margin-bottom: 8px;
    }

    .modal-section-content {
      font-size: 14px;
      line-height: 1.6;
      color: #1a1a1a;
    }

    .modal-description,
    .modal-summary,
    .modal-note,
    .modal-text-content,
    .modal-asset-info,
    .modal-metadata {
      margin-bottom: 20px;
    }

    .modal-description.hidden,
    .modal-summary.hidden,
    .modal-note.hidden,
    .modal-text-content.hidden,
    .modal-asset-info.hidden,
    .modal-metadata.hidden,
    .modal-available-assets.hidden {
      display: none;
    }

    .modal-note .modal-section-content {
      background: #fef3c7;
      padding: 12px;
      border-radius: 8px;
      border-left: 4px solid #f59e0b;
    }

    .modal-text-content .modal-section-content {
      white-space: pre-wrap;
      background: #f8fafc;
      padding: 12px;
      border-radius: 8px;
    }

    .modal-metadata-grid {
      display: grid;
      grid-template-columns: auto 1fr;
      gap: 8px 16px;
      font-size: 13px;
    }

    .modal-metadata-label {
      color: #666;
      font-weight: 500;
    }

    .modal-metadata-value {
      color: #1a1a1a;
    }

    .modal-asset-buttons {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 8px;
      align-items: flex-start;
      align-content: flex-start;
    }

    .modal-asset-btn {
      padding: 8px 16px;
      border: 1px solid #e5e7eb;
      border-radius: 6px;
      font-size: 13px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      background: #ffffff;
      color: #1a1a1a;
      flex: 0 0 auto;
      vertical-align: top;
      min-height: 0;
      max-height: 40px;
    }

    .modal-asset-btn:hover {
      background: #f8fafc;
      border-color: #4f46e5;
      color: #4f46e5;
    }

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

    .modal-asset-btn.loading {
      opacity: 0.6;
      cursor: not-allowed;
    }

    .modal-asset-btn:disabled {
      background: #ffffff;
      color: #1a1a1a;
      border: 1px solid #e5e7eb;
      display: inline-flex;
      align-items: center;
      gap: 6px;
      cursor: not-allowed;
      pointer-events: none;
      flex: 0 0 auto;
      vertical-align: top;
      min-height: 0;
      max-height: 40px;
      padding: 8px 16px;
      border-radius: 6px;
      font-size: 13px;
      font-weight: 500;
    }

    .modal-actions {
      display: flex;
      gap: 12px;
      margin-top: 24px;
      padding-top: 20px;
      border-top: 1px solid #e5e7eb;
    }

    .modal-actions.hidden {
      display: none;
    }

    .modal-action-btn {
      flex: 1;
      padding: 12px 20px;
      border: none;
      border-radius: 8px;
      font-size: 14px;
      font-weight: 600;
      cursor: pointer;
      transition: background 0.2s ease, transform 0.1s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
    }

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

    .modal-action-btn.primary {
      background: #4f46e5;
      color: #ffffff;
    }

    .modal-action-btn.primary:hover {
      background: #4338ca;
    }

    .modal-action-btn.secondary {
      background: #f3f4f6;
      color: #1a1a1a;
    }

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

    .modal-action-btn:disabled {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      cursor: not-allowed;
      pointer-events: none;
      flex-grow: 0;
      height: auto;
    }

    /* ===== RESPONSIVE DESIGN ===== */
    @media (max-width: 640px) {
      header h1 {
        font-size: 24px;
      }

      main {
        padding: 16px;
      }

      .search-container {
        margin-bottom: 16px;
      }

      .bookmarks-grid {
        gap: 16px;
      }

      .card-title {
        font-size: 16px;
      }

      .modal-backdrop {
        padding: 0;
      }

      .modal-container {
        max-height: 100vh;
        border-radius: 0;
      }

      .modal-body {
        padding: 20px;
      }

      .modal-title {
        font-size: 20px;
      }

      .modal-actions {
        flex-direction: column;
      }
    }
