/* ===== Design Tokens ===== */
:root {
    --primary: #1e3a8a;
    --primary-light: #2563eb;
    --primary-glow: rgba(37, 99, 235, 0.15);
    --gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    --gradient-hover: linear-gradient(135deg, #1e3570 0%, #1d4ed8 100%);
    --gradient-subtle: linear-gradient(135deg, rgba(30,58,138,0.04) 0%, rgba(37,99,235,0.06) 100%);
    --gradient-mesh: radial-gradient(ellipse at 20% 50%, rgba(37,99,235,0.08) 0%, transparent 50%),
                     radial-gradient(ellipse at 80% 20%, rgba(30,58,138,0.06) 0%, transparent 50%),
                     radial-gradient(ellipse at 50% 80%, rgba(59,130,246,0.05) 0%, transparent 50%);
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-heading: 'Space Grotesk', 'Inter', sans-serif;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --green-50: #f0fdf4;
    --green-100: #dcfce7;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --green-700: #15803d;
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 40px -8px rgba(30, 58, 138, 0.18);
    --shadow-glow: 0 0 30px rgba(37, 99, 235, 0.12);
    --sidebar-width: 240px;
    --header-height: 64px;
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== Keyframe Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse-ring {
    0% { transform: scale(0.95); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.7; }
    100% { transform: scale(0.95); opacity: 1; }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-6px); }
}

@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--gray-50);
    background-image: var(--gradient-mesh);
    background-attachment: fixed;
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(229, 231, 235, 0.6);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    height: var(--header-height);
    max-width: 1440px;
    margin: 0 auto;
}

.back-link {
    font-size: 13px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.25s var(--ease-out-expo);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    letter-spacing: -0.01em;
}

.back-link:hover {
    color: var(--primary-light);
    background: var(--gradient-subtle);
}

.header-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    flex: 1;
    letter-spacing: -0.03em;
}

.privacy-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--green-700);
    background: linear-gradient(135deg, rgba(240,253,244,0.9), rgba(220,252,231,0.9));
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(187,247,208,0.5);
    padding: 6px 14px;
    border-radius: 20px;
    white-space: nowrap;
    animation: fadeIn 0.6s var(--ease-out-expo);
}

/* ===== App Layout ===== */
.app-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(255,255,255,0.7);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-right: 1px solid rgba(229, 231, 235, 0.5);
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-nav {
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 14px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--gray-600);
    text-align: left;
    transition: all 0.25s var(--ease-out-expo);
    border-radius: var(--radius-sm);
    width: 100%;
    position: relative;
    letter-spacing: -0.01em;
    animation: slideInLeft 0.4s var(--ease-out-expo) both;
}

.sidebar-item:nth-child(1)  { animation-delay: 0.02s; }
.sidebar-item:nth-child(2)  { animation-delay: 0.04s; }
.sidebar-item:nth-child(3)  { animation-delay: 0.06s; }
.sidebar-item:nth-child(4)  { animation-delay: 0.08s; }
.sidebar-item:nth-child(5)  { animation-delay: 0.10s; }
.sidebar-item:nth-child(6)  { animation-delay: 0.12s; }
.sidebar-item:nth-child(7)  { animation-delay: 0.14s; }
.sidebar-item:nth-child(8)  { animation-delay: 0.16s; }
.sidebar-item:nth-child(9)  { animation-delay: 0.18s; }
.sidebar-item:nth-child(10) { animation-delay: 0.20s; }
.sidebar-item:nth-child(11) { animation-delay: 0.22s; }
.sidebar-item:nth-child(12) { animation-delay: 0.24s; }

.sidebar-item:hover {
    background: var(--gradient-subtle);
    color: var(--gray-900);
    transform: translateX(3px);
}

.sidebar-item.active {
    background: var(--gradient);
    color: var(--white);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.sidebar-item.active .sidebar-icon {
    filter: brightness(10);
}

.sidebar-icon {
    font-size: 17px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.25s var(--ease-spring);
}

.sidebar-item:hover .sidebar-icon {
    transform: scale(1.15);
}

.sidebar-label {
    white-space: nowrap;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 199;
}

/* ===== Hamburger ===== */
.hamburger {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 201;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--gradient);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.open span:nth-child(2) {
    opacity: 0;
}

.hamburger.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    min-width: 0;
    padding: 32px 24px;
}

/* ===== Welcome Screen ===== */
.welcome-screen {
    max-width: 920px;
    margin: 0 auto;
    text-align: center;
    padding-top: 32px;
    animation: fadeIn 0.5s var(--ease-out-expo);
}

.welcome-title {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
    letter-spacing: -0.04em;
    animation: fadeInUp 0.6s var(--ease-out-expo);
}

.welcome-subtitle {
    font-size: 15px;
    color: var(--gray-500);
    margin-bottom: 40px;
    animation: fadeInUp 0.6s 0.08s var(--ease-out-expo) both;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 12px 22px;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(229, 231, 235, 0.6);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s var(--ease-out-expo);
    font-family: var(--font-body);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.45s var(--ease-out-expo) both;
}

/* Staggered entrance for tool cards */
.tool-card:nth-child(1)  { animation-delay: 0.06s; }
.tool-card:nth-child(2)  { animation-delay: 0.09s; }
.tool-card:nth-child(3)  { animation-delay: 0.12s; }
.tool-card:nth-child(4)  { animation-delay: 0.15s; }
.tool-card:nth-child(5)  { animation-delay: 0.18s; }
.tool-card:nth-child(6)  { animation-delay: 0.21s; }
.tool-card:nth-child(7)  { animation-delay: 0.24s; }
.tool-card:nth-child(8)  { animation-delay: 0.27s; }
.tool-card:nth-child(9)  { animation-delay: 0.30s; }
.tool-card:nth-child(10) { animation-delay: 0.33s; }
.tool-card:nth-child(11) { animation-delay: 0.36s; }
.tool-card:nth-child(12) { animation-delay: 0.39s; }

.tool-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient);
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: inherit;
    z-index: 0;
}

.tool-card:hover {
    border-color: transparent;
    box-shadow: var(--shadow-xl);
    transform: translateY(-6px);
}

.tool-card:hover::before {
    opacity: 0.06;
}

.tool-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tool-card-icon {
    font-size: 36px;
    position: relative;
    z-index: 1;
    transition: transform 0.35s var(--ease-spring);
}

.tool-card:hover .tool-card-icon {
    transform: scale(1.2) translateY(-2px);
}

.tool-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    position: relative;
    z-index: 1;
    letter-spacing: -0.01em;
    transition: color 0.25s;
}

.tool-card:hover .tool-card-name {
    color: var(--primary);
}

/* ===== Tool View ===== */
.tool-view {
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 0.45s var(--ease-out-expo);
}

.tool-header {
    margin-bottom: 28px;
}

.tool-title {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 6px;
    letter-spacing: -0.03em;
}

.tool-desc {
    font-size: 14.5px;
    color: var(--gray-500);
    line-height: 1.5;
}

/* ===== Error Message ===== */
.error-message {
    display: none;
    background: var(--red-50);
    border: 1px solid var(--red-100);
    color: var(--red-600);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

.error-message.visible {
    display: block;
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-xl);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.35s var(--ease-out-expo);
    background: rgba(255,255,255,0.6);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    margin-bottom: 20px;
    position: relative;
    animation: scaleIn 0.45s 0.1s var(--ease-out-expo) both;
}

.upload-zone:hover {
    border-color: var(--primary-light);
    background: rgba(37, 99, 235, 0.03);
    box-shadow: var(--shadow-glow);
    transform: scale(1.01);
}

.upload-zone.drag-over {
    border-color: var(--primary-light);
    background: rgba(37, 99, 235, 0.06);
    border-style: solid;
    box-shadow: 0 0 40px rgba(37, 99, 235, 0.18);
    transform: scale(1.02);
}

.upload-zone.has-file {
    border-style: solid;
    border-color: var(--green-500);
    background: var(--green-50);
}

.upload-icon {
    font-size: 44px;
    margin-bottom: 14px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

.upload-text {
    font-size: 15px;
    color: var(--gray-600);
    margin-bottom: 16px;
}

.upload-text strong {
    color: var(--primary);
}

.upload-btn {
    display: inline-block;
    padding: 10px 28px;
    background: var(--gradient);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.3s var(--ease-out-expo);
    letter-spacing: 0.01em;
}

.upload-btn:hover {
    background: var(--gradient-hover);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
    transform: translateY(-2px);
}

.upload-btn:active {
    transform: translateY(0);
}

.upload-input {
    display: none;
}

/* ===== File Info ===== */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
}

.file-info-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.file-info-details {
    flex: 1;
    min-width: 0;
}

.file-info-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-info-size {
    font-size: 12px;
    color: var(--gray-400);
}

.file-remove-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.file-remove-btn:hover {
    color: var(--red-500);
    background: var(--red-50);
}

/* ===== Options Panel ===== */
.options-panel {
    background: rgba(255,255,255,0.75);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(229, 231, 235, 0.6);
    border-radius: var(--radius-lg);
    padding: 22px;
    margin-bottom: 18px;
    animation: fadeInUp 0.35s var(--ease-out-expo) both;
}

.options-panel h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 12px;
}

.options-panel label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.options-panel input[type="text"],
.options-panel input[type="number"],
.options-panel input[type="password"],
.options-panel select,
.options-panel textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.2s;
    margin-bottom: 12px;
}

.options-panel input:focus,
.options-panel select:focus,
.options-panel textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===== Radio Option Groups ===== */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.radio-option {
    padding: 8px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    background: var(--white);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.radio-option:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.radio-option.selected {
    background: linear-gradient(135deg, rgba(30,58,138,0.08), rgba(37,99,235,0.12));
    border-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

/* ===== Thumbnail Grid ===== */
.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.thumbnail-item {
    position: relative;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    aspect-ratio: 3/4;
}

.thumbnail-item:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.thumbnail-item.selected {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.thumbnail-item canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.thumbnail-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.65);
    color: var(--white);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    padding: 3px;
}

.thumbnail-checkbox {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--gray-300);
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.thumbnail-item.selected .thumbnail-checkbox {
    background: var(--primary-light);
    border-color: var(--primary-light);
    color: var(--white);
}

/* ===== Action Button ===== */
.action-area {
    margin-bottom: 16px;
}

.action-btn {
    width: 100%;
    padding: 16px 24px;
    background: var(--gradient);
    background-size: 200% 200%;
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 0.3s var(--ease-out-expo);
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

.action-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.action-btn:hover::after {
    transform: translateX(100%);
}

.action-btn:hover {
    background: var(--gradient-hover);
    box-shadow: 0 8px 28px rgba(30, 58, 138, 0.3);
    transform: translateY(-2px);
}

.action-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
}

.action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.action-btn:disabled::after {
    display: none;
}

/* ===== Progress Bar ===== */
.progress-area {
    display: none;
    margin-bottom: 16px;
}

.progress-area.visible {
    display: block;
}

.progress-bar-track {
    width: 100%;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.progress-text {
    font-size: 13px;
    color: var(--gray-500);
    text-align: center;
}

/* ===== Result Area ===== */
.result-area {
    display: none;
    background: var(--green-50);
    border: 1px solid var(--green-100);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    margin-bottom: 16px;
}

.result-area.visible {
    display: block;
    animation: scaleIn 0.4s var(--ease-spring);
}

.result-icon {
    font-size: 36px;
    margin-bottom: 8px;
    display: block;
}

.result-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    color: var(--green-700);
    margin-bottom: 4px;
}

.result-stats {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.download-btn {
    display: inline-block;
    padding: 12px 32px;
    background: var(--green-600);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 0.2s;
    text-decoration: none;
}

.download-btn:hover {
    background: var(--green-700);
    box-shadow: 0 6px 20px rgba(22, 163, 74, 0.3);
    transform: translateY(-2px);
}

/* ===== Preview Area ===== */
.preview-area {
    margin-bottom: 16px;
}

/* ===== Signature Pad ===== */
.signature-pad-wrapper {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
}

.signature-pad {
    width: 100%;
    height: 200px;
    cursor: crosshair;
    display: block;
    touch-action: none;
}

.signature-actions {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--gray-200);
}

.signature-actions button {
    padding: 6px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-body);
    color: var(--gray-600);
    transition: all 0.2s;
}

.signature-actions button:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

/* ===== Tab Bar ===== */
.tab-bar {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 16px;
}

.tab-item {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    font-family: var(--font-body);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-item:hover {
    color: var(--gray-700);
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary-light);
    font-weight: 600;
}

/* ===== Privacy Footer ===== */
.privacy-footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--gray-400);
    border-top: 1px solid var(--gray-100);
    margin-top: 24px;
}

.privacy-footer strong {
    color: var(--gray-500);
}

/* ===== Mobile Responsive ===== */
@media (max-width: 768px) {
    .header-inner {
        padding: 0 16px;
    }

    .privacy-badge {
        display: none;
    }

    .hamburger {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        z-index: 200;
        width: 260px;
        height: calc(100vh - var(--header-height));
        transition: left 0.3s ease;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .main-content {
        padding: 20px 16px;
    }

    .tool-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .tool-card {
        padding: 16px 8px;
    }

    .tool-card-icon {
        font-size: 26px;
    }

    .tool-card-name {
        font-size: 12px;
    }

    .welcome-title {
        font-size: 22px;
    }

    .upload-zone {
        padding: 28px 16px;
    }

    .thumbnail-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 18px;
    }

    .back-link {
        font-size: 13px;
    }

    .tool-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .tool-card {
        padding: 14px 8px;
    }

    .tool-card-icon {
        font-size: 22px;
    }

    .tool-card-name {
        font-size: 11px;
    }

    .radio-group {
        flex-direction: column;
    }

    .radio-option {
        width: 100%;
        text-align: center;
    }
}

/* ===== Merge Module: Drag & Drop ===== */
.merge-drag-handle {
    cursor: grab;
    color: var(--gray-400);
    font-size: 16px;
    padding: 0 6px;
    -webkit-user-select: none;
    user-select: none;
    transition: color 0.2s;
}

.merge-drag-handle:hover {
    color: var(--gray-700);
}

.merge-file-item {
    transition: box-shadow 0.2s, background 0.2s, transform 0.2s;
}

.merge-file-item.drag-over {
    background: rgba(37, 99, 235, 0.06);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
    transform: scale(1.01);
}

.merge-drag-fallback {
    opacity: 0.9;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18) !important;
    background: white !important;
    border-radius: var(--radius-sm);
    z-index: 9999;
}

.merge-file-item.sortable-chosen {
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2);
}

/* ===== Merge Module: Page Range Input ===== */
.merge-page-range {
    width: 80px;
    padding: 5px 8px;
    font-size: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    color: var(--gray-700);
    background: var(--white);
    flex-shrink: 0;
    transition: border-color 0.2s;
}

.merge-page-range:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.merge-page-range::placeholder {
    color: var(--gray-400);
}

/* ===== PDF Editor Overlays ===== */
.edit-text-overlay { z-index: 10; }
.edit-text-overlay:hover { border-color: #93c5fd !important; background: rgba(37, 99, 235, 0.1) !important; }
.edit-mode-btn.active { background: #1e3a8a !important; color: white !important; border-color: #1e3a8a !important; }

/* =====================================================================
   v2 - Hub, grouped sidebar, results, modal, toasts, shared form widgets
   ===================================================================== */
.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-title .ht-sub { font-weight: 500; color: var(--gray-500); font-size: 0.7em; margin-left: 6px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-search-btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--gray-200);
    background: var(--white); border-radius: 999px; color: var(--gray-500); font-size: 13px; cursor: pointer; font-family: var(--font-body);
}
.header-search-btn kbd { font-size: 11px; border: 1px solid var(--gray-200); border-radius: 4px; padding: 0 5px; background: var(--gray-50); }
.header-search-btn:hover { border-color: var(--primary-light); color: var(--primary); }

/* Sidebar groups */
.sidebar { overflow-y: auto; }
.sidebar-nav { gap: 2px; }
.sidebar-group { margin-top: 10px; }
.sidebar-group-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400);
    padding: 8px 14px 4px; display: flex; align-items: center; gap: 6px;
}
.sidebar-group-title::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--cat, var(--primary-light)); }
.sidebar-item { animation: none !important; padding: 8px 14px; }
.sidebar-icon { font-size: 15px; width: 20px; text-align: center; }

/* Hub */
.welcome-screen { padding-top: 8px; max-width: 1100px; margin: 0 auto; }
.hub-hero { text-align: center; margin-bottom: 22px; }
.hub-hero .welcome-title { margin-bottom: 8px; }
.hub-hero .welcome-subtitle { margin-bottom: 18px; }
.hub-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 20px; }
.hub-badge { font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: var(--white); border: 1px solid var(--gray-200); color: var(--gray-700); }
.hub-search-wrap { position: relative; max-width: 560px; margin: 0 auto 18px; }
.hub-search-wrap svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.hub-search {
    width: 100%; padding: 14px 16px 14px 46px; border-radius: 999px; border: 1px solid var(--gray-200); font-size: 15px;
    font-family: var(--font-body); background: var(--white); box-shadow: var(--shadow-sm); color: var(--gray-800);
}
.hub-search:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 4px var(--primary-glow); }
.hub-filters { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 10px; }
.suite-tabs { display: inline-flex; background: var(--gray-100); border-radius: 999px; padding: 4px; }
.suite-tab { border: none; background: none; padding: 8px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--gray-600); cursor: pointer; font-family: var(--font-body); }
.suite-tab.active { background: var(--white); color: var(--primary); box-shadow: var(--shadow-sm); }
.cat-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.cat-chip { border: 1px solid var(--gray-200); background: var(--white); padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--gray-600); cursor: pointer; font-family: var(--font-body); }
.cat-chip:hover { border-color: var(--cat, var(--primary-light)); color: var(--cat, var(--primary)); }
.cat-chip.active { background: var(--cat, var(--primary)); border-color: var(--cat, var(--primary)); color: #fff; }
.hub-section { margin-top: 26px; }
.hub-section-title { font-family: var(--font-heading); font-size: 17px; font-weight: 700; color: var(--gray-800); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.hub-section-title::before { content: ''; width: 4px; height: 18px; border-radius: 2px; background: var(--cat, var(--primary-light)); }
.hub-empty { text-align: center; color: var(--gray-500); padding: 40px 0; }

.tool-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tool-grid.compact { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tool-card { align-items: flex-start; text-align: left; padding: 18px 16px 16px; gap: 6px; animation: none; position: relative; }
.tool-card::before { display: none; }
.tool-card:hover { border-color: var(--cat, var(--primary-light)); box-shadow: 0 10px 28px -10px rgba(15, 23, 42, .25); transform: translateY(-3px); }
.tool-card-icon {
    font-size: 22px; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--cat, #2563eb) 12%, white); margin-bottom: 4px;
}
.tool-card-name { font-size: 15px; font-weight: 700; color: var(--gray-900); font-family: var(--font-heading); }
.tool-card:hover .tool-card-name { color: var(--cat, var(--primary)); }
.tool-card-desc { font-size: 12.5px; color: var(--gray-500); line-height: 1.45; }
.tool-badge { position: absolute; top: 12px; right: 12px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; background: #fef3c7; color: #92400e; padding: 2px 7px; border-radius: 999px; }

.hub-info { margin-top: 48px; display: grid; gap: 18px; }
.hub-features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.hub-feature { background: rgba(255,255,255,.75); border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 18px; }
.hub-feature h3 { font-family: var(--font-heading); font-size: 15px; margin: 0 0 6px; color: var(--gray-900); }
.hub-feature p { font-size: 13px; color: var(--gray-600); margin: 0; line-height: 1.55; }
.hub-faq { background: rgba(255,255,255,.75); border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 8px 18px; }
.hub-faq h2 { font-family: var(--font-heading); font-size: 18px; margin: 12px 0; }
.hub-faq details { border-top: 1px solid var(--gray-100); padding: 12px 0; }
.hub-faq summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--gray-800); }
.hub-faq details p { font-size: 13.5px; color: var(--gray-600); line-height: 1.6; margin: 8px 0 0; }

/* Tool view */
.tool-view { max-width: 920px; margin: 0 auto; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--gray-500); margin-bottom: 10px; }
.tool-title { display: flex; align-items: center; gap: 10px; }
.tool-title-icon { font-size: 22px; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--cat, #2563eb) 12%, white); }
.upload-hint { font-size: 12px; color: var(--gray-400); margin-top: 10px; }
.upload-area.collapsed .upload-zone { padding: 14px 16px; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.upload-area.collapsed .upload-icon, .upload-area.collapsed .upload-hint { display: none; }
.upload-area.collapsed .upload-text { margin: 0; }
.upload-area.collapsed .upload-text strong::after { content: ' to replace'; font-weight: 400; }
.upload-zone:focus-visible { outline: 3px solid var(--primary-glow); outline-offset: 2px; }
body.drag-anywhere .upload-zone { border-color: var(--primary-light); background: rgba(37, 99, 235, 0.06); }
.file-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.file-info-icon .file-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; display: block; }
.file-move-btn { border: 1px solid var(--gray-200); background: var(--white); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; color: var(--gray-600); flex-shrink: 0; }
.file-move-btn:disabled { opacity: .35; cursor: default; }
.file-list-footer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-list-count { font-size: 12.5px; color: var(--gray-500); }

.secondary-btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border: 1px solid var(--gray-300); background: var(--white);
    color: var(--gray-700); border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font-body); transition: all .2s;
}
.secondary-btn:hover { border-color: var(--primary-light); color: var(--primary); }
.secondary-btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { border: none; background: none; color: var(--primary-light); font-weight: 600; cursor: pointer; padding: 0; font-size: inherit; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }
.action-hint { text-align: center; font-size: 12.5px; color: var(--gray-500); margin-top: 8px; }

/* Results */
.result-area { padding: 24px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }
.download-btn .dl-size { font-weight: 500; opacity: .85; font-size: .9em; }
.download-btn:disabled { opacity: .6; cursor: wait; }
.result-note { font-size: 13px; color: var(--gray-600); margin-top: 6px; }
.result-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin: 14px 0 4px; }
.result-previews.single { grid-template-columns: 1fr; justify-items: center; }
.result-previews img { width: 100%; max-height: 160px; object-fit: contain; border-radius: 8px; background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px; border: 1px solid var(--gray-200); }
.result-previews.single img { max-width: 420px; max-height: 320px; width: auto; }
.result-filelist { text-align: left; margin-top: 16px; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 10px 14px; }
.result-filelist summary { cursor: pointer; font-weight: 600; font-size: 13.5px; }
.result-filelist ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow: auto; }
.result-filelist li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--gray-100); font-size: 13px; }
.rf-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rf-size { color: var(--gray-400); font-size: 12px; }
.continue-with { margin-top: 18px; border-top: 1px dashed var(--green-100); padding-top: 14px; }
.continue-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500); margin-bottom: 8px; }
.continue-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip { border: 1px solid var(--gray-200); background: var(--white); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--gray-700); font-family: var(--font-body); }
.chip:hover { border-color: var(--primary-light); color: var(--primary); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 1000; display: none; align-items: center; justify-content: center; background: rgba(15, 23, 42, .5); padding: 16px; }
.modal.open { display: flex; animation: fadeIn .2s ease; }
.modal-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); width: 100%; max-width: 420px; padding: 24px; }
.modal-card h3 { margin: 0 0 6px; font-family: var(--font-heading); font-size: 18px; }
.modal-card p { margin: 0 0 14px; color: var(--gray-600); font-size: 13.5px; word-break: break-word; }
.modal-input-row { display: flex; gap: 8px; }
.modal-input-row input { flex: 1; padding: 11px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 15px; font-family: var(--font-body); min-width: 0; }
.modal-input-row input:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px var(--primary-glow); }
.modal-error { display: none; color: var(--red-600); font-size: 13px; margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.primary-btn { padding: 10px 20px; border: none; border-radius: var(--radius-sm); background: var(--gradient); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; font-family: var(--font-body); }
.primary-btn:hover { background: var(--gradient-hover); }

/* Toasts */
.toast-host { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: var(--gray-900); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: fadeInUp .3s var(--ease-out-expo); transition: opacity .4s, transform .4s; text-align: center; }
.toast-success { background: var(--green-700); }
.toast-error { background: var(--red-600); }
.toast.leaving { opacity: 0; transform: translateY(8px); }

/* Thumbnails: lazy placeholder */
.thumb-placeholder { width: 100%; height: 100%; background: linear-gradient(90deg, var(--gray-100), var(--gray-50), var(--gray-100)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.thumbnail-item:focus-visible { outline: 3px solid var(--primary-glow); }
.thumbnail-item.marked-delete { border-color: var(--red-500); }
.thumbnail-item.marked-delete canvas { opacity: .35; }
.thumbnail-item.marked-delete::after { content: '\2715'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 42px; color: var(--red-600); font-weight: 700; pointer-events: none; }

/* Shared option widgets for v2 modules */
.opt-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.opt-field { margin-bottom: 12px; }
.opt-field > label, .opt-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.opt-help { font-size: 12px; color: var(--gray-500); margin-top: -6px; margin-bottom: 10px; line-height: 1.5; }
.opt-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.options-panel .opt-inline input[type="number"], .options-panel .opt-inline select { width: auto; margin-bottom: 0; }
.options-panel input[type="range"] { width: 100%; accent-color: var(--primary-light); margin: 4px 0 10px; }
.options-panel input[type="color"] { width: 44px; height: 36px; border: 1px solid var(--gray-300); border-radius: 8px; padding: 2px; background: #fff; cursor: pointer; }
.check-row { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; cursor: pointer; margin-bottom: 8px !important; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary-light); margin: 0; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.seg button { padding: 8px 14px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); background: var(--white); font-size: 13px; font-weight: 600; color: var(--gray-600); cursor: pointer; font-family: var(--font-body); }
.seg button.selected { border-color: var(--primary-light); color: var(--primary); background: linear-gradient(135deg, rgba(30,58,138,0.06), rgba(37,99,235,0.1)); }
.seg button:hover { border-color: var(--primary-light); }
.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.choice-card { text-align: left; border: 1.5px solid var(--gray-200); background: var(--white); border-radius: var(--radius-md); padding: 12px 14px; cursor: pointer; font-family: var(--font-body); transition: all .2s; }
.choice-card strong { display: block; font-size: 14px; color: var(--gray-800); margin-bottom: 2px; }
.choice-card span { font-size: 12px; color: var(--gray-500); line-height: 1.4; display: block; }
.choice-card.selected { border-color: var(--primary-light); background: linear-gradient(135deg, rgba(30,58,138,0.04), rgba(37,99,235,0.08)); box-shadow: 0 0 0 3px var(--primary-glow); }
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; line-height: 1.5; margin-bottom: 14px; }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; line-height: 1.5; margin-bottom: 14px; }
.ok-box { background: var(--green-50); border: 1px solid #bbf7d0; color: var(--green-700); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; line-height: 1.5; margin-bottom: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat b { display: block; font-size: 16px; color: var(--gray-900); }
.stat span { font-size: 11.5px; color: var(--gray-500); }
.text-output { width: 100%; min-height: 260px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.5; padding: 12px; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); background: var(--white); resize: vertical; }

/* Interactive page / image canvas stage (crop, redact, img-crop, img-adjust) */
.stage-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.stage-toolbar .spacer { flex: 1; }
.stage-wrap { position: relative; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: 12px; display: flex; justify-content: center; overflow: auto; max-height: 75vh; }
.stage { position: relative; display: inline-block; line-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: var(--shadow-md); }
.stage canvas, .stage img { display: block; max-width: 100%; height: auto; }
.sel-box { position: absolute; border: 2px solid var(--primary-light); background: rgba(37, 99, 235, .08); box-shadow: 0 0 0 9999px rgba(15, 23, 42, .45); cursor: move; touch-action: none; }
.sel-box.no-shade { box-shadow: none; }
.sel-handle { position: absolute; width: 14px; height: 14px; background: #fff; border: 2px solid var(--primary-light); border-radius: 50%; transform: translate(-50%, -50%); touch-action: none; }
.sel-handle[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.sel-handle[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.sel-handle[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.sel-handle[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.sel-handle[data-h="n"] { left: 50%; top: 0; cursor: ns-resize; }
.sel-handle[data-h="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.sel-handle[data-h="w"] { left: 0; top: 50%; cursor: ew-resize; }
.sel-handle[data-h="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.redact-box { position: absolute; background: rgba(0,0,0,.85); outline: 2px solid var(--red-500); cursor: pointer; }
.redact-box button { position: absolute; top: -10px; right: -10px; width: 22px; height: 22px; border-radius: 50%; border: none; background: var(--red-600); color: #fff; font-size: 13px; line-height: 22px; cursor: pointer; padding: 0; }
.page-nav { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-600); }
.page-nav button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--gray-300); background: #fff; cursor: pointer; }
.page-nav button:disabled { opacity: .4; cursor: default; }

.img-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.img-compare figure { margin: 0; background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 8px; text-align: center; }
.img-compare img, .img-compare canvas { max-width: 100%; max-height: 260px; object-fit: contain; display: block; margin: 0 auto; }
.img-compare figcaption { font-size: 12px; color: var(--gray-500); margin-top: 6px; }
.batch-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; background: var(--white); border-radius: var(--radius-sm); overflow: hidden; }
.batch-table th, .batch-table td { padding: 8px 10px; border-bottom: 1px solid var(--gray-100); text-align: left; }
.batch-table th { background: var(--gray-50); font-size: 12px; color: var(--gray-500); font-weight: 600; }
.batch-table .good { color: var(--green-700); font-weight: 600; }
.batch-table .bad { color: var(--red-600); font-weight: 600; }

body.is-processing .action-btn { pointer-events: none; opacity: .6; }

@media (max-width: 768px) {
    /* Closed off-canvas sidebar must not be reachable by keyboard / screen readers */
    .sidebar:not(.open) { visibility: hidden; transition: left 0.3s ease, visibility 0s linear 0.3s; }
    .sidebar.open { visibility: visible; }
    /* Long file names must not blow the table past the viewport */
    .batch-table td, .batch-table th { word-break: break-word; overflow-wrap: anywhere; }
    .batch-table { table-layout: fixed; }
    .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .tool-card { padding: 14px 12px; }
    .tool-card-desc { display: none; }
    .tool-card-name { font-size: 13.5px; }
    .header-search-btn .hs-label, .header-search-btn kbd { display: none; }
    .img-compare { grid-template-columns: 1fr; }
    .sidebar { overflow-y: auto; }
}
@media (max-width: 480px) {
    .tool-card-icon { width: 36px; height: 36px; font-size: 18px; }
    .tool-card-name { font-size: 12.5px; }
    .suite-tab { padding: 7px 12px; font-size: 13px; }
    .result-actions { flex-direction: column; }
    .result-actions .download-btn, .result-actions .secondary-btn { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 2000; background: #fff; padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow-md); }
.skip-link:focus { left: 8px; }
.main-content:focus { outline: none; }

/* ===== 2026-11 refresh: icon-tile card grid, Tax One header ===== */
:root { --ink: #1a1f36; --muted: #5b6577; --rule: #e3e6eb; --page: #f5f6f8; --brand: #1e3a8a; }
body { background: var(--page); background-image: none; color: var(--ink); }

/* Header */
.header { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; border-bottom: 1px solid var(--rule); box-shadow: none; }
.header-inner { gap: 14px; }
.brand { font-family: var(--font-heading); font-weight: 700; font-size: 18px; color: var(--brand); text-decoration: none; letter-spacing: -0.02em; white-space: nowrap; }
.brand-rule { width: 1px; height: 22px; background: var(--rule); }
.back-link { color: var(--muted); font-weight: 500; font-size: 14px; padding: 4px 0; }
.back-link:hover { color: var(--brand); background: none; }
.header-title { font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.header-title::before { content: '/'; color: #c3c8d2; margin-right: 14px; font-weight: 400; }

/* Hub has the full width; the sidebar appears once a tool is open */
body.on-hub .sidebar, body.on-hub .hamburger, body.on-hub .sidebar-overlay { display: none; }
body.on-hub .main-content { padding: 48px 32px 64px; }

/* Hero */
.welcome-screen { max-width: 1240px; padding-top: 0; animation: none; }
.hub-hero { text-align: center; margin-bottom: 26px; }
.welcome-title { font-size: clamp(28px, 4vw, 42px); font-weight: 700; line-height: 1.15; letter-spacing: -0.03em; color: var(--ink); max-width: 20ch; margin: 0 auto; animation: none; }
.welcome-subtitle, .hub-hero .welcome-subtitle { font-size: 17px; line-height: 1.6; color: var(--muted); max-width: 60ch; margin: 14px auto 26px; animation: none; }
.hub-search-wrap { max-width: 560px; margin: 0 auto; }
.hub-search { height: 52px; border-radius: 12px; border: 1px solid #d5dae2; background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); font-size: 15px; }
.hub-search:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(30, 58, 138, 0.12); }

/* Category pills */
.hub-filters { margin: 0 0 8px; }
.suite-tabs { display: none; }
.cat-chips { gap: 8px; }
.cat-chip { padding: 8px 16px; font-size: 14px; font-weight: 600; color: var(--ink); background: #fff; border: 1px solid #d5dae2; }
.cat-chip:hover { border-color: var(--ink); color: var(--ink); }
.cat-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Sections + grid */
.hub-section { margin-top: 36px; }
.hub-section-title { font-size: 20px; font-weight: 700; color: var(--ink); margin: 0 0 14px; align-items: baseline; gap: 8px; }
.hub-section-title::before { display: none; }
.hub-count { font-family: var(--font-body); font-size: 14px; font-weight: 500; color: #8a93a3; }
.tool-grid, .tool-grid.compact { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }

/* Tool card */
.tool-card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 12px; text-align: left;
    padding: 24px 22px 26px; min-height: 196px;
    background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none;
    border: 1px solid var(--rule); border-radius: 12px;
    animation: none; box-shadow: none; transform: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.tool-card::before { display: none; }
.tool-card:hover { border-color: color-mix(in srgb, var(--cat) 55%, white); box-shadow: 0 10px 28px rgba(16, 24, 40, 0.08); transform: none; }
.tool-card:active { transform: none; box-shadow: 0 4px 12px rgba(16, 24, 40, 0.08); }
.tool-card:focus-visible { outline: 3px solid color-mix(in srgb, var(--cat) 45%, white); outline-offset: 2px; }
.tool-card-icon {
    width: 46px; height: 46px; border-radius: 11px; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--cat); color: #fff; font-size: 0; transition: none;
}
.tool-card:hover .tool-card-icon { transform: none; }
.tool-card-name { font-size: 17px; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; text-align: left; }
.tool-card:hover .tool-card-name { color: var(--ink); }
.tool-card-desc { font-size: 13.5px; line-height: 1.5; color: var(--muted); text-align: left; margin: 0; }

/* Tool view */
.tool-title { display: flex; align-items: center; gap: 14px; }
.tool-title-icon { width: 42px; height: 42px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--cat); color: #fff; font-size: 0; flex: none; }

/* Sidebar */
.sidebar { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; border-right: 1px solid var(--rule); }
.sidebar-item { animation: none; padding: 8px 12px; color: #3d4556; border-radius: 8px; }
.sidebar-item:hover { background: var(--page); color: var(--ink); transform: none; }
.sidebar-item.active { background: #eef2fb; color: var(--brand); box-shadow: none; font-weight: 600; }
.sidebar-icon { width: 18px; height: 18px; font-size: 0; color: var(--cat, var(--muted)); background: none; transform: none; }
.sidebar-item.active .sidebar-icon, .sidebar-item:hover .sidebar-icon { transform: none; background: none; }
.sidebar-group-title { text-transform: none; letter-spacing: 0; font-size: 12.5px; font-weight: 700; color: var(--ink); }
.sidebar-group-title::before { display: none; }

/* Info block */
.hub-info { margin-top: 64px; }
.hub-features { gap: 16px; }
.hub-feature { background: #fff; border: 1px solid var(--rule); border-radius: 12px; padding: 22px; }
.hub-feature h3 { font-size: 16px; font-weight: 700; color: var(--ink); }
.hub-feature p { color: var(--muted); font-size: 14px; }
.hub-faq { background: #fff; border: 1px solid var(--rule); border-radius: 12px; padding: 8px 22px; }

@media (max-width: 768px) {
    .brand-rule, .header-title::before, .back-link { display: none; }
    body.on-hub .main-content { padding: 28px 16px 48px; }
    .tool-grid, .tool-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .tool-card { padding: 16px; min-height: 0; gap: 10px; }
    .tool-card-icon { width: 40px; height: 40px; }
    .tool-card-name { font-size: 15px; }
    .tool-card-desc { display: none; }
}
.hub-section.hub-all { margin-top: 22px; }
.sidebar-item.active .sidebar-icon, .sidebar-item:hover .sidebar-icon { color: var(--cat, var(--brand)); filter: none; opacity: 1; }
