@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+JP:wght@300;400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Shippori+Antique&display=swap');

:root {
    --primary-orange: #f97316;
    --primary-orange-dark: #ea580c;
    --secondary-amber: #f59e0b;
    --accent-green: #10b981;
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;
}

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    min-height: 100vh;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

/* Glass morphism effect */
.glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.glass-dark {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Modern card design - Clean & Professional */
.modern-card {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--neutral-200);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.modern-card:hover {
    border-color: var(--primary-orange);
    background: linear-gradient(135deg, #ffffff 0%, #fefefe 100%);
}

.modern-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-orange), var(--secondary-amber));
    border-radius: 16px 16px 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* Enhanced button styles - Clean & Modern */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--secondary-amber) 100%);
    border: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-height: 44px;
    /* タッチしやすい最小サイズ */
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    /* iOSのタップハイライト無効化 */
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-orange-dark) 0%, var(--primary-orange) 100%);
    border-color: var(--primary-orange);
    transform: scale(1.02);
}

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

/* Process steps enhancement */
.process-step {
    position: relative;
    transition: all 0.3s ease;
    z-index: 10;
}





.process-circle {
    background: var(--neutral-200);
    border: 2px solid var(--neutral-300);
    transition: all 0.3s ease;
    color: var(--neutral-600);
}

.process-circle.active {
    background: linear-gradient(135deg, var(--primary-orange) 0%, var(--secondary-amber) 100%);
    border: 2px solid var(--primary-orange);
    color: white;
}

/* Loading animation enhancement */
.loading-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner-circle {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Tab design enhancement */
.tab-container {
    background: var(--neutral-50);
    border-radius: 12px;
    padding: 4px;
    display: flex;
    gap: 4px;
}

/* Bottom Fixed tab navigation */
.tab-navigation-fixed {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--neutral-200);
    padding: 12px 16px;
    transition: all 0.3s ease;
    transform: translateY(100%);
    opacity: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}

.tab-navigation-fixed.visible {
    transform: translateY(0);
    opacity: 1;
}

.tab-navigation-fixed .tab-container {
    max-width: 400px;
    margin: 0 auto;
    border: 1px solid var(--neutral-200);
}

.tab-button {
    flex: 1;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    background: transparent;
    color: var(--neutral-600);
    min-height: 44px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
}

.tab-button:hover {
    background: var(--neutral-100);
    color: var(--neutral-700);
}

.tab-button.active {
    background: white;
    color: var(--primary-orange);
    border: 1px solid var(--primary-orange);
    font-weight: 600;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-orange);
    border-radius: 2px 2px 0 0;
}

/* Result card enhancements - Clean Design */
.result-card {
    border-radius: 12px;
    border: 1px solid var(--neutral-200);
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
    background: white;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-orange), var(--secondary-amber));
    border-radius: 12px 12px 0 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.result-card:hover {
    border-color: var(--primary-orange);
    background: linear-gradient(135deg, #ffffff 0%, #fffbf7 100%);
}

/* Tag design */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.tag-basic {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    color: var(--primary-orange-dark);
}

.tag-ai {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: var(--accent-blue);
}

.tag-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: var(--secondary-amber);
}

/* Diff-style highlights */
.diff-container {
    display: inline-block;
    line-height: 1.6;
}

.diff-removed {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    text-decoration: line-through;
    text-decoration-color: #dc2626;
    text-decoration-thickness: 2px;
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 2px;
    font-weight: 500;
}

.diff-added {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #16a34a;
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 2px;
    font-weight: 500;
}

.diff-warning {
    background: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    color: #ea580c;
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 2px;
    border: 1px dashed #ea580c;
    cursor: help;
    position: relative;
}

.diff-warning:not(.legend-item):hover::after {
    content: attr(data-reason);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--neutral-800);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 1000;
    margin-bottom: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    min-width: 150px;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
}

.diff-warning:not(.legend-item):hover::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--neutral-800);
    z-index: 1001;
}

/* Input enhancements */
.modern-input {
    border: 2px solid var(--neutral-200);
    border-radius: 12px;
    transition: all 0.3s ease;
    background: white;
}

.modern-input:focus {
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
    outline: none;
}

/* Animation utilities */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* Mobile-first responsive improvements */
@media (max-width: 768px) {
    /* プロセスステップのモバイル最適化 */

    .process-step {
        z-index: auto;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .process-step span {
        font-size: 14px;
        font-weight: 600;
    }

    .process-circle {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    /* カードデザインのモバイル最適化 */
    .modern-card {
        border-radius: 12px;
        margin: 0 -8px;
        border: 1px solid var(--neutral-200);
    }

    .result-card {
        border-radius: 12px;
        margin-bottom: 16px;
        padding: 16px !important;
    }

    /* 下部タブナビゲーションのモバイル最適化 */
    .tab-navigation-fixed {
        padding: 10px 12px;
    }

    .tab-navigation-fixed .tab-container {
        max-width: 100%;
        margin: 0;
    }

    .tab-button {
        padding: 10px 8px;
        font-size: 13px;
        min-height: 44px;
    }

    /* モバイルでは結果エリアの下にスペースを確保 */
    .modern-card {
        margin-bottom: 80px;
    }

    /* メインコンテンツのモバイル最適化 */
    main {
        padding: 16px !important;
    }

    .modern-card .p-8 {
        padding: 20px !important;
    }

    /* テキストエリアのモバイル最適化 */
    .modern-input {
        font-size: 16px;
        /* iOS zoom防止 */
        padding: 16px !important;
        min-height: 120px;
    }

    /* ボタンのモバイル最適化 */
    .btn-primary {
        width: 100%;
        padding: 16px 24px;
        font-size: 16px;
        min-height: 48px;
    }

    .reset-button {
        padding: 8px 12px;
        font-size: 12px;
        top: 8px;
        right: 8px;
    }

    /* SNSプレビューのモバイル最適化 */
    .modern-card .space-y-8>div {
        margin-bottom: 24px;
    }

    /* 凡例のモバイル最適化 */
    .space-y-4>div {
        margin-bottom: 12px;
        padding: 12px;
    }

    /* カテゴリアイコンのモバイル最適化 */
    .category-icon {
        width: 20px;
        height: 20px;
        font-size: 9px;
    }

    .highlight-category-icon {
        width: 18px;
        height: 18px;
        font-size: 8px;
    }
}

/* Tablet optimization */
@media (min-width: 769px) and (max-width: 1024px) {

    main {
        padding: 24px;
    }

    .modern-card {
        margin: 0 auto;
        max-width: 90%;
    }

    .tab-navigation-sticky {
        padding: 16px 20px;
    }

    .tab-navigation-sticky .tab-container {
        max-width: 500px;
    }

    .result-card {
        padding: 20px;
    }
}

/* Desktop enhancements */
@media (min-width: 1025px) {
    .modern-card {
        max-width: 1200px;
        margin: 0 auto;
    }

    .tab-navigation-sticky .tab-container {
        max-width: 600px;
    }

    .result-card {
        transition: all 0.3s ease;
    }

    .result-card:hover {
        border-color: var(--primary-orange);
        background: linear-gradient(135deg, #ffffff 0%, #fffbf7 100%);
    }

    /* デスクトップでのSNSプレビュー2列表示 */
    .sns-preview-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 32px;
        align-items: start;
    }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--neutral-100);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-orange), var(--secondary-amber));
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--primary-orange-dark), var(--secondary-amber));
}

/* Reset button styles */
.reset-button {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    color: var(--primary-orange);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(8px);
}

.reset-button:hover {
    background: rgba(249, 115, 22, 0.15);
    border-color: rgba(249, 115, 22, 0.3);
    transform: scale(1.02);
}

/* Category icons - Clean Design */
.category-icon {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
    border: 2px solid white;
    z-index: 10;
}

/* Highlight category icons - Clean Design */
.highlight-category-icon {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: white;
    border: 1px solid white;
    z-index: 10;
    white-space: nowrap;
    pointer-events: none;
}

.legend-item {
    cursor: default !important;
    pointer-events: none;
}

.legend-item:hover::after,
.legend-item:hover::before {
    display: none !important;
    content: none !important;
}

.icon-basic {
    background: linear-gradient(135deg, var(--primary-orange), var(--secondary-amber));
}

.icon-ai {
    background: linear-gradient(135deg, var(--accent-blue), #6366f1);
}

.icon-warning {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* Tab content visibility */
.tab-content {
    display: block;
}

.tab-content.hidden {
    display: none !important;
}

/* Instagram hashtag styling */
.instagram-hashtag {
    color: #405DE6 !important;
    font-weight: 500 !important;
}

/* ショートカットアニメーション */
.animate-fadeInScale {
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Instagram official-like gradient button */
.instagram-copy-btn {
    /* Fallback handled via inline style; apply official-like gradient */
    background-image: linear-gradient(45deg, #F58529, #DD2A7B, #8134AF, #515BD4);
    background-size: 200% 200%;
    border: none;
    min-height: 40px;
    transition: background-position 0.3s ease, transform 0.15s ease;
}

.instagram-copy-btn:hover {
    background-position: 100% 0;
}

.instagram-copy-btn:active {
    transform: translateY(1px);
}

/* Xプレビュー用タイトルバッジ */
#x-ogp-image-area .x-ogp-title-badge {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    /* 中央配置 */
    background: rgba(17, 24, 39, 0.75);
    color: #fff;
    padding: 6px 10px;
    border-radius: 9999px;
    font-size: 12px;
    line-height: 1.2;
    max-width: calc(100% - 24px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(6px);
    z-index: 40;
    pointer-events: none;
}

/* Xプレビューエリアのキャンバススタイル */
#x-preview-canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    position: relative;
    z-index: 10;
}

#instagram-preview-canvas {
    position: relative;
    z-index: 10;
}

/* タイトル・OGP専用スタイル */
.title-candidate-item {
    transition: all 0.2s ease;
}

.title-candidate-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.title-candidate-item.selected {
    border-color: #fb923c !important;
    background-color: #fff7ed !important;
}

.ogp-download-btn {
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    z-index: 20;
    pointer-events: auto;
}

.ogp-download-btn:hover {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

/* プレビューエリアの高さ問題を修正 */
#x-ogp-image-area,
#instagram-image-area {
    position: relative;
    overflow: hidden;
    min-height: 200px;
    /* 最小高さを確保 */
}

/* Xプレビューエリアの特別なスタイリング（16:9中央配置対応） */
#x-ogp-image-area {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    /* 軽いグレー背景 */
    position: relative;
    /* 子要素の絶対配置の基準点 */
}

/* ダウンロードボタンを完全にオーバーレイ */
.ogp-download-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 50 !important;
    pointer-events: auto;
    backdrop-filter: blur(6px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: rgba(0, 0, 0, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    padding: 8px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.ogp-download-btn:hover {
    background-color: rgba(0, 0, 0, 0.85) !important;
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.35);
}

.ogp-download-btn:active {
    transform: scale(1.02);
    transition: transform 0.1s ease;
}

/* フォント読み込み用（Googleフォント） */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@100;200;300;400;500;600;700;800;900&display=swap');

/* Temporarily disable gradient so success色 (bg-green-600) が見えるように */
.instagram-copy-btn.no-gradient {
    background-image: none !important;
}

/* Cropper.js スタイル調整 */
.crop-container {
    max-height: 60vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cropper-container {
    max-width: 100%;
    max-height: 100%;
}

.cropper-modal,
.cropper-bg {
    background-color: rgba(0, 0, 0, 0.8) !important;
}

.cropper-line,
.cropper-point {
    background-color: #fff !important;
    opacity: 0.8;
}

.cropper-line.line-w,
.cropper-line.line-e {
    border-top: 2px solid #fff;
    border-bottom: 2px solid #fff;
}

.cropper-line.line-n,
.cropper-line.line-s {
    border-left: 2px solid #fff;
    border-right: 2px solid #fff;
}

.cropper-point.point-se,
.cropper-point.point-sw,
.cropper-point.point-ne,
.cropper-point.point-nw {
    width: 8px;
    height: 8px;
    background-color: #fff;
    border: 2px solid #333;
}

.cropper-face {
    border: 2px solid #fff;
    box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.5);
}

/* クロップモーダルのモバイル対応 */
@media (max-width: 768px) {
    #crop-modal .crop-container {
        max-height: 40vh;
    }
}

/* クロップ時にヘッダーと下部タブを非表示 */
.crop-mode header,
.crop-mode .tab-navigation-fixed {
    display: none !important;
}

/* クロップモード時のメインコンテンツ調整 */
.crop-mode main {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}