@import "tailwindcss";

@source "./src/**/*.{rs,html,css}";

/* ============================================================================
   Tailwind v4 Theme Configuration
   ============================================================================ */

@theme {
    /* Primary colors - Rust themed */
    --color-primary-50: #fef7f4;
    --color-primary-100: #fdeee8;
    --color-primary-200: #fbd5c5;
    --color-primary-300: #f7b299;
    --color-primary-400: #f08560;
    --color-primary-500: #b7410e;
    --color-primary-600: #9a3a0a;
    --color-primary-700: #8b3109;
    --color-primary-800: #6d2607;
    --color-primary-900: #4a1a05;

    /* Secondary/Accent colors */
    --color-accent-500: #d4621a;
    --color-accent-600: #b7410e;
    --color-accent-700: #8b3109;

    /* Surface colors */
    --color-surface-50: #fff;
    --color-surface-100: #faf8f6;
    --color-surface-200: #f5f1ed;
    --color-surface-300: #ebe7e3;
    --color-surface-400: #ddd5cc;

    /* Text colors */
    --color-text-primary: #2c2418;
    --color-text-secondary: #4a4541;
    --color-text-muted: #6b6560;
    --color-text-contrast: #1a1a1a;

    /* Semantic colors */
    --color-error-50: #fef2f2;
    --color-error-100: #fee2e2;
    --color-error-500: #c53030;
    --color-error-600: #991b1b;
    --color-error-700: #742a2a;
    --color-success-50: #f0fdf4;
    --color-success-100: #c6f6d5;
    --color-success-500: #38a169;
    --color-success-600: #22543d;
    --color-success-700: #065f46;
    --color-warning-50: #fffbeb;
    --color-warning-100: #fed7aa;
    --color-warning-500: #f59e0b;
    --color-warning-600: #92400e;
    --color-info-50: #eff6ff;
    --color-info-100: #bee3f8;
    --color-info-500: #2196f3;
    --color-info-600: #1565c0;

    /* Border color */
    --color-border: #ddd5cc;

    /* Font families */
    --font-sans: -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, sans-serif;
    --font-mono: "Courier New", courier, monospace;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgb(0 0 0 / 5%);
    --shadow-md: 0 4px 6px rgb(0 0 0 / 10%);
    --shadow-lg: 0 4px 12px rgb(0 0 0 / 15%);
    --shadow-xl: 0 20px 60px rgb(0 0 0 / 30%);
    --shadow-primary: 0 4px 8px rgb(183 65 14 / 20%);
    --shadow-primary-sm: 0 2px 8px rgb(183 65 14 / 20%);
    --shadow-focus: 0 0 0 3px rgb(183 65 14 / 10%);
    --shadow-focus-lg: 0 0 0 3px rgb(183 65 14 / 20%);

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Animations */
    --animate-spin: spin 0.8s linear infinite;
    --animate-slide-in: slidein 0.3s ease-out;
    --animate-indeterminate: indeterminate 1.5s ease-in-out infinite;
}

/* ============================================================================
   Base Layer - Element defaults
   ============================================================================ */

@layer base {
    body {
        font-family: var(--font-sans);
        background-color: var(--color-surface-200);
        color: var(--color-text-primary);
        line-height: 1.6;
    }

    a {
        color: var(--color-primary-500);
    }

    a:not(.btn, .navbar-brand, [role="menuitem"]) {
        text-decoration: underline;
        text-decoration-thickness: 1px;
        text-underline-offset: 2px;
    }

    a:not(.btn):hover {
        text-decoration-thickness: 2px;
    }

    label {
        display: block;
        font-weight: 500;
        margin-bottom: 4px;
        color: var(--color-text-contrast);
    }

    table {
        border-collapse: collapse;
    }

    th {
        text-align: left;
        font-weight: 600;
    }

    /* Focus styles */
    *:focus {
        outline: none;
    }

    *:focus-visible {
        outline: 3px solid var(--color-primary-500);
        outline-offset: 2px;
        border-radius: var(--radius-sm);
    }

    button:focus-visible,
    a:focus-visible {
        outline: 3px solid var(--color-primary-500);
        outline-offset: 2px;
        box-shadow: var(--shadow-focus-lg);
    }

    input:focus-visible,
    textarea:focus-visible,
    select:focus-visible {
        outline: 2px solid var(--color-primary-500);
        outline-offset: 1px;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    /* Form validation states */
    input[aria-invalid="true"],
    textarea[aria-invalid="true"],
    select[aria-invalid="true"] {
        border-color: var(--color-error-500);
        background: var(--color-error-50);
    }

    input[aria-invalid="true"]:focus-visible,
    textarea[aria-invalid="true"]:focus-visible,
    select[aria-invalid="true"]:focus-visible {
        outline-color: var(--color-error-500);
        box-shadow: 0 0 0 3px rgb(211 47 47 / 20%);
    }

    /* Table sort indicators */
    th[aria-sort="ascending"]::after {
        content: " \25B2";
        font-size: 0.8em;
    }

    th[aria-sort="descending"]::after {
        content: " \25BC";
        font-size: 0.8em;
    }

    /* Details/Summary */
    details {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: 12px;
        margin-bottom: 8px;
    }

    summary {
        cursor: pointer;
        font-weight: 600;
        padding: 8px;
        margin: -12px;
        border-radius: var(--radius-lg);
        transition: background-color 0.2s;
    }

    summary:hover {
        background: rgb(183 65 14 / 5%);
    }

    summary:focus-visible {
        outline: 2px solid var(--color-primary-500);
        outline-offset: 2px;
    }

    details[open] summary {
        margin-bottom: 12px;
        border-bottom: 1px solid var(--color-border);
    }

    /* Navigation list reset */
    nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    nav li {
        display: inline-block;
    }
}

/* ============================================================================
   Components Layer
   ============================================================================ */

@layer components {
    /* Navbar */
    nav a,
    nav button {
        cursor: pointer;
    }

    /* Container */
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
    }

    .page-container {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
    }

    .content-container {
        padding: 24px;
        overflow-x: hidden;
    }

    /* Page Header */
    .page-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
    }

    .page-header h1 {
        font-size: 2rem;
        font-weight: 700;
        color: var(--color-primary-500);
    }

    /* Auth Pages */
    .auth-container {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        padding: 2rem;
    }

    .auth-card {
        background-color: var(--color-surface-50);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-md);
        padding: 3rem;
        width: 100%;
        max-width: 420px;
    }

    .auth-title {
        font-size: 2rem;
        font-weight: 700;
        color: var(--color-primary-500);
        margin-bottom: 0.5rem;
        text-align: center;
    }

    .auth-subtitle {
        color: var(--color-text-secondary);
        text-align: center;
        margin-bottom: 2rem;
        font-size: 0.95rem;
    }

    /* Forms */
    .form {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .form-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .form-label {
        font-weight: 600;
        color: var(--color-text-primary);
        font-size: 0.9rem;
    }

    .form-input {
        padding: 0.75rem 1rem;
        border: 2px solid var(--color-border);
        border-radius: var(--radius-md);
        font-size: 1rem;
        transition: all 0.2s;
        background-color: var(--color-surface-50);
        color: var(--color-text-primary);
    }

    .form-input:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    .form-input::placeholder {
        color: #a0a0a0;
    }

    .form-hint {
        font-size: 0.85rem;
        color: var(--color-text-secondary);
    }

    /* Buttons */
    .btn {
        padding: 0.75rem 1.5rem;
        border: none;
        border-radius: var(--radius-md);
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        text-decoration: none;
        display: inline-block;
        text-align: center;
    }

    .btn-primary {
        padding: 10px 20px;
        background: var(--color-primary-500);
        color: white;
        border: none;
        border-radius: var(--radius-md);
        cursor: pointer;
        font-weight: 500;
        font-size: 1rem;
        transition: background 0.2s;
    }

    .btn-primary:hover:not(:disabled) {
        background-color: var(--color-accent-500);
        transform: translateY(-1px);
        box-shadow: var(--shadow-primary);
    }

    .btn-primary:active:not(:disabled) {
        transform: translateY(0);
    }

    .btn-primary:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

    .btn-secondary {
        padding: 10px 20px;
        background: #e2e8f0;
        color: var(--color-text-primary);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        cursor: pointer;
        font-weight: 500;
        font-size: 1rem;
        transition: background 0.2s;
    }

    .btn-secondary:hover:not(:disabled) {
        background: #cbd5e0;
    }

    .btn-danger {
        padding: 10px 20px;
        background: var(--color-error-500);
        color: white;
        border: none;
        border-radius: var(--radius-md);
        cursor: pointer;
        font-weight: 500;
        font-size: 1rem;
        transition: background 0.2s;
    }

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

    .btn-delete {
        padding: 10px 20px;
        background: white;
        color: var(--color-error-500);
        border: 1px solid var(--color-error-500);
        border-radius: var(--radius-md);
        cursor: pointer;
        font-weight: 500;
        font-size: 1rem;
        transition: all 0.2s;
    }

    .btn-delete:hover {
        background: var(--color-error-500);
        color: white;
    }

    .btn-success {
        color: var(--color-success-700);
        background-color: transparent;
        border: none;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .btn-success:hover {
        background-color: var(--color-success-100);
    }

    .btn-success:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .btn-full {
        width: 100%;
    }

    .btn-sm {
        padding: 6px 16px;
        font-size: 0.875rem;
    }

    .btn-icon {
        width: 32px;
        height: 32px;
        padding: 0;
        border: none;
        border-radius: var(--radius-sm);
        cursor: pointer;
        font-size: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
    }

    .btn-icon:hover {
        transform: scale(1.1);
    }

    .btn-save {
        background: var(--color-success-500);
        color: white;
    }

    .btn-save:hover {
        background: #2f855a;
    }

    .btn-cancel {
        background: var(--color-text-secondary);
        color: white;
    }

    .btn-cancel:hover {
        background: #4a5568;
    }

    .btn-add {
        background: transparent;
        color: var(--color-primary-500);
        border: 1px solid transparent;
        font-size: 20px;
        font-weight: bold;
    }

    .btn-add:hover {
        background: #FFF3E0;
        border-color: var(--color-primary-500);
    }

    .btn-refresh {
        padding: 10px 20px;
        background: var(--color-primary-500);
        color: white;
        border: none;
        border-radius: var(--radius-md);
        cursor: pointer;
        font-weight: 500;
        margin-top: 8px;
    }

    .btn-refresh:hover {
        background: var(--color-primary-600);
    }

    .btn-refresh:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .refresh-icon {
        display: inline-block;
        font-size: 1.1em;
    }

    .refresh-icon.spinning {
        animation: spin 1s linear infinite;
    }

    .btn-retry {
        padding: 6px 12px;
        background: var(--color-primary-500);
        color: white;
        border: none;
        border-radius: var(--radius-sm);
        font-size: 13px;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .btn-retry:hover {
        background: var(--color-accent-500);
    }

    .btn-dismiss {
        padding: 6px 10px;
        background: transparent;
        color: var(--color-text-muted);
        border: none;
        border-radius: var(--radius-sm);
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .btn-dismiss:hover {
        background: rgb(0 0 0 / 5%);
    }

    .btn-add-link {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 24px;
        font-size: 1rem;
        font-weight: 500;
    }

    .btn-add-link .icon {
        width: 20px;
        height: 20px;
    }

    /* Button states */
    button:disabled,
    .btn:disabled {
        cursor: not-allowed;
        opacity: 0.6;
    }

    button[aria-pressed="true"],
    .btn[aria-pressed="true"] {
        background: var(--color-accent-500);
        box-shadow: inset 0 2px 4px rgb(0 0 0 / 20%);
    }

    /* Messages */
    .message {
        padding: 0.75rem 1rem;
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
        font-size: 0.9rem;
    }

    .message-error {
        background-color: var(--color-error-100);
        color: var(--color-error-700);
        border: 1px solid #fc8181;
    }

    .message-success {
        background-color: var(--color-success-100);
        color: var(--color-success-600);
        border: 1px solid #68d391;
    }

    .message-info {
        background-color: var(--color-info-100);
        color: var(--color-info-600);
        border: 1px solid #63b3ed;
    }

    /* Loading */
    .loading {
        display: inline-block;
        width: 1rem;
        height: 1rem;
        border: 2px solid rgb(255 255 255 / 30%);
        border-radius: 50%;
        border-top-color: white;
        animation: var(--animate-spin);
        margin-right: 0.5rem;
    }

    .loading-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px;
        gap: 16px;
    }

    .loading-message {
        color: var(--color-text-primary);
        font-size: 14px;
        margin: 0;
    }

    .loading-spinner {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: var(--color-text-secondary);
    }

    .loading-spinner::before {
        content: "";
        width: 16px;
        height: 16px;
        border: 2px solid var(--color-border);
        border-top-color: var(--color-primary-500);
        border-radius: 50%;
        animation: var(--animate-spin);
    }

    /* Spinners */
    .spinner {
        border: 3px solid var(--color-surface-200);
        border-top: 3px solid var(--color-primary-500);
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    .spinner-small {
        width: 20px;
        height: 20px;
        border-width: 2px;
    }

    .spinner-medium {
        width: 40px;
        height: 40px;
    }

    .spinner-large {
        width: 60px;
        height: 60px;
        border-width: 4px;
    }

    .spinner-inline {
        display: inline-block;
        width: 14px;
        height: 14px;
        border: 2px solid var(--color-surface-200);
        border-top: 2px solid var(--color-primary-500);
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
        vertical-align: middle;
        margin-right: 6px;
    }

    .spinner-button {
        display: inline-block;
        width: 16px;
        height: 16px;
        border: 2px solid rgb(255 255 255 / 30%);
        border-top: 2px solid white;
        border-radius: 50%;
        animation: spin 0.8s linear infinite;
        vertical-align: middle;
        margin-right: 8px;
    }

    /* Progress Bar */
    .progress-container {
        width: 100%;
        padding: 16px 0;
    }

    .progress-message {
        color: var(--color-text-primary);
        font-size: 14px;
        margin: 0 0 8px;
        font-weight: 500;
    }

    .progress-bar {
        width: 100%;
        height: 8px;
        background: var(--color-surface-200);
        border-radius: var(--radius-sm);
        overflow: hidden;
        margin-bottom: 8px;
    }

    .progress-fill {
        height: 100%;
        background: linear-gradient(90deg, var(--color-primary-500), var(--color-accent-500));
        border-radius: var(--radius-sm);
        transition: width 0.3s ease;
    }

    .progress-fill-indeterminate {
        height: 100%;
        width: 30%;
        background: linear-gradient(90deg, var(--color-primary-500), var(--color-accent-500));
        border-radius: var(--radius-sm);
        animation: var(--animate-indeterminate);
    }

    .progress-text {
        color: var(--color-text-muted);
        font-size: 12px;
        margin: 0;
        text-align: right;
    }

    /* Links Page */
    .links-page {
        flex: 1;
        padding: 2rem;
    }

    .links-header {
        margin-bottom: 2rem;
    }

    .links-title {
        font-size: 2rem;
        font-weight: 700;
        color: var(--color-primary-500);
        margin-bottom: 0.5rem;
    }

    .links-actions {
        display: flex;
        gap: 1rem;
        align-items: center;
    }

    /* Placeholder Content */
    .placeholder-content {
        background-color: var(--color-surface-50);
        border-radius: var(--radius-lg);
        padding: 4rem 2rem;
        text-align: center;
        box-shadow: var(--shadow-sm);
    }

    .placeholder-text {
        font-size: 1.5rem;
        color: var(--color-text-secondary);
        margin-bottom: 1rem;
    }

    /* Status Filter */
    .status-filter {
        padding: 0.5rem 1rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background-color: white;
        font-size: 0.875rem;
        cursor: pointer;
        transition: border-color 0.2s;
    }

    .status-filter:hover {
        border-color: var(--color-primary-500);
    }

    .status-filter:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    /* Search */
    .search-container {
        position: relative;
        margin: 1.5rem 0;
    }

    .search-bar {
        position: relative;
        margin-bottom: 16px;
    }

    .search-icon {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 20px;
        height: 20px;
        color: var(--color-text-secondary);
        pointer-events: none;
    }

    .search-input {
        width: 100%;
        padding: 12px 40px 12px 44px;
        border: 2px solid var(--color-border);
        border-radius: var(--radius-lg);
        font-size: 1rem;
        background-color: white;
        transition: all 0.2s;
    }

    .search-input:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

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

    .search-clear {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        background: none;
        border: none;
        font-size: 24px;
        color: var(--color-text-secondary);
        cursor: pointer;
        padding: 4px 8px;
        border-radius: var(--radius-sm);
        transition: all 0.2s;
        line-height: 1;
    }

    .search-clear:hover {
        background-color: #f3f4f6;
        color: var(--color-primary-500);
    }

    .search-results-info {
        margin: 0.75rem 0;
        padding: 0.5rem 0.75rem;
        background-color: var(--color-surface-50);
        border-left: 3px solid var(--color-primary-500);
        border-radius: var(--radius-sm);
        font-size: 0.875rem;
        color: var(--color-text-secondary);
    }

    /* Filter Section */
    .filter-section {
        margin: 1rem 0;
    }

    .filter-toggle-btn {
        margin-bottom: 1rem;
        font-size: 0.875rem;
    }

    .filter-panel {
        background-color: var(--color-surface-50);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: 1.5rem;
        margin-bottom: 1.5rem;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1.5rem;
    }

    .filter-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-group label {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--color-text-primary);
    }

    .filter-group select {
        padding: 0.5rem 0.75rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background-color: white;
        font-size: 0.875rem;
        cursor: pointer;
        transition: border-color 0.2s;
    }

    .filter-group select:hover {
        border-color: var(--color-primary-500);
    }

    .filter-group select:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    .filter-group-checkbox {
        display: flex;
        align-items: center;
    }

    .filter-group-checkbox label {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        cursor: pointer;
        font-weight: normal;
    }

    .filter-group-checkbox input[type="checkbox"] {
        width: 1.125rem;
        height: 1.125rem;
        cursor: pointer;
    }

    .filter-panel button {
        grid-column: 1 / -1;
        justify-self: flex-start;
    }

    /* Filters Container */
    .filters-container {
        display: flex;
        gap: 12px;
        margin-bottom: 24px;
        flex-wrap: wrap;
        align-items: center;
    }

    .filter-dropdown {
        position: relative;
    }

    .filter-button {
        padding: 8px 16px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background: white;
        cursor: pointer;
        font-size: 0.875rem;
        color: var(--color-text-primary);
        transition: all 0.2s;
        font-weight: 500;
    }

    .filter-button:hover {
        background: var(--color-surface-200);
        border-color: var(--color-primary-500);
    }

    .filter-menu {
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 4px;
        background: white;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        min-width: 280px;
        max-height: 400px;
        overflow-y: auto;
        z-index: 100;
    }

    .filter-chips {
        padding: 12px;
        border-bottom: 1px solid var(--color-border);
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .filter-chip {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px 8px;
        background: var(--color-primary-500);
        color: white;
        border-radius: var(--radius-sm);
        font-size: 0.875rem;
    }

    .filter-chip button {
        background: none;
        border: none;
        color: white;
        font-size: 18px;
        cursor: pointer;
        padding: 0;
        line-height: 1;
        margin-left: 4px;
    }

    .filter-chip button:hover {
        opacity: 0.8;
    }

    .filter-search {
        width: calc(100% - 16px);
        margin: 8px;
        padding: 8px 12px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        font-size: 0.875rem;
    }

    .filter-search:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    .filter-options {
        padding: 8px;
        max-height: 300px;
        overflow-y: auto;
    }

    .filter-option {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 8px;
        cursor: pointer;
        border-radius: var(--radius-sm);
        transition: background 0.15s;
    }

    .filter-option:hover {
        background: var(--color-surface-200);
    }

    .filter-option input[type="checkbox"] {
        width: 16px;
        height: 16px;
        cursor: pointer;
    }

    .reset-filters {
        padding: 8px 16px;
        background: var(--color-text-secondary);
        color: white;
        border: none;
        border-radius: var(--radius-md);
        cursor: pointer;
        font-size: 0.875rem;
        font-weight: 500;
        transition: all 0.2s;
    }

    .reset-filters:hover {
        background: var(--color-primary-700);
        transform: translateY(-1px);
    }

    .reset-filters:active {
        transform: translateY(0);
    }

    /* Sort Controls */
    .sort-container {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin: 1rem 0;
        padding: 0.75rem;
        background-color: var(--color-surface-50);
        border-radius: var(--radius-md);
    }

    .sort-label {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--color-text-primary);
    }

    .sort-select {
        padding: 0.5rem 0.75rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background-color: white;
        font-size: 0.875rem;
        cursor: pointer;
        transition: border-color 0.2s;
        min-width: 150px;
    }

    .sort-select:hover {
        border-color: var(--color-primary-500);
    }

    .sort-select:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    .sort-order-btn {
        width: 2.5rem;
        height: 2.5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        background-color: white;
        cursor: pointer;
        transition: all 0.2s;
    }

    .sort-order-btn:hover {
        background-color: var(--color-surface-50);
        border-color: var(--color-primary-500);
    }

    .sort-order-btn:active {
        transform: scale(0.95);
    }

    /* Link Status */
    .link-status {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        padding: 0.25rem 0.75rem;
        border-radius: var(--radius-full);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .status-indicator {
        font-size: 0.75rem;
    }

    .status-label {
        font-size: 0.75rem;
    }

    .status-active {
        background-color: var(--color-success-100);
        color: var(--color-success-700);
    }

    .status-archived {
        background-color: #e5e7eb;
        color: #374151;
    }

    .status-inaccessible {
        background-color: var(--color-error-100);
        color: var(--color-error-600);
    }

    .status-repo-unavailable {
        background-color: var(--color-warning-100);
        color: var(--color-warning-600);
    }

    .status-unknown {
        background-color: #f3f4f6;
        color: #6b7280;
    }

    .status-badge {
        display: inline-block;
        padding: 4px 8px;
        border-radius: var(--radius-sm);
        font-size: 0.75rem;
        font-weight: 500;
        text-transform: capitalize;
    }

    /* Link Card variations */
    .link-card-archived {
        opacity: 0.7;
    }

    .link-card-inaccessible {
        border-left: 3px solid var(--color-error-500);
    }

    .link-card-repo-unavailable {
        border-left: 3px solid var(--color-warning-500);
    }

    .link-title-unavailable a {
        text-decoration: line-through;
        color: var(--color-text-secondary);
    }

    .link-title-unavailable a:hover {
        color: var(--color-text-secondary);
    }

    /* Table */
    .table-container {
        background: var(--color-surface-50);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        overflow-x: auto;
        margin-bottom: 24px;
    }

    .search-filters-placeholder {
        margin-bottom: 16px;
        padding: 12px;
        background-color: #f9fafb;
        border-radius: var(--radius-md);
        border: 1px dashed var(--color-border);
    }

    .links-table {
        width: 100%;
        border-collapse: collapse;
        background: var(--color-surface-50);
    }

    .links-table th {
        background: var(--color-surface-200);
        padding: 12px;
        text-align: left;
        font-weight: 600;
        border-bottom: 2px solid var(--color-border);
        user-select: none;
        color: var(--color-text-primary);
        white-space: nowrap;
    }

    .links-table th.sortable {
        cursor: pointer;
    }

    .links-table th.sortable:hover {
        background: var(--color-surface-300);
    }

    .links-table td {
        padding: 12px;
        border-bottom: 1px solid var(--color-border);
        color: var(--color-text-primary);
        vertical-align: middle;
    }

    .links-table tr.link-row {
        cursor: pointer;
        transition: background-color 0.15s;
    }

    .links-table tr.link-row:hover {
        background: var(--color-surface-200);
    }

    .links-table tbody tr:nth-child(even) {
        background: #FAFAFA;
    }

    .links-table tbody tr:nth-child(even):hover {
        background: var(--color-surface-200);
    }

    /* Table Cells */
    .cell-logo {
        width: 48px;
        text-align: center;
        padding: 8px !important;
    }

    /* Logo exists. Uses <img> tags */
    .link-logo {
        width: 32px;
        height: 32px;
        object-fit: contain;
        border-radius: var(--radius-sm);
        display: inline-block;
        vertical-align: middle;
    }

    /* Placeholder for when logo does not exist. Uses <div> tags */
    .link-logo-placeholder {
        width: 32px;
        height: 32px;
        font-size: 20px;
        line-height: 32px;
        border-radius: var(--radius-sm);
        background: inherit !important;
        display: inline-block;
        vertical-align: middle;
    }

    .cell-title {
        max-width: 300px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: 500;
    }

    .cell-domain {
        color: var(--color-text-primary);
        font-size: 0.875rem;
        max-width: 250px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .cell-description {
        max-width: 400px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--color-text-primary);
        font-size: 0.875rem;
    }

    .cell-tags,
    .cell-categories,
    .cell-languages,
    .cell-licenses {
        font-size: 0.875rem;
        color: var(--color-text-primary);
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .cell-status {
        text-align: center;
    }

    .cell-stars {
        text-align: center;
        font-weight: 500;
    }

    .cell-date {
        font-size: 0.875rem;
        color: var(--color-text-primary);
        white-space: nowrap;
    }

    /* Pagination */
    .pagination-container {
        margin-top: 24px;
    }

    .pagination {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 16px;
        background: var(--color-surface-50);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
    }

    .pagination-pages {
        display: flex;
        gap: 4px;
        align-items: center;
    }

    .pagination-btn {
        padding: 8px 12px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        background: white;
        cursor: pointer;
        font-size: 0.875rem;
        color: var(--color-text-primary);
        transition: all 0.2s;
    }

    .pagination-btn:hover:not(:disabled) {
        background: var(--color-surface-200);
        border-color: var(--color-primary-500);
    }

    .pagination-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .pagination-page-active {
        background: var(--color-primary-500);
        color: white;
        border-color: var(--color-primary-500);
    }

    .pagination-page-active:hover {
        background: var(--color-primary-700);
    }

    .pagination-ellipsis {
        padding: 8px 4px;
        color: var(--color-text-secondary);
    }

    .pagination-info {
        text-align: center;
        margin-top: 8px;
        font-size: 0.875rem;
        color: var(--color-text-secondary);
    }

    .results-info {
        text-align: center;
        margin-top: 8px;
        font-size: 0.875rem;
        color: var(--color-text-secondary);
        padding: 8px;
    }

    /* Error Message */
    .error-message {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        padding: 12px 16px;
        border-radius: var(--radius-lg);
        margin-bottom: 16px;
        gap: 12px;
    }

    .error-message-info {
        background: rgb(33 150 243 / 10%);
        border: 1px solid rgb(33 150 243 / 30%);
    }

    .error-message-warning {
        background: rgb(255 152 0 / 10%);
        border: 1px solid rgb(255 152 0 / 30%);
    }

    .error-message-error {
        background: rgb(244 67 54 / 10%);
        border: 1px solid rgb(244 67 54 / 30%);
    }

    .error-content {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        flex: 1;
    }

    .error-icon {
        font-size: 18px;
        line-height: 1;
    }

    .error-text {
        color: var(--color-text-primary);
        font-size: 14px;
        line-height: 1.5;
    }

    .error-actions {
        display: flex;
        gap: 8px;
    }

    .error-box {
        padding: 12px;
        background: #FFEBEE;
        border: 1px solid #EF5350;
        border-radius: var(--radius-md);
        color: #C62828;
        margin-top: 16px;
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }

    .info-box {
        padding: 12px;
        background: #E3F2FD;
        border: 1px solid #42A5F5;
        border-radius: var(--radius-md);
        color: #1565C0;
        margin-top: 16px;
        font-size: 0.875rem;
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }

    .inline-error {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        color: #d32f2f;
        font-size: 13px;
        margin-left: 8px;
    }

    .inline-error-icon {
        font-size: 14px;
    }

    .inline-error-text {
        line-height: 1;
    }

    .field-error {
        color: #d32f2f;
        font-size: 12px;
        margin-top: 4px;
        padding-left: 4px;
    }

    /* Modal */
    .modal-overlay {
        position: fixed;
        inset: 0;
        background: rgb(0 0 0 / 50%);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1000;
        padding: 16px;
        overflow-y: auto;
    }

    .modal-container {
        background: white;
        border-radius: var(--radius-xl);
        max-width: 90vw;
        max-height: calc(100vh - 32px);
        width: 800px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: var(--shadow-xl);
    }

    .modal-content {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        max-height: 100%;
        overflow: hidden;
    }

    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 24px;
        border-bottom: 1px solid var(--color-border);
        flex-shrink: 0;
    }

    .modal-header h2 {
        margin: 0;
        font-size: 1.5rem;
        color: var(--color-text-primary);
    }

    .modal-close {
        background: none;
        border: none;
        font-size: 32px;
        cursor: pointer;
        color: var(--color-text-secondary);
        line-height: 1;
        padding: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

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

    .modal-body {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 24px;
        min-height: 0;
    }

    .modal-loading,
    .modal-error {
        padding: 60px 24px;
        text-align: center;
        font-size: 1.125rem;
    }

    .modal-error {
        color: var(--color-error-500);
    }

    .modal-section {
        margin-bottom: 32px;
    }

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

    .section-title {
        font-size: 1.125rem;
        font-weight: 600;
        margin-bottom: 16px;
        color: var(--color-primary-500);
        border-bottom: 2px solid var(--color-primary-500);
        padding-bottom: 8px;
    }

    .section-content {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .modal-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 24px;
        border-top: 1px solid var(--color-border);
        flex-shrink: 0;
        background: var(--color-surface-100);
    }

    .footer-actions {
        display: flex;
        gap: 12px;
    }

    .modal-body .error-message {
        background: #FFEBEE;
        border: 1px solid var(--color-error-500);
        color: var(--color-error-500);
        padding: 12px 16px;
        border-radius: var(--radius-md);
        margin-top: 16px;
    }

    .modal[aria-hidden="true"] {
        display: none;
    }

    .modal[aria-hidden="false"] {
        display: flex;
    }

    /* Form Fields in Modal */
    .readonly-field,
    .editable-field {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .readonly-field label,
    .editable-field label {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--color-text-secondary);
    }

    .readonly-field div {
        padding: 12px;
        background: var(--color-surface-100);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        color: var(--color-text-primary);
        min-height: 44px;
    }

    .editable-field input,
    .editable-field textarea {
        padding: 12px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        font-size: 1rem;
        font-family: inherit;
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    .editable-field input:focus,
    .editable-field textarea:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    .github-stats {
        display: flex;
        gap: 24px;
        padding: 12px 0;
    }

    .github-stat {
        font-size: 1rem;
        color: var(--color-text-primary);
    }

    .notes-textarea {
        min-height: 150px;
        font-family: var(--font-mono);
        resize: vertical;
    }

    .url-input {
        width: 100%;
        padding: 12px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        font-size: 1rem;
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    .url-input:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    /* Dialog */
    .dialog-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 24px;
        border-bottom: 1px solid var(--color-border);
    }

    .dialog-header h2 {
        margin: 0;
        font-size: 1.5rem;
        color: var(--color-text-primary);
    }

    .close-button {
        background: none;
        border: none;
        font-size: 32px;
        cursor: pointer;
        color: var(--color-text-secondary);
        line-height: 1;
        padding: 0;
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: color 0.2s;
    }

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

    .dialog-body {
        padding: 24px;
    }

    .dialog-footer {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 12px;
        padding: 24px;
        border-top: 1px solid var(--color-border);
    }

    .dialog-actions {
        display: flex;
        gap: 12px;
        justify-content: flex-end;
    }

    /* Link Preview Section */
    .preview-section {
        background: var(--color-surface-100);
        border-radius: var(--radius-lg);
        padding: 16px;
        margin-top: 16px;
    }

    .preview-header {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 12px;
    }

    .preview-favicon {
        width: 32px;
        height: 32px;
        border-radius: var(--radius-sm);
        flex-shrink: 0;
    }

    .preview-title-group {
        flex: 1;
        min-width: 0;
    }

    .preview-title {
        margin: 0;
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--color-text-primary);
        line-height: 1.3;
    }

    .preview-domain {
        font-size: 0.875rem;
        color: var(--color-text-muted);
    }

    .preview-description {
        font-size: 0.875rem;
        color: var(--color-text-secondary);
        margin: 0 0 12px;
        line-height: 1.5;
    }

    .preview-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 12px;
    }

    .preview-badge {
        display: inline-flex;
        align-items: center;
        padding: 4px 10px;
        font-size: 0.75rem;
        font-weight: 500;
        border-radius: var(--radius-full);
    }

    .preview-badge-github {
        background: var(--color-surface-300);
        color: var(--color-text-primary);
    }

    .preview-badge-stars {
        background: var(--color-warning-100);
        color: var(--color-warning-500);
    }

    .preview-badge-license {
        background: var(--color-info-100);
        color: var(--color-info-500);
    }

    .preview-badge-language {
        background: var(--color-surface-200);
        color: var(--color-text-secondary);
    }

    .preview-url {
        font-size: 0.8125rem;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--color-border);
    }

    .preview-url a {
        color: var(--color-primary-500);
        text-decoration: none;
        word-break: break-all;
    }

    .preview-url a:hover {
        text-decoration: underline;
    }

    /* Progress Steps */
    .progress-steps {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin: 16px 0;
    }

    .progress-step {
        display: flex;
        align-items: center;
        gap: 12px;
        color: var(--color-text-muted);
    }

    .progress-step-active {
        color: var(--color-primary-600);
        font-weight: 500;
    }

    .progress-step-active .progress-step-indicator {
        background: var(--color-primary-600);
        color: white;
        animation: pulse 1.5s ease-in-out infinite;
    }

    .progress-step-complete {
        color: var(--color-success-500);
    }

    .progress-step-complete .progress-step-indicator {
        background: var(--color-success-500);
        color: white;
    }

    .progress-step-indicator {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: var(--color-surface-200);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem;
        font-weight: 700;
        flex-shrink: 0;
    }

    .progress-step-label {
        font-size: 0.875rem;
    }

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

        50% {
            opacity: 0.6;
        }
    }

    /* Categorization Accordion */
    .categorization-accordion {
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        margin-top: 16px;
    }

    .categorization-summary {
        padding: 12px 16px;
        background: var(--color-surface-100);
        cursor: pointer;
        font-weight: 500;
        color: var(--color-text-primary);
        border-radius: var(--radius-lg);
        display: flex;
        align-items: center;
        transition: background 0.2s;
        list-style: none;
    }

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

    .categorization-summary:hover {
        background: var(--color-surface-200);
    }

    .categorization-arrow {
        display: inline-block;
        margin-right: 8px;
        transition: transform 0.2s;
    }

    .categorization-arrow::before {
        content: "▶";
        font-size: 0.625rem;
        color: var(--color-text-muted);
    }

    details[open] .categorization-arrow {
        transform: rotate(90deg);
    }

    details[open] .categorization-summary {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .categorization-count {
        font-size: 0.875rem;
        color: var(--color-primary-500);
        margin-left: auto;
    }

    .categorization-content {
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 16px;
        border-top: 1px solid var(--color-border);
    }

    /* Auto-suggested badge */
    .auto-suggested-badge {
        margin-left: 8px;
        padding: 2px 8px;
        font-size: 0.75rem;
        font-weight: 500;
        background: var(--color-success-100);
        color: var(--color-success-500);
        border-radius: var(--radius-full);
    }

    /* Keyboard hints */
    .keyboard-hints {
        display: flex;
        gap: 16px;
        font-size: 0.75rem;
        color: var(--color-text-muted);
        margin-right: auto;
    }

    .keyboard-hints kbd {
        padding: 2px 6px;
        background: var(--color-surface-100);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
        color: var(--color-text-secondary);
        font-family: ui-monospace, monospace;
        font-size: 0.6875rem;
    }

    .keyboard-hints .hint {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    /* Success Indicator */
    .success-indicator {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 48px 24px;
        gap: 16px;
        animation: fadeIn 0.3s ease-out;
    }

    .success-checkmark {
        width: 64px;
        height: 64px;
        border-radius: 50%;
        background: var(--color-success, #22c55e);
        color: white;
        font-size: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        animation: scaleIn 0.4s ease-out;
    }

    .success-indicator span {
        font-size: 1.125rem;
        color: var(--color-text-primary);
        font-weight: 500;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }

        to {
            opacity: 1;
        }
    }

    @keyframes scaleIn {
        0% {
            transform: scale(0);
            opacity: 0;
        }

        50% {
            transform: scale(1.2);
        }

        100% {
            transform: scale(1);
            opacity: 1;
        }
    }

    /* Error Box Improvements */
    .error-box {
        display: flex;
        flex-direction: column;
        gap: 12px;
        background: var(--color-error-bg, #fef2f2);
        border: 1px solid var(--color-error-border, #fecaca);
        border-radius: var(--radius-md);
        padding: 12px 16px;
        margin-top: 16px;
    }

    .error-content {
        display: flex;
        align-items: flex-start;
        gap: 8px;
    }

    .error-icon {
        color: var(--color-error, #ef4444);
        font-size: 1.125rem;
        flex-shrink: 0;
    }

    .error-text {
        color: var(--color-error-text, #991b1b);
        font-size: 0.875rem;
        line-height: 1.5;
    }

    /* Retry Button */
    .btn-retry {
        align-self: flex-start;
        padding: 6px 12px;
        font-size: 0.8125rem;
        background: white;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        cursor: pointer;
        transition: all 0.15s ease;
        color: var(--color-text-secondary);
    }

    .btn-retry:hover {
        background: var(--color-surface-50);
        border-color: var(--color-primary);
        color: var(--color-primary);
    }

    /* Responsive Design for Add Link Dialog */
    @media (width <= 640px) {
        .add-link-dialog {
            width: 100%;
            max-width: 100%;
            height: 100%;
            max-height: 100%;
            border-radius: 0;
        }

        .dialog-header {
            padding: 16px;
        }

        .dialog-body {
            padding: 16px;
        }

        .dialog-footer {
            padding: 16px;
            flex-direction: column;
            gap: 12px;
        }

        .keyboard-hints {
            display: none;
        }

        .dialog-actions {
            width: 100%;
            display: flex;
            gap: 8px;
        }

        .dialog-actions button {
            flex: 1;
        }

        .preview-section {
            padding: 12px;
        }

        .preview-header {
            flex-direction: column;
            align-items: flex-start;
        }

        .preview-meta {
            flex-wrap: wrap;
        }

        .categorization-accordion {
            margin-top: 12px;
        }

        .categorization-content {
            padding: 12px;
        }

        .form-group {
            margin-bottom: 12px;
        }

        .progress-steps {
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
        }
    }

    /* Confirm Dialog */
    .confirm-dialog {
        background: white;
        border-radius: var(--radius-xl);
        padding: 32px;
        max-width: 400px;
        box-shadow: var(--shadow-xl);
    }

    .confirm-dialog h3 {
        margin: 0 0 16px;
        font-size: 1.25rem;
        color: var(--color-text-primary);
    }

    .confirm-dialog p {
        margin: 0 0 24px;
        color: var(--color-text-secondary);
        line-height: 1.6;
    }

    /* Chips */
    .category-chips,
    .tag-chips,
    .language-chips,
    .license-chips,
    .selected-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        background: var(--color-primary-500);
        color: white;
        border-radius: var(--radius-full);
        font-size: 0.875rem;
        font-weight: 500;
    }

    .chip button {
        background: none;
        border: none;
        color: white;
        font-size: 18px;
        cursor: pointer;
        padding: 0;
        line-height: 1;
        margin-left: 4px;
    }

    .chip button:hover {
        opacity: 0.8;
    }

    /* Badges */
    .badge {
        display: inline-block;
        padding: 4px 12px;
        border-radius: var(--radius-full);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .badge-success {
        background: #4CAF50;
        color: white;
    }

    .badge-warning {
        background: #FF9800;
        color: white;
    }

    .badge-active {
        background: #4CAF50;
        color: white;
    }

    .badge-inactive {
        background: #9E9E9E;
        color: white;
    }

    .badge-pending {
        background: #FF9800;
        color: white;
    }

    /* Category Tree */
    .category-tree {
        background: white;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: 16px;
        margin-bottom: 24px;
    }

    .tree-node {
        margin-bottom: 4px;
    }

    .tree-node-content {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        border-radius: var(--radius-md);
        transition: background 0.2s;
    }

    .tree-node-content:hover {
        background: var(--color-surface-200);
    }

    .drag-handle {
        cursor: grab;
        color: var(--color-text-secondary);
        font-weight: bold;
        font-size: 16px;
    }

    .drag-handle:active {
        cursor: grabbing;
    }

    .category-name {
        flex: 1;
        cursor: pointer;
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        transition: background 0.2s;
    }

    .category-name:hover {
        background: var(--color-surface-100);
    }

    .usage-count {
        font-size: 0.875rem;
        color: var(--color-text-primary);
        min-width: 80px;
    }

    .tree-node-actions {
        display: flex;
        gap: 4px;
    }

    .tree-children {
        margin-left: 24px;
    }

    /* Inline Edit */
    .inline-edit {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
    }

    .inline-edit-input {
        flex: 1;
        padding: 6px 12px;
        border: 2px solid var(--color-primary-500);
        border-radius: var(--radius-sm);
        font-size: 1rem;
        box-shadow: var(--shadow-focus);
    }

    .inline-edit-input:focus {
        outline: none;
    }

    /* Add Category/Item Input */
    .add-category-input,
    .add-item-input {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px;
        background: var(--color-surface-200);
        border: 2px solid var(--color-primary-500);
        border-radius: var(--radius-lg);
        margin-bottom: 16px;
    }

    .add-category-input input,
    .add-item-input input {
        flex: 1;
        padding: 8px 12px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
    }

    .add-category-input input:focus,
    .add-item-input input:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    /* Flat List */
    .flat-list {
        background: white;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: 8px;
        margin-bottom: 24px;
    }

    .flat-list-item {
        margin-bottom: 4px;
    }

    .flat-list-item-content {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        border-radius: var(--radius-md);
        transition: background 0.2s;
    }

    .flat-list-item-content:hover {
        background: var(--color-surface-200);
    }

    .item-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .item-name {
        cursor: pointer;
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        transition: background 0.2s;
        font-weight: 500;
    }

    .item-name:hover {
        background: var(--color-surface-100);
    }

    .item-secondary {
        font-size: 0.875rem;
        color: var(--color-text-primary);
        padding-left: 12px;
    }

    .add-license-input-special {
        display: grid;
        grid-template-columns: 2fr 1fr auto auto;
        gap: 12px;
    }

    .add-license-input-special input {
        flex: unset;
    }

    /* Empty State */
    .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 60px 20px;
        text-align: center;
        background: var(--color-surface-50);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
    }

    .empty-icon {
        font-size: 64px;
        margin-bottom: 16px;
        opacity: 0.6;
    }

    .empty-title {
        font-size: 20px;
        font-weight: 600;
        color: var(--color-text-primary);
        margin: 0 0 8px;
    }

    .empty-description {
        font-size: 14px;
        color: var(--color-text-muted);
        margin: 0 0 24px;
        max-width: 400px;
    }

    .empty-action {
        margin-top: 16px;
    }

    .error-state .empty-icon {
        opacity: 0.8;
    }

    /* Toast */
    .toast-container {
        position: fixed;
        top: 20px;
        right: 20px;
        z-index: 10000;
        display: flex;
        flex-direction: column;
        gap: 12px;
        max-width: 400px;
    }

    .toast {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        padding: 12px 16px;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        animation: var(--animate-slide-in);
        gap: 12px;
    }

    .toast-success {
        background: #4caf50;
        color: white;
    }

    .toast-error {
        background: #f44336;
        color: white;
    }

    .toast-warning {
        background: #ff9800;
        color: white;
    }

    .toast-info {
        background: #2196f3;
        color: white;
    }

    .toast-content {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        flex: 1;
    }

    .toast-icon {
        font-size: 18px;
        line-height: 1;
        font-weight: bold;
    }

    .toast-message {
        font-size: 14px;
        line-height: 1.5;
    }

    .toast-close {
        background: transparent;
        border: none;
        color: white;
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
        padding: 0 4px;
        opacity: 0.8;
        transition: opacity 0.2s;
    }

    .toast-close:hover {
        opacity: 1;
    }

    .toast[role="status"],
    .toast[role="alert"] {
        position: relative;
    }

    /* 404 Not Found Page */
    .not-found-container {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        padding: 2rem;
        background: var(--color-surface-200);
    }

    .not-found-content {
        text-align: center;
        max-width: 500px;
    }

    .not-found-icon {
        font-size: 8rem;
        font-weight: 800;
        color: var(--color-primary-500);
        line-height: 1;
        margin-bottom: 1rem;
        opacity: 0.8;
    }

    .not-found-title {
        font-size: 2rem;
        font-weight: 700;
        color: var(--color-text-primary);
        margin: 0 0 1rem;
    }

    .not-found-message {
        font-size: 1.125rem;
        color: var(--color-text-secondary);
        margin: 0 0 0.5rem;
    }

    .not-found-path {
        background: var(--color-surface-300);
        padding: 0.25rem 0.5rem;
        border-radius: var(--radius-sm);
        font-family: var(--font-mono);
        font-size: 1rem;
        color: var(--color-primary-500);
    }

    .not-found-suggestion {
        font-size: 1rem;
        color: var(--color-text-muted);
        margin: 0 0 2rem;
    }

    .not-found-actions {
        display: flex;
        gap: 1rem;
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Skip Link */
    .skip-link {
        position: absolute;
        top: -100px;
        left: 0;
        background: var(--color-primary-500);
        color: white;
        padding: 12px 20px;
        text-decoration: none;
        font-weight: 600;
        z-index: 100000;
        border-radius: 0 0 var(--radius-lg) 0;
        transition: top 0.2s ease;
    }

    .skip-link:focus {
        top: 0;
        outline: 3px solid white;
        outline-offset: -3px;
    }

    /* Screen Reader Only */
    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border-width: 0;
    }

    .sr-only-focusable:focus {
        position: static;
        width: auto;
        height: auto;
        padding: inherit;
        margin: inherit;
        overflow: visible;
        clip: auto;
        white-space: normal;
    }

    /* Live Regions */
    [aria-live] {
        position: relative;
    }

    .live-region-polite,
    .live-region-assertive {
        position: absolute;
        left: -10000px;
        width: 1px;
        height: 1px;
        overflow: hidden;
    }

    /* Focus Trap */
    .focus-trap-active {
        position: relative;
    }

    .focus-trap-active::before {
        content: '';
        position: absolute;
        inset: -4px;
        border: 2px solid var(--color-primary-500);
        border-radius: inherit;
        pointer-events: none;
        opacity: 0.5;
    }

    /* Landmark Roles */
    [role="banner"],
    [role="navigation"],
    [role="main"],
    [role="contentinfo"],
    [role="complementary"] {
        position: relative;
    }
}

/* ============================================================================
   Keyframes
   ============================================================================ */

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

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

@keyframes indeterminate {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

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

@media (width <= 1023px) {
    body {
        font-size: 15px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 22px;
    }

    h3 {
        font-size: 18px;
    }

    .page-container {
        padding: 0;
    }

    .content-container {
        padding: 16px;
        max-width: 100%;
        overflow-x: hidden;
    }

    .page-header {
        gap: 12px;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-lg);
        border: 1px solid var(--color-border);
    }

    table {
        width: 100%;
        min-width: 0;
    }

    th,
    td {
        padding: 10px;
        font-size: 13px;
    }

    .links-table {
        min-width: 0;
    }

    .link-card {
        padding: 14px;
    }

    .link-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 14px;
    }
}

@media (width >= 768px) and (width <= 1023px) {
    .link-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }

    .content-container {
        max-width: 100%;
        padding: 20px;
        overflow-x: hidden;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
    }
}

@media (width <= 767px) {
    /* Filter styles */
    .filters-container {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-dropdown {
        width: 100%;
    }

    .filter-button {
        width: 100%;
        text-align: left;
    }

    .filter-menu {
        width: 100%;
    }

    /* Typography */
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 20px;
    }

    h3 {
        font-size: 16px;
    }

    .content-container {
        padding: 12px;
        max-width: 100%;
        overflow-x: hidden;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 22px;
    }

    .page-header button,
    .page-header .btn-primary {
        width: 100%;
    }

    /* Touch-friendly targets */
    button,
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-danger,
    a.btn,
    [role="menuitem"] {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 14px;
    }

    .btn-icon {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    textarea,
    select {
        min-height: 44px;
        padding: 12px;
        font-size: 16px;
    }

    input[type="checkbox"],
    input[type="radio"] {
        min-width: 20px;
        min-height: 20px;
    }

    .table-container {
        margin: 0 -12px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    table {
        width: 100%;
        min-width: 0;
    }

    .links-table {
        min-width: 0;
    }

    th,
    td {
        padding: 8px;
        font-size: 12px;
    }

    .modal {
        padding: 10px;
    }

    .modal-content {
        max-width: 100%;
        margin: 20px 0;
        border-radius: var(--radius-xl);
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
        flex: 1 1 auto;
        overflow-y: auto;
        min-height: 0;
    }

    .modal-container {
        max-height: calc(100vh - 24px);
        margin: 12px;
    }

    .modal-footer {
        padding: 16px;
        gap: 8px;
    }

    .modal-footer button {
        flex: 1;
    }

    .confirm-dialog,
    .add-link-dialog {
        max-width: 100%;
        margin: 20px 10px;
    }

    .dialog-actions,
    .confirm-actions {
        flex-direction: column;
    }

    .dialog-actions button,
    .confirm-actions button {
        width: 100%;
    }

    .link-card {
        padding: 12px;
    }

    .link-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .link-header {
        flex-wrap: wrap;
    }

    .link-title {
        font-size: 15px;
    }

    .link-url {
        font-size: 11px;
    }

    .metadata-badges {
        flex-wrap: wrap;
        gap: 4px;
    }

    .badge {
        font-size: 10px;
        padding: 3px 6px;
    }

    .category-tree,
    .flat-list {
        margin: 0;
        width: calc(100%);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .tree-node-content,
    .flat-list-item-content {
        padding: 12px;
        font-size: 14px;
    }

    .tree-node-actions,
    .flat-list-item-actions {
        gap: 6px;
    }

    .inline-edit input,
    .inline-edit-input {
        font-size: 14px;
        padding: 10px;
    }

    .add-category-input,
    .add-item-input {
        padding: 12px;
        gap: 8px;
        flex-direction: column;
        align-items: stretch;
    }

    .add-category-input input,
    .add-item-input input {
        font-size: 14px;
        padding: 10px;
    }

    .add-category-input button,
    .add-item-input button {
        width: 100%;
    }

    .tree-node-content {
        flex-wrap: wrap;
    }

    .tree-children {
        margin-left: 12px;
    }

    .flat-list-item-content {
        flex-wrap: nowrap;
    }

    .item-info {
        flex: 1;
        min-width: 0;
    }

    .add-license-input-special {
        grid-template-columns: 1fr;
    }

    .add-license-input-special button {
        width: 100%;
    }

    .search-filter-container {
        flex-direction: column;
        gap: 12px;
    }

    .search-input-wrapper,
    .filter-controls {
        width: 100%;
    }

    .filter-controls {
        flex-wrap: wrap;
    }

    .filter-controls select,
    .filter-controls button {
        flex: 1 1 calc(50% - 6px);
        min-width: 120px;
    }

    .pagination {
        flex-direction: column;
        gap: 12px;
    }

    .pagination button {
        padding: 8px 12px;
        font-size: 13px;
        min-width: 40px;
    }

    .pagination .page-info {
        font-size: 12px;
        padding: 0 8px;
    }

    .toast-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }

    .loading-container {
        padding: 30px 20px;
    }

    .empty-state {
        padding: 40px 20px;
    }

    .empty-icon {
        font-size: 48px;
    }

    .empty-title {
        font-size: 18px;
    }

    .error-message {
        flex-direction: column;
    }

    .error-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .auth-card {
        padding: 2rem 1.5rem;
    }

    .links-actions {
        flex-direction: column;
        width: 100%;
    }

    .status-filter {
        width: 100%;
    }

    .add-link-dialog {
        width: 100%;
        max-width: 90vw;
    }

    .btn-add-link {
        width: 100%;
        justify-content: center;
    }
}

@media (width <= 767px) and (orientation: landscape) {
    .modal-body {
        max-height: calc(100vh - 120px);
    }

    .page-header {
        flex-flow: row wrap;
    }

    .page-header button {
        width: auto;
        flex: 0 0 auto;
    }

    .table-container {
        max-height: 60vh;
        overflow-y: auto;
    }
}

@media (width >= 1024px) {
    .content-container {
        max-width: 1600px;
        width: 100%;
        margin: 0 auto;
        padding: 24px;
        overflow-x: hidden;
    }

    .link-grid {
        grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    }

    .link-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-lg);
    }

    .btn:hover,
    button:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: var(--shadow-primary-sm);
    }

    .tree-node-content:hover,
    .flat-list-item-content:hover {
        background: rgb(183 65 14 / 2%);
    }
}

/* ============================================================================
   Accessibility
   ============================================================================ */

@media (prefers-contrast: high) {
    @theme {
        --color-primary-500: #a83f0f;
        --color-accent-500: #8b3410;
        --color-border: #000;
        --color-text-primary: #000;
    }

    button,
    .btn {
        border: 2px solid currentcolor;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .spinner,
    .spinner-inline,
    .spinner-button {
        animation: none;
        border-top-color: transparent;
    }

    .progress-fill-indeterminate {
        animation: none;
    }
}

@media (prefers-color-scheme: dark) {
    @theme {
        /* Dark surfaces - darker backgrounds */
        --color-surface-50: #1a1a1a;
        --color-surface-100: #242424;
        --color-surface-200: #2d2d2d;
        --color-surface-300: #383838;
        --color-surface-400: #484848;

        /* Light text for dark mode - high contrast */
        --color-text-primary: #f0f0f0;
        --color-text-secondary: #d0d0d0;
        --color-text-contrast: #fff;
        --color-text-muted: #a0a0a0;

        /* Borders visible on dark */
        --color-border: #505050;

        /* Brighter accent colors for dark mode */
        --color-primary-500: #ff8a65;
        --color-primary-600: #ff7043;
        --color-primary-700: #f4511e;
        --color-accent-500: #ff7043;
        --color-accent-600: #f4511e;

        /* Semantic colors adjusted for dark mode */
        --color-error-50: #3d1f1f;
        --color-error-100: #5c2a2a;
        --color-error-500: #ef5350;
        --color-error-600: #f44336;
        --color-error-700: #ff6659;
        --color-success-50: #1a3d2a;
        --color-success-100: #2a5c3a;
        --color-success-500: #66bb6a;
        --color-success-600: #4caf50;
        --color-success-700: #81c784;
        --color-warning-50: #3d3015;
        --color-warning-100: #5c4a20;
        --color-warning-500: #ffb74d;
        --color-warning-600: #ffa726;
        --color-info-50: #1a2d3d;
        --color-info-100: #2a445c;
        --color-info-500: #64b5f6;
        --color-info-600: #42a5f5;
    }

    body {
        background: var(--color-surface-200);
        color: var(--color-text-primary);
    }

    /* Override hardcoded white/light backgrounds */
    .flat-list,
    .category-tree,
    .modal-container,
    .confirm-dialog,
    .auth-card,
    .table-container,
    .links-table,
    .filter-menu,
    .toast {
        background: var(--color-surface-100);
    }

    .links-table th {
        background: var(--color-surface-300);
    }

    .links-table tbody tr:nth-child(even) {
        background: var(--color-surface-200);
    }

    .links-table tbody tr:hover,
    .links-table tbody tr:nth-child(even):hover {
        background: var(--color-surface-300);
    }

    .tree-node-content:hover,
    .flat-list-item-content:hover,
    .filter-option:hover {
        background: var(--color-surface-300);
    }

    .item-name:hover,
    .category-name:hover {
        background: var(--color-surface-200);
    }

    .btn-secondary {
        background: var(--color-surface-300);
        color: var(--color-text-primary);
        border-color: var(--color-border);
    }

    .btn-secondary:hover:not(:disabled) {
        background: var(--color-surface-400);
    }

    .form-input,
    .search-input,
    .filter-search,
    .url-input,
    .inline-edit-input,
    .status-filter,
    .sort-select,
    .filter-group select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="url"],
    textarea,
    select {
        background: var(--color-surface-100);
        color: var(--color-text-primary);
        border-color: var(--color-border);
    }

    .readonly-field div {
        background: var(--color-surface-200);
        color: var(--color-text-primary);
    }

    .modal-footer {
        background: var(--color-surface-200);
    }

    .pagination,
    .pagination-btn {
        background: var(--color-surface-100);
    }

    .pagination-btn:hover:not(:disabled) {
        background: var(--color-surface-300);
    }

    .sort-order-btn {
        background: var(--color-surface-100);
    }

    .sort-order-btn:hover {
        background: var(--color-surface-300);
    }

    .add-category-input,
    .add-item-input {
        background: var(--color-surface-300);
    }

    .chip {
        background: var(--color-primary-600);
    }

    .filter-chip {
        background: var(--color-primary-600);
    }

    .info-box {
        background: var(--color-info-50);
        border-color: var(--color-info-500);
        color: var(--color-info-600);
    }

    .error-box {
        background: var(--color-error-50);
        border-color: var(--color-error-500);
        color: var(--color-error-600);
    }

    .search-clear:hover {
        background: var(--color-surface-300);
    }

    .link-logo-placeholder {
        background: var(--color-surface-300);
    }

    .empty-state {
        background: var(--color-surface-100);
    }

    .sort-container,
    .filter-panel {
        background: var(--color-surface-100);
    }

    .search-results-info {
        background: var(--color-surface-100);
    }

    /* Filter buttons */
    .filter-button {
        background: var(--color-surface-100);
        color: var(--color-text-primary);
        border-color: var(--color-border);
    }

    .filter-button:hover {
        background: var(--color-surface-300);
    }

    .reset-filters {
        background: var(--color-surface-400);
        color: var(--color-text-primary);
    }

    .reset-filters:hover {
        background: var(--color-primary-600);
        color: white;
    }

    /* Navbar buttons */
    nav button,
    nav a[role="menuitem"] {
        background: var(--color-surface-300);
        color: var(--color-text-primary);
    }

    nav button:hover,
    nav a[role="menuitem"]:hover {
        background: var(--color-surface-400);
    }

    /* Primary button adjustments */
    .btn-primary {
        background: var(--color-primary-500);
        color: white;
    }

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

    /* Delete button */
    .btn-delete {
        background: var(--color-surface-100);
        color: var(--color-error-500);
        border-color: var(--color-error-500);
    }

    .btn-delete:hover {
        background: var(--color-error-500);
        color: white;
    }

    /* Icon buttons */
    .btn-icon {
        background: var(--color-surface-200);
        color: var(--color-text-primary);
    }

    .btn-icon:hover {
        background: var(--color-surface-300);
    }

    /* Add link button */
    .btn-add-link {
        background: var(--color-primary-500);
        color: white;
    }
}

/* ============================================================================
   Add Link Page Styles
   ============================================================================ */

@layer components {
    .add-link-page-content {
        max-width: 800px;
        margin: 0 auto;
    }

    /* Preview section with separator */
    .add-link-page-content .preview-section {
        padding-bottom: 24px;
        margin-bottom: 24px;
        border-bottom: 1px solid var(--color-border);
    }

    /* Use edit-section styles for categorization in add-link page */
    .add-link-page-content .edit-section {
        margin-bottom: 24px;
    }

    .add-link-page-content .edit-section:last-of-type {
        border-bottom: none;
    }

    .add-link-page-content .page-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 24px;
        margin-top: 24px;
    }

    .add-link-page-content .page-actions {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-left: auto;
    }

    /* Responsive adjustments for Add Link page */
    @media (width <= 640px) {
        .add-link-page-content .page-footer {
            flex-direction: column;
            gap: 16px;
        }

        .add-link-page-content .page-actions {
            width: 100%;
            margin-left: 0;
        }

        .add-link-page-content .page-actions button {
            flex: 1;
        }
    }
}

/* ============================================================================
   Edit Link Page Styles
   ============================================================================ */

@layer components {
    .edit-link-page-content {
        max-width: 800px;
        margin: 0 auto;
    }

    .edit-section {
        margin-bottom: 32px;
        padding-bottom: 24px;
        border-bottom: 1px solid var(--color-border);
    }

    .edit-section:last-of-type {
        border-bottom: none;
    }

    .edit-section-title {
        font-size: 1.125rem;
        font-weight: 600;
        margin-bottom: 16px;
        color: var(--color-primary-600);
        border-bottom: 2px solid var(--color-primary-500);
        padding-bottom: 8px;
    }

    .edit-section-content {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    /* Inline form fields for categorization */
    .edit-section-content .form-group {
        display: grid;
        grid-template-columns: 120px 1fr;
        align-items: start;
        gap: 16px;
    }

    .edit-section-content .form-group label {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--color-text-secondary);
        padding-top: 10px;
    }

    /* Notes textarea full width */
    .edit-section-content .notes-textarea {
        width: 100%;
        min-height: 150px;
        font-family: var(--font-mono);
        resize: vertical;
        padding: 12px;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        font-size: 1rem;
        transition: border-color 0.2s, box-shadow 0.2s;
    }

    .edit-section-content .notes-textarea:focus {
        outline: none;
        border-color: var(--color-primary-500);
        box-shadow: var(--shadow-focus);
    }

    /* Inline metadata fields */
    .metadata-field {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .metadata-field label {
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--color-text-secondary);
        min-width: 80px;
    }

    .metadata-field .field-value {
        color: var(--color-text-primary);
        font-size: 0.875rem;
    }

    /* Status badge with emoji */
    .status-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 4px 12px;
        border-radius: var(--radius-md);
        font-size: 0.875rem;
        font-weight: 500;
    }

    .status-badge-active {
        background: var(--color-success-100);
        color: var(--color-success-700);
    }

    .status-badge-pending {
        background: var(--color-warning-100);
        color: var(--color-warning-700);
    }

    .status-badge-error,
    .status-badge-failed {
        background: var(--color-error-100);
        color: var(--color-error-700);
    }

    .status-badge-archived {
        background: var(--color-surface-200);
        color: var(--color-text-secondary);
    }

    /* Page footer for edit link */
    .edit-link-page-content .page-footer {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-top: 24px;
        margin-top: 24px;
        border-top: 1px solid var(--color-border);
    }

    .edit-link-page-content .page-actions {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .edit-link-page-content .action-group {
        display: flex;
        gap: 12px;
    }

    /* Responsive adjustments */
    @media (width <= 640px) {
        .edit-section-content .form-group {
            grid-template-columns: 1fr;
            gap: 8px;
        }

        .edit-section-content .form-group label {
            padding-top: 0;
        }

        /* Metadata fields stay inline on mobile */
        .metadata-field {
            gap: 8px;
        }

        .metadata-field label {
            min-width: 70px;
        }

        .edit-link-page-content .page-footer {
            flex-direction: column;
            gap: 16px;
        }

        .edit-link-page-content .page-actions {
            width: 100%;
            flex-direction: column;
        }

        .edit-link-page-content .action-group {
            width: 100%;
        }

        .edit-link-page-content .action-group button {
            flex: 1;
        }
    }
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
    .navbar,
    .page-header button,
    .btn,
    .modal,
    .toast-container {
        display: none !important;
    }

    .content-container {
        padding: 0;
    }

    .link-card,
    .tree-node,
    .flat-list-item {
        break-inside: avoid;
    }

    body {
        font-size: 12pt;
        color: black;
    }
}
