* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #FFD700;
    --secondary-color: #FFA500;
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --card-bg: #2a2a2a;
    --input-bg: #333333;
    --border-color: #444444;
    --success-color: #4CAF50;
    --error-color: #f44336;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.4;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px;
}

header {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.2);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
}

.header-text {
    flex: 1;
    text-align: left;
}

header h1 {
    font-size: 1.2rem;
    margin: 0;
    color: var(--bg-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.version {
    font-size: 0.7rem;
    font-weight: 400;
    opacity: 0.7;
    margin-left: 6px;
}

.install-button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: var(--bg-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.install-button:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

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

.info-links {
    margin: 8px 0 12px 0;
}

.info-link {
    display: block;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    transition: all 0.3s ease;
}

.info-link:hover {
    border-color: var(--primary-color);
    background: rgba(255, 215, 0, 0.1);
    transform: translateY(-1px);
}

main {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.input-section {
    margin-bottom: 12px;
}

.section-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 12px 0;
}

label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color);
}

textarea,
input[type="password"] {
    width: 100%;
    padding: 8px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.label-with-clear {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.label-with-clear label {
    margin-bottom: 0;
}

.clear-btn {
    padding: 2px 8px;
    background: transparent;
    color: #888;
    border: 1px solid #888;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-btn:hover {
    background: #888;
    color: var(--bg-color);
}

.image-upload-section {
    margin-bottom: 8px;
}

.upload-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.upload-drop-zone {
    flex: 4;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 16px;
    background: var(--input-bg);
    transition: border-color 0.3s ease, background 0.3s ease;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
    color: #999;
}

.upload-drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(255, 215, 0, 0.1);
}

.upload-drop-zone p {
    margin: 0 0 4px 0;
    font-size: 0.9rem;
}

.upload-drop-zone small {
    font-size: 0.75rem;
}

.camera-zone {
    flex: 1;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.camera-zone-grid {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    aspect-ratio: 1;
}

.upload-drop-zone-grid {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 12px;
    background: var(--input-bg);
    transition: border-color 0.3s ease, background 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 0;
    color: #999;
    font-size: 0.75rem;
    text-align: center;
}

.upload-drop-zone-grid.dragover {
    border-color: var(--primary-color);
    background: rgba(255, 215, 0, 0.1);
}

.upload-drop-zone-grid p {
    margin: 0;
    font-size: 0.7rem;
    line-height: 1.2;
}

.upload-drop-zone-grid small {
    font-size: 0.6rem;
}

.camera-btn {
    background: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    /* セルいっぱいに広げて行高さに追従 */
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
}

.camera-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

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

.camera-icon {
    /* セルサイズに素直に追従 - max制限を外して急な変化を防ぐ */
    width: 70%;
    height: auto;
    max-width: none;
    max-height: none;
    filter: brightness(0) invert(1);
    transition: all 0.3s ease;
}

.image-preview-container {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 16px;
    /* 各行を均等にする - 3枚のときでも行の高さを安定させる */
    grid-auto-rows: 1fr;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-remove-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.3s ease;
}

.image-remove-btn:hover {
    background: #da190b;
}

.settings {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 8px 0;
}

.setting-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.setting-item label {
    margin-bottom: 0;
    white-space: nowrap;
}

select {
    padding: 6px 8px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.api-key-accordion,
.custom-prompts-accordion,
.image-library-accordion {
    margin-bottom: 8px;
}

.accordion-toggle {
    width: 100%;
    padding: 8px 10px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.accordion-toggle:hover {
    border-color: var(--primary-color);
    background: rgba(255, 215, 0, 0.1);
}

.api-warning {
    display: none;
    color: #f44336;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 12px;
    margin-top: 8px;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid #f44336;
    border-radius: 6px;
    text-align: center;
}

.api-warning.show {
    display: block;
}

.accordion-icon {
    transition: transform 0.3s ease;
    font-size: 0.7rem;
}

.accordion-toggle.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.accordion-content.active {
    max-height: 250px;
}

.custom-prompts-accordion .accordion-content.active {
    max-height: 600px;
    overflow-y: auto;
}

.api-key-section,
.custom-prompts-section {
    margin: 8px 0;
}

.custom-prompts-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}

.custom-prompt-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.custom-prompt-header {
    display: flex;
    gap: 8px;
    align-items: center;
}

.custom-prompt-name-input {
    flex: 1;
    padding: 4px 6px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 0.8rem;
}

.custom-prompt-copy-btn {
    padding: 4px 10px;
    background: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.custom-prompt-copy-btn:hover {
    background: var(--primary-hover);
}

.custom-prompt-text {
    padding: 4px 6px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 0.75rem;
    resize: vertical;
    min-height: 80px;
}

.custom-prompts-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.use-prompt-btn {
    padding: 6px 12px;
    background: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.use-prompt-btn:hover {
    background: var(--secondary-color);
}

.use-prompt-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.image-library-accordion {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.05), rgba(255, 193, 7, 0.05));
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.image-library-section {
    margin: 8px 0;
    padding-top: 8px;
    transition: all 0.3s ease;
}

.image-library-section.dragover {
    background: rgba(255, 215, 0, 0.1);
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    padding: 12px 8px 8px 8px;
    margin: 8px -8px;
}

.library-add-btn {
    width: 100%;
    padding: 8px 12px;
    background: var(--primary-color);
    color: var(--bg-color);
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.library-add-btn:hover {
    background: var(--secondary-color);
}

.image-library-accordion .accordion-content.active {
    max-height: 600px;
    overflow-y: auto;
}

.image-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.library-image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.library-image-item:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.library-image-item.selected {
    border-color: var(--success-color);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.library-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.3s ease;
    z-index: 2;
}

.library-image-remove:hover {
    background: #da190b;
}

.library-image-size {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 600;
}

/* Official Library */
.official-library-accordion {
    background: linear-gradient(135deg, rgba(100, 181, 246, 0.05), rgba(33, 150, 243, 0.05));
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.official-library-section {
    margin: 8px 0;
    padding-top: 8px;
}

.official-library-description {
    font-size: 0.85rem;
    color: #666;
    margin: 0 0 8px 0;
    text-align: center;
}

.official-library-accordion .accordion-content.active {
    max-height: 600px;
    overflow-y: auto;
}

.official-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.official-library-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: var(--card-bg);
    border: 2px solid rgba(33, 150, 243, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.official-library-item:hover {
    border-color: rgba(33, 150, 243, 0.8);
    transform: scale(1.05);
}

.official-library-item.selected {
    border-color: var(--success-color);
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.5);
}

.official-library-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.official-library-item-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 4px;
    font-size: 0.55rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.api-key-buttons {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.api-btn {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.save-btn:hover {
    background: #45a049;
}

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

.delete-btn:hover {
    background: #da190b;
}

.api-key-section small {
    display: block;
    margin-top: 6px;
    color: #999;
    font-size: 0.75rem;
    line-height: 1.3;
}

.api-key-section small a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.api-key-section small a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.generate-btn {
    flex: 1;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    border: none;
    border-radius: 12px;
    color: var(--bg-color);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 16px rgba(255, 165, 0, 0.3);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(255, 165, 0, 0.4);
}

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

.generate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cancel-btn {
    padding: 16px 24px;
    background: var(--error-color);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 16px rgba(244, 67, 54, 0.3);
}

.cancel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(244, 67, 54, 0.4);
    background: #da190b;
}

.cancel-btn:active {
    transform: translateY(0);
}

.terms-links {
    text-align: center;
    margin-top: 8px;
}

.terms-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.terms-link:hover {
    background: rgba(255, 215, 0, 0.1);
    text-decoration: underline;
}

.btn-loader {
    display: inline-block;
}

.status {
    margin: 20px 0;
    padding: 15px;
    border-radius: 10px;
    font-weight: 500;
    display: none;
}

.status.info {
    background: rgba(33, 150, 243, 0.1);
    border: 2px solid #2196F3;
    color: #64B5F6;
    display: block;
}

.status.success {
    background: rgba(76, 175, 80, 0.1);
    border: 2px solid var(--success-color);
    color: #81C784;
    display: block;
}

.status.error {
    background: rgba(244, 67, 54, 0.1);
    border: 2px solid var(--error-color);
    color: #E57373;
    display: block;
}

.results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.result-item {
    background: var(--input-bg);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.result-item:hover {
    transform: translateY(-5px);
}

.result-item img {
    width: 100%;
    height: auto;
    display: block;
}

.result-actions {
    padding: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.result-actions a,
.result-actions .share-btn {
    flex: 1;
    padding: 10px;
    background: var(--primary-color);
    color: var(--bg-color);
    text-decoration: none;
    text-align: center;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

.result-actions a:hover,
.result-actions .share-btn:hover {
    background: var(--secondary-color);
}

.ios-save-hint {
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    margin-top: 4px;
}

footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    color: #999;
    font-size: 0.9rem;
}

footer p {
    margin: 8px 0;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.2rem;
    }

    .results {
        grid-template-columns: 1fr;
    }

    main {
        padding: 20px;
    }
}

@media (prefers-color-scheme: light) {
    :root {
        --primary-color: #d4a300;
        --secondary-color: #b8860b;
        --bg-color: #f5f5f5;
        --text-color: #1a1a1a;
        --card-bg: #ffffff;
        --input-bg: #f0f0f0;
        --border-color: #dddddd;
    }

    body {
        background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    }

    label {
        color: #996c00;
    }
}

.loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--bg-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* Confirmation dialog */
.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.confirm-dialog {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.confirm-dialog-message {
    color: var(--text-color);
    font-size: 0.95rem;
    margin-bottom: 16px;
    text-align: center;
    line-height: 1.4;
}

.confirm-dialog-buttons {
    display: flex;
    gap: 8px;
}

.confirm-dialog-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.confirm-dialog-btn.yes {
    background: var(--error-color);
    color: white;
}

.confirm-dialog-btn.yes:hover {
    background: #da190b;
}

.confirm-dialog-btn.no {
    background: var(--input-bg);
    color: var(--text-color);
    border: 2px solid var(--border-color);
}

.confirm-dialog-btn.no:hover {
    border-color: var(--primary-color);
    background: rgba(255, 215, 0, 0.1);
}

/* Update notification */
.update-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: var(--bg-color);
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(255, 165, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.update-message {
    font-weight: 600;
    font-size: 0.9rem;
}

.update-button {
    background: var(--bg-color);
    color: var(--primary-color);
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.update-button:hover {
    background: var(--card-bg);
    transform: scale(1.05);
}

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

@media (max-width: 768px) {
    .update-notification {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        width: auto;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
}

/* Install banner (toast-style) */
.install-banner {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(150px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    z-index: 9999;
    max-width: 90%;
    width: 420px;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.install-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.install-banner-icon {
    font-size: 2rem;
    line-height: 1;
}

.install-banner-text {
    flex: 1;
}

.install-banner-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 2px;
}

.install-banner-desc {
    font-size: 0.75rem;
    opacity: 0.9;
    font-weight: 400;
}

.install-banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.install-banner-btn {
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.install-banner-btn.install-btn {
    background: white;
    color: #667eea;
    padding: 8px 16px;
    font-size: 0.85rem;
}

.install-banner-btn.install-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
}

.install-banner-btn.install-btn:active {
    transform: scale(0.95);
}

.install-banner-btn.dismiss-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 10px;
    font-size: 1.2rem;
    line-height: 1;
}

.install-banner-btn.dismiss-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 768px) {
    .install-banner {
        bottom: 10px;
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        transform: translateY(150px);
        flex-direction: column;
        align-items: stretch;
    }

    .install-banner.show {
        transform: translateY(0);
    }

    .install-banner-actions {
        width: 100%;
    }

    .install-banner-btn.install-btn {
        flex: 1;
    }
}

/* 400px以下では狭い画面用に調整 */
@media (max-width: 400px) {
    .camera-icon {
        width: 60%;
        max-width: 24px;
        max-height: 24px;
    }

    .upload-drop-zone-grid {
        padding: 6px;
        min-height: 0;
    }
}

/* 350px以下では2列グリッドに切り替え（5列では物理的に成立しないため） */
@media (max-width: 350px) {
    .image-preview-container {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ドロップゾーンは2列分横幅いっぱいに広げる */
    .upload-drop-zone-grid {
        grid-column: span 2 !important;
    }

    /* カメラボタンは1列分 */
    .camera-zone-grid {
        grid-column: span 1 !important;
    }
}
