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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --bg-color: #f8fafc;
    --surface-color: rgba(255, 255, 255, 0.4);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: url('../images/background.png') center/cover fixed;
    min-height: 100vh;
    padding: 1.5rem 1rem;
    color: var(--text-primary);
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    z-index: -1;
}

@keyframes gradientShift {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ===========================
   Header
   =========================== */
.header {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 0.25rem 1.5rem;
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.header-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.125rem 1rem;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-title::before {
    content: '✨';
    font-size: 1.25rem;
    -webkit-text-fill-color: initial;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(180deg); }
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Header Dropdown */
.dropdown-container {
    position: relative;
}

.header-dropdown-menu {
    position: fixed;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.2);
    min-width: 180px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.header-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.header-dropdown-menu .dropdown-menu-item {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.header-dropdown-menu .dropdown-menu-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.header-dropdown-menu .dropdown-menu-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.header-dropdown-menu .dropdown-menu-item:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
}

.header-dropdown-menu .dropdown-menu-item i {
    width: 16px;
    text-align: center;
}

/* 危険アクション用スタイル */
.header-dropdown-menu .dropdown-menu-item.danger {
    color: #dc2626;
}

.header-dropdown-menu .dropdown-menu-item.danger:hover {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    padding: 0.6rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: inherit;
    white-space: nowrap;
}

.btn i {
    font-size: 0.875rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

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

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #475569;
    font-size: 1rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    font-family: inherit;
    color: #1e293b;
    font-weight: 500;
}

.search-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), 0 4px 12px rgba(102, 126, 234, 0.15);
    background: rgba(255, 255, 255, 0.85);
}

.search-input::placeholder {
    color: #64748b;
    font-weight: 500;
}

.search-hint {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: #64748b;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.search-hint i {
    font-size: 0.7rem;
}

.search-hint span {
    font-weight: 600;
}

.search-input:focus ~ .search-hint {
    opacity: 0.5;
}

.search-clear-btn {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(239, 68, 68, 0.1);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #ef4444;
    font-size: 0.9rem;
    z-index: 10;
}

.search-clear-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.search-clear-btn:active {
    transform: translateY(-50%) scale(0.95);
}

/* 検索ボックスに入力がある時はヒントを隠してクリアボタンを表示 */
.search-input:not(:placeholder-shown) ~ .search-hint {
    display: none;
}

/* ===========================
   Category Tabs
   =========================== */
.category-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: grab;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #1e293b;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.tab-btn.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.tab-btn.drag-over {
    border-color: var(--primary-color);
    border-width: 2px;
}

.tab-btn:hover {
    border-color: rgba(102, 126, 234, 0.5);
    color: var(--primary-color);
    background: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.tab-btn i {
    font-size: 0.875rem;
}

/* ===========================
   Tools Grid
   =========================== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    grid-auto-rows: minmax(240px, auto);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
}

@media (max-width: 1400px) {
    .tools-grid {
        max-height: calc((100vw - 2rem - 4.5rem) * 2 / 5 + 1.5rem);
    }
}

.tool-card {
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 1px 0.875rem 1.25rem 0.875rem;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: default;
    position: relative;
    overflow: visible;
    border: 1px solid rgba(255, 255, 255, 0.3);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 240px;
    max-width: 240px;
}

.tool-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
    transform: scale(0.98);
    transition: all 0.2s ease;
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: var(--radius-xl);
    padding: 2px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3), rgba(118, 75, 162, 0.3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tool-card:hover {
    box-shadow: 0 12px 48px 0 rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 0.95);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-card-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: grab;
    position: relative;
    margin-bottom: 0.5rem;
}

.tool-card-header:active {
    cursor: grabbing;
}

.drag-handle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.2s ease;
    padding: 0;
}

.drag-handle:hover {
    background: rgba(100, 116, 139, 0.08);
    border-radius: var(--radius-md);
}

.drag-handle:active {
    cursor: grabbing;
    background: rgba(100, 116, 139, 0.12);
}

.drag-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 1px 4px;
    background: rgba(100, 116, 139, 0.15);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.drag-handle:hover .drag-dots {
    background: rgba(100, 116, 139, 0.25);
}

.drag-dots .dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: rgba(71, 85, 105, 0.6);
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.drag-handle:hover .dot {
    background: rgba(71, 85, 105, 0.85);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
}

.tool-card-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
    flex-shrink: 0;
    margin-bottom: 0.75rem;
    position: relative;
}

.tool-card-clickable-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: pointer;
    background: transparent;
    text-decoration: none;
}

.tool-card-clickable-overlay:hover {
    background: rgba(102, 126, 234, 0.05);
    border-radius: var(--radius-md);
}

.tool-icon,
.tool-info,
.tool-name,
.tool-description {
    -webkit-user-drag: none;
    user-drag: none;
    position: relative;
    z-index: 0;
    pointer-events: none;
}

.tool-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    justify-content: center;
    font-size: 1.875rem;
    color: white;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.tool-card:hover .tool-icon {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.tool-info {
    text-align: left;
    flex: 1;
    min-width: 0;
}

.tool-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-category {
    display: none;
}

.tool-description {
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 500;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: left;
}

.tool-url {
    display: none;
}

/* ===========================
   Sub Links (Card Internal)
   =========================== */
.sub-links-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    z-index: 5;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Card Sub Links Section */
.card-sublinks-section {
    margin-top: auto;
    width: 100%;
    pointer-events: auto;
    cursor: default !important;
    position: relative;
    z-index: 10;
    text-align: left;
    -webkit-user-drag: none;
    user-drag: none;
}

.card-sublinks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.card-sublinks-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-sublinks-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 0.4rem;
    max-height: 120px;
    overflow-y: auto;
}

.card-sublinks-list::-webkit-scrollbar {
    width: 4px;
}

.card-sublinks-list::-webkit-scrollbar-track {
    background: rgba(226, 232, 240, 0.3);
    border-radius: 2px;
}

.card-sublinks-list::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
}

.card-sublinks-list::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

.card-sublink-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    text-decoration: none;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 500;
    background: transparent;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    cursor: pointer !important;
}

.card-sublink-item:hover {
    background: rgba(102, 126, 234, 0.08);
    color: var(--primary-color);
}

.card-sublink-emoji {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.card-sublink-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}



.card-sublinks-empty {
    text-align: center;
    padding: 0.5rem;
    color: #cbd5e1;
    font-size: 0.7rem;
    font-style: italic;
}

.card-sublink-add-btn {
    display: block;
    color: var(--primary-color);
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.25rem 0;
    transition: opacity 0.2s ease;
    cursor: pointer !important;
    background: none;
    border: none;
    font-family: inherit;
    position: relative;
    z-index: 10;
    text-align: center;
    width: 100%;
    margin-top: 0.25rem;
}

.card-sublink-add-btn:hover {
    opacity: 0.7;
}

/* Card Menu Button */
.card-menu-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 1rem;
    opacity: 0;
    z-index: 10;
}

.tool-card:hover .card-menu-btn {
    opacity: 1;
}

.card-menu-btn:hover {
    background: var(--surface-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

/* Dropdown Menu */
.card-dropdown-menu {
    position: absolute;
    top: 3rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.3);
    min-width: 150px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.card-dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu-item {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.dropdown-menu-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.dropdown-menu-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.dropdown-menu-item:hover {
    background: rgba(248, 250, 252, 0.8);
}

.dropdown-menu-item.edit:hover {
    color: var(--primary-color);
}

.dropdown-menu-item.delete:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.dropdown-menu-item i {
    width: 16px;
    text-align: center;
}

/* ===========================
   Empty State
   =========================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.empty-state i {
    font-size: 4rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* ===========================
   Modal
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

/* Icon Picker Modal should be above other modals */
#iconPickerModal {
    z-index: 1100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px 0 rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

.modal-small {
    max-width: 400px;
}

.modal-large {
    max-width: 800px;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-header h2 {
    font-size: 1.5rem;
    color: #0f172a;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.close-btn {
    background: rgba(255, 255, 255, 0.5);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.modal-body {
    padding: 2rem;
    background: rgba(255, 255, 255, 0.4);
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(226, 232, 240, 0.6);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ===========================
   Form Styles
   =========================== */
#toolForm {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1e293b;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.required {
    color: var(--danger-color);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid rgba(226, 232, 240, 0.4);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: all 0.2s ease;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #1e293b;
    font-weight: 500;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: rgba(255, 255, 255, 0.7);
}

.form-input::placeholder {
    color: #64748b;
}

textarea.form-input {
    resize: vertical;
}

.color-input {
    height: 50px;
    cursor: pointer;
}

.help-text {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.help-text a {
    color: var(--primary-color);
    text-decoration: none;
}

.help-text a:hover {
    text-decoration: underline;
}

/* Sub Links Manager (in modal) */
.sub-links-manager {
    margin-top: 1rem;
}

.sub-link-manager-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(248, 250, 252, 0.8);
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    border: 1px solid rgba(226, 232, 240, 0.5);
}

.sub-link-manager-emoji {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sub-link-manager-info {
    flex: 1;
    min-width: 0;
}

.sub-link-manager-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-link-manager-url {
    font-size: 0.75rem;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-link-manager-actions {
    display: flex;
    gap: 0.5rem;
}

.sub-link-manager-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #64748b;
    font-size: 0.85rem;
}

.sub-link-manager-btn:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.sub-link-manager-btn.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid rgba(226, 232, 240, 0.4);
}

.confirm-text {
    padding: 1.5rem 2rem;
    color: #334155;
    font-size: 1rem;
    font-weight: 500;
}

/* ===========================
   Icon Type Selector
   =========================== */
.icon-type-selector {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    flex: 1;
    min-width: 150px;
}

.radio-label:hover {
    border-color: var(--primary-color);
    background: var(--bg-color);
}

.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.radio-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--primary-color);
}

.radio-label span {
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Favicon Image Style */
.tool-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}

/* ===========================
   Category Checkboxes
   =========================== */
.category-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
}

.category-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.category-checkbox-item:hover {
    border-color: var(--primary-color);
    background: var(--surface-color);
}

.category-checkbox-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.category-checkbox-item.checked {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

.category-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    cursor: pointer;
}

.category-checkbox-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
}

.category-checkbox-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* ===========================
   Category Management Modal
   =========================== */
.category-management {
    padding: 2rem;
}

.category-list {
    margin-bottom: 2rem;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    border: 2px solid var(--border-color);
}

.category-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.category-item-info {
    flex: 1;
}

.category-item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.category-item-id {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.category-item-actions {
    display: flex;
    gap: 0.5rem;
}

.category-item-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.add-category-form h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.form-row .form-input {
    flex: 1;
    min-width: 150px;
}

.color-input-small {
    width: 60px;
    height: 45px;
    cursor: pointer;
    padding: 0.25rem;
}

/* ===========================
   Drop Zone
   =========================== */
.drop-zone {
    border: 3px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem 2rem;
    text-align: center;
    background: var(--bg-color);
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 1.5rem;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.1);
    border-style: solid;
    transform: scale(1.02);
}

.drop-zone-content i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: block;
    opacity: 0.7;
}

.drop-zone-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.drop-zone-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.form-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-divider::before,
.form-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.form-divider span {
    white-space: nowrap;
}

/* ===========================
   Icon Picker
   =========================== */
.icon-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.icon-picker-btn {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-picker-btn #selectedIconPreview {
    font-size: 1.25rem;
}

.icon-picker-content {
    padding: 1.5rem 2rem 2rem;
}

.icon-picker-search {
    position: relative;
    margin-bottom: 1.5rem;
}

.icon-picker-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.icon-picker-search .form-input {
    padding-left: 3rem;
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
}

.icon-picker-item {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0.5rem;
    background: var(--surface-color);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-picker-item:hover {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.05);
    transform: translateY(-2px);
}

.icon-picker-item.selected {
    border-color: var(--primary-color);
    background: rgba(79, 70, 229, 0.1);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.icon-picker-item i {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.icon-picker-item-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    word-break: break-word;
    line-height: 1.2;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 1200px) {
    .tools-grid {
        grid-template-columns: repeat(4, 1fr);
        max-height: calc((100vw - 2rem - 4.5rem) * 2 / 4 + 1.5rem);
    }
}

@media (max-width: 900px) {
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
        max-height: calc((100vw - 2rem - 3rem) * 2 / 3 + 1.5rem);
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem;
    }

    .header {
        padding: 1rem;
        flex-direction: column;
        align-items: stretch;
    }

    .header-title {
        font-size: 1.1rem;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: calc((100vw - 1rem - 1.5rem) * 2 / 2 + 1.5rem);
    }

    .category-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

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

    #toolForm {
        padding: 1.5rem;
    }

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

    .modal-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 1rem;
    }

    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .tool-card {
        padding: 1rem 0.75rem;
    }
    
    .tool-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }
    
    .tool-name {
        font-size: 0.8rem;
    }
    
    .tool-description {
        font-size: 0.7rem;
    }

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

    .tool-action-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===========================
   Import Mode Modal
   =========================== */
.import-info {
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding: 1.25rem;
    background: rgba(102, 126, 234, 0.25);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary-color);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

.import-mode-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.import-mode-option {
    display: block;
    cursor: pointer;
}

.import-mode-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.import-mode-content {
    padding: 1.25rem;
    border: 2px solid rgba(226, 232, 240, 0.7);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
    transition: all 0.2s ease;
}

.import-mode-option input[type="radio"]:checked + .import-mode-content {
    border-color: var(--primary-color);
    background: rgba(102, 126, 234, 0.25);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.import-mode-content:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.import-mode-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #0f172a;
    font-weight: 700;
}

.import-mode-header i {
    font-size: 1.25rem;
}

.import-mode-description {
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
}

.warning-text {
    color: #dc2626;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.9);
}

.import-mode-details {
    font-size: 0.85rem;
    color: #334155;
    font-weight: 600;
    padding-left: 2rem;
}

.import-mode-details div {
    margin-bottom: 0.25rem;
}

/* ===========================
   Reset Data Modal
   =========================== */
.reset-warning-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: rgba(220, 38, 38, 0.1);
    border: 2px solid #dc2626;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.reset-info {
    font-size: 0.95rem;
    line-height: 1.6;
}

.reset-confirmation-input {
    border-top: 1px solid rgba(226, 232, 240, 0.7);
    padding-top: 1.5rem;
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tool-card {
    animation: fadeIn 0.3s ease;
}

/* ===========================
   Scrollbar Styling
   =========================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.tools-grid::-webkit-scrollbar {
    width: 6px;
}

.tools-grid::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: var(--radius-sm);
}
