:root {
    --primary: #000;
    --background: #fff;
    --gray-50: #fafafa;
    --gray-100: #f4f4f5;
    --gray-200: #e4e4e7;
    --gray-300: #d4d4d8;
    --gray-400: #a1a1aa;
    --gray-600: #52525b;
    --accent: #18181b;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --radius: 6px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

html {
    scrollbar-gutter: stable;
    overflow-y: scroll;
    scroll-behavior: smooth;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--background);
    color: var(--primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-right: 0 !important;
}

.site-header {
    padding: 2rem 1rem 1.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.logo-container {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: transform 0.2s ease;
}

.logo-container:hover {
    transform: translateY(-1px);
}

#title {
    font-family: "Noto Serif SC", serif;
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(to right, var(--accent), var(--gray-600));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-image {
    height: 48px;
    width: auto;
}

.main-content {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 1rem;
}

.search-form {
    background: var(--background);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 2px solid var(--gray-200);
    margin-bottom: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-form.searching {
    transform: scale(0.98) translateY(-8px);
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.input-group {
    display: grid;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.search-input-container {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

.semantic-toggle {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    transform-origin: center;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    cursor: pointer;
    padding: 5px 10px;
    color: var(--gray-600);
    transition: all 0.2s ease;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    font-weight: 500;
    will-change: transform;
}

.semantic-toggle:hover {
    color: var(--primary);
    background-color: var(--gray-100);
    border-color: var(--gray-300);
    transform: translateY(-50%);
}

.semantic-toggle:active {
    transform: translateY(-50%);
    background-color: var(--gray-200);
}

.semantic-toggle.active {
    color: var(--background);
    background-color: var(--primary);
    border-color: var(--primary);
}

.semantic-toggle svg {
    width: 14px;
    height: 14px;
}

.semantic-label {
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.semantic-toggle.active svg {
    animation: none;
}

@keyframes sparkle-no-scale {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes sparkle {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

#query {
    padding-right: 120px;
}

input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    color: var(--primary);
    background: var(--background);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

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

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

.search-button {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    color: var(--background);
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    position: relative;
    margin-top: 10px;
}

.search-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.search-button:active {
    transform: scale(0.98);
    box-shadow: none;
    background: var(--gray-600);
}

.loading-container {
    height: 2px;
    background: var(--gray-100);
    border-radius: 1px;
    overflow: hidden;
}

#loadingBar {
    height: 100%;
    background: var(--primary);
    transition: width 0.15s ease;
}

.random-string {
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-600);
    font-weight: 500;
    height: 1.2em;
    min-height: 1.2em;
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#randomStringDisplay.fade-out {
    opacity: 0;
    transform: translateY(-10px);
    visibility: hidden;
}

#randomStringDisplay.fade-in {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

#results {
    margin-top: 1.5rem;
}

.result-card {
    padding: 1rem;
    background: var(--background);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    gap: 1.25rem;
    align-items: center;
    transform-origin: center;
    will-change: transform;
}

.result-card:hover {
    border-color: var(--primary);
    transform: scale(1.01);
    box-shadow: var(--shadow);
}

.result-card:active {
    transform: scale(0.98);
    box-shadow: none;
    background: var(--gray-50);
}

.preview-frame-container {
    position: relative;
    width: 180px;
    height: 100px;
    flex-shrink: 0;
    border-radius: var(--radius);
    overflow: hidden;
    order: 2;
}

.preview-frame-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 37%, var(--gray-100) 63%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite linear;
}

.preview-frame {
    position: relative;
    width: 180px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s ease;
    cursor: pointer;
}

.preview-frame:hover {
    transform: scale(1.02);
}

.preview-frame:active {
    transform: scale(0.98);
}

.preview-frame.loaded {
    opacity: 1;
}

.result-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.125rem 0;
    order: 1;
    justify-content: center;
}

.result-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    margin: 0;
    line-height: 1.4;
}

.result-text {
    font-size: 1rem;
    color: var(--gray-600);
    line-height: 1.6;
    margin: 0;
}

.result-meta {
    font-size: 0.875rem;
    color: var(--gray-400);
    margin: 0;
    line-height: 1.5;
}

.highlight {
    color: var(--accent);
    background: var(--gray-100);
    padding: 0.125rem 0.375rem;
    border-radius: 2px;
    font-weight: 500;
}

.site-footer {
    text-align: center;
    padding: 2rem 0;
}

.github-link {
    color: var(--primary);
    opacity: 0.5;
    transition: opacity 0.2s;
}

.github-link:hover {
    opacity: 1;
}

@media (max-width: 640px) {
    .main-content {
        padding: 0 1rem;
        max-width: 100%;
    }
    
    #title {
        font-size: 3rem;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: 1.5rem 1rem 1.25rem;
        margin-bottom: 1.25rem;
    }

    #title {
        font-size: 2.5rem;
    }

    .logo-image {
        height: 40px;
    }

    .search-form {
        padding: 1rem;
    }

    .input-group {
        gap: 0.75rem;
    }
    
    input {
        padding: 0.75rem;
        font-size: 1rem;
    }

    .result-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.875rem;
        gap: 0.875rem;
    }
    
    .preview-frame-container {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
        order: 1;
    }
    
    .preview-frame {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }
    
    .result-content {
        width: 100%;
        order: 2;
        justify-content: flex-start;
    }
    
    .result-card h3 {
        font-size: 1rem;
    }
    
    .result-text {
        font-size: 0.9375rem;
    }
    
    .result-meta {
        font-size: 0.8125rem;
    }
    
    .tag {
        padding: 0.125rem 0.5rem;
        margin-right: 0.375rem;
        letter-spacing: 0.04em;
    }

    .result-card:hover {
        transform: scale(1.005);
    }
    
    .result-card:active {
        transform: scale(0.99);
    }

    .result-card h3 .tag {
        letter-spacing: 0.06em;
    }


    
    .input-row label {
        flex: none;
        margin-bottom: 0.25rem;
    }
    
    .input-row input {
        width: 100%;
    }

    .advanced-options {
        padding: 0 0.75rem;
    }

    .advanced-options.show {
        padding: 0.75rem;
    }

    .input-row {
        margin-bottom: 0.5rem;
    }

    .input-row:last-child {
        margin-bottom: 0;
    }

    .input-row label {
        font-size: 0.8125rem;
        margin-bottom: 0.25rem;
    }

    .input-row input {
        padding: 0.5rem;
        font-size: 0.875rem;
    }

    .semantic-label {
        display: inline-block;
        font-size: 0.7rem;
    }
    
    #query {
        padding-right: 90px;
    }
    
    .semantic-toggle {
        padding: 5px 8px;
    }
}

.tag {
    display: inline-block;
    background-color: var(--gray-100);
    color: var(--primary);
    padding: 0.125rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 700;
    margin-right: 0.5rem;
    border: 1px solid var(--gray-200);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    letter-spacing: 0.05em;
}

.tag:active {
    transform: scale(0.95);
    background-color: var(--gray-200);
}

.result-card h3 .tag {
    margin-right: 0.75rem;
    letter-spacing: 0.075em;
    vertical-align: middle;
}

input:active, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    transform: none;
}

.search-input-container:focus-within .semantic-toggle {
    transform: translateY(-50%);
}

.search-input-container:focus-within .semantic-toggle:hover {
    transform: translateY(-50%);
}

.search-input-container:focus-within .semantic-toggle:active {
    transform: translateY(-50%);
    background-color: var(--gray-200);
}

.input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 10px;
}

.input-row label {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.input-row input {
    flex: 1;
}

input::placeholder {
    color: var(--gray-400);
}

.toggle-button {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    color: var(--gray-600);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    width: 100%;
    text-align: center;
    margin: 0.5rem 0;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.toggle-button:hover {
    background: var(--gray-100);
}

.toggle-button .arrow {
    font-size: 0.75rem;
    transition: transform 0.3s ease;
}

.toggle-button.active .arrow {
    transform: rotate(180deg);
}

.advanced-options {
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    opacity: 0;
    margin-top: 0;
    padding: 0 1rem;
}

.advanced-options.show {
    max-height: fit-content;
    opacity: 1;
    margin-top: 0.5rem;
    padding: 1rem;
}

.progress-section {
    margin-top: 3rem;
}

.loading-indicator {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
}

#randomStringDisplay {
    transition: opacity 0.3s ease-in-out;
}

.fade-in {
    opacity: 1;
}

.fade-out {
    opacity: 0;
}

::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--gray-50);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-200);
    border: 3px solid var(--gray-50);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-300);
}

input,
button {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.error-message {
    background-color: #f0f0f0;
    color: #333;
    border: 2px solid #ccc;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    align-items: center;
    gap: 1rem;
}

.error-message:hover {
    border-color: #bbb;
    box-shadow: var(--shadow);
    transform: scale(1.02);
}

.error-message:active {
    transform: scale(0.98);
    box-shadow: none;
    background-color: #e0e0e0;
}

.error-message h3 {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
}

.error-message ul {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 32px;
    cursor: pointer;
    user-select: none;
    height: 24px;
    margin-top: 10px;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 18px;
    width: 18px;
    background-color: var(--background);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary);
    transform: translateY(-50%) scale(1.05);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-50%) scale(1.05);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 4.5px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid var(--background);
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
    animation: checkmark 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.checkbox-row {
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
    margin-top: 0px;
}

.checkbox-label {
    font-size: 0.875rem;
    color: var(--gray-600);
    transition: color 0.2s ease;
    line-height: 1;
    padding-top: 1px;
}

.checkbox-container:hover .checkbox-label {
    color: var(--primary);
}

@keyframes checkmark {
    0% {
        opacity: 0;
        transform: rotate(45deg) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: rotate(45deg) scale(1);
    }
}

.checkbox-container:active .checkmark {
    transform: translateY(-50%) scale(0.95);
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #fff;
        --background: #18181b;
        --gray-50: #27272a;
        --gray-100: #3f3f46;
        --gray-200: #52525b;
        --gray-300: #71717a;
        --gray-400: #a1a1aa;
        --gray-600: #d4d4d8;
        --accent: #e4e4e7;
    }

    .error-message {
        background-color: var(--gray-50);
        color: var(--gray-600);
        border-color: var(--gray-100);
    }

    .error-message:hover {
        border-color: var(--gray-200);
    }

    .error-message:active {
        background-color: var(--gray-100);
    }
}

.tooltip {
    position: absolute;
    top: -35px;
    right: 0;
    background: var(--primary);
    color: var(--background);
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 0.7rem;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 10;
    transform: translateY(5px);
    box-shadow: var(--shadow-sm);
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: -4px;
    right: 10px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--primary);
}

.tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.keywords-container {
    display: none;
    margin: 0.5rem 0 1.25rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: var(--background);
    border: 2px solid var(--gray-200);
    transition: all 0.3s ease;
}

.keywords-container.show {
    display: block;
    animation: fade-in 0.3s ease;
}

.keywords-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem 0.5rem;
    justify-content: space-between;
}

.keyword-tag {
    background: var(--gray-50);
    color: var(--primary);
    padding: 0.1875rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    border: 1px solid var(--gray-200);
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 0.125rem;
    flex: 0 0 auto;
}

.keyword-tag:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.keyword-tag:active {
    transform: translateY(0);
    background-color: var(--gray-100);
}

.keyword-tag.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 480px) {
    .keywords-container {
        padding: 0.5rem;
        margin: 0.375rem 0 1rem;
    }
    
    .keywords-tags {
        gap: 0.3125rem 0.375rem;
    }
    
    .keyword-tag {
        font-size: 0.6875rem;
        padding: 0.125rem 0.375rem;
        margin-bottom: 0.125rem;
    }
}

.copy-button {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--primary);
    color: var(--background);
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding: 5px;
}

.preview-frame-container:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background: var(--primary);
    opacity: 0.9;
    transform: scale(1.1);
}

.copy-button:active {
    transform: scale(0.95);
}

.copy-icon {
    width: 16px;
    height: 16px;
    filter: invert(1);
}

.copy-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: var(--background);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: fade-in 0.3s ease;
}

.copy-toast.fade-out {
    animation: fade-out 0.3s ease;
}

@keyframes fade-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes fade-out {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, 10px); }
}

@media (max-width: 480px) {
    .copy-button {
        opacity: 1;
        top: 8px;
        right: 8px;
    }
}

@media (prefers-color-scheme: dark) {
    .copy-icon {
        filter: none;
    }
}