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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 10px;
}

.compact-header {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 10px 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

h1 {
    font-size: 1.5rem;
    color: #1a73e8;
    margin: 0;
}

.main-layout {
    display: flex;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

.left-panel {
    flex: 0.75;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.right-panel {
    flex: 1.25;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.section.compact {
    padding: 15px;
}

h2 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 10px;
}

.api-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.api-requirement {
    font-size: 0.85rem;
    color: #666;
    white-space: nowrap;
}

.api-requirement a {
    color: #1a73e8;
    text-decoration: none;
}

.api-requirement a:hover {
    text-decoration: underline;
}

.api-key-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    max-width: 300px;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-primary {
    background-color: #1a73e8;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1557b0;
}

.btn-secondary {
    background-color: #f1f3f4;
    color: #333;
}

.btn-secondary:hover {
    background-color: #e8eaed;
}

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

.status-message {
    padding: 4px 8px;
    border-radius: 4px;
    display: none;
    font-size: 0.85rem;
    margin-left: 10px;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
    display: block;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
    display: block;
}

.upload-container {
    margin-top: 20px;
}

.upload-label {
    display: block;
    cursor: pointer;
}

.upload-area {
    border: 2px dashed #1a73e8;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    transition: all 0.3s ease;
}

.upload-area.compact {
    padding: 20px;
}

.upload-area:hover {
    background-color: #f8f9fa;
    border-color: #1557b0;
}

.upload-icon {
    width: 40px;
    height: 40px;
    color: #1a73e8;
    margin-bottom: 10px;
}

.instruction {
    color: #666;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.canvas-container {
    position: relative;
    display: inline-block;
    margin: 0 auto;
    text-align: center;
}

#selection-canvas {
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: crosshair;
    max-width: 100%;
    display: block;
    margin: 0 auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.canvas-controls {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: center;
}


.loading {
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1a73e8;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.result-card {
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 10px;
}

.result-card.compact {
    padding: 10px;
}

.result-card h3 {
    color: #1a73e8;
    margin-bottom: 8px;
    font-size: 1rem;
}

.result-text {
    line-height: 1.6;
    color: #444;
    white-space: pre-wrap;
    font-size: 0.9rem;
    max-height: 300px;
    overflow-y: auto;
}

.links-list {
    list-style: none;
}

.links-list.compact li {
    margin-bottom: 8px;
}

.links-list a {
    color: #1a73e8;
    text-decoration: none;
    display: block;
    padding: 6px;
    background-color: white;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 0.85rem;
}

.links-list a:hover {
    background-color: #e8f0fe;
    transform: translateX(3px);
}

.link-title {
    font-weight: bold;
    display: block;
    margin-bottom: 2px;
    color: #1a73e8;
    font-size: 0.9rem;
}

.link-url {
    display: block;
    font-size: 0.85rem;
    color: #5f6368;
    margin-bottom: 5px;
    word-break: break-all;
}

.link-snippet {
    font-size: 0.8rem;
    color: #666;
    display: block;
    line-height: 1.3;
    margin-top: 2px;
}

.link-item {
    padding: 15px;
    background-color: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
    transition: all 0.3s ease;
}

.link-item:hover {
    background-color: #f8f9fa;
    border-color: #1a73e8;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.link-domain {
    display: block;
    font-size: 1.1rem;
    font-weight: bold;
    color: #1a73e8;
    margin-bottom: 5px;
}

.link-note {
    display: block;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.search-queries {
    background-color: #e8f0fe;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.query-label {
    font-weight: bold;
    color: #1a73e8;
    margin-right: 10px;
}

.query-text {
    color: #333;
    font-style: italic;
}

.api-help-content {
    font-size: 0.9rem;
}

.api-help-content ol {
    margin: 10px 0;
    padding-left: 20px;
}

.api-help-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.api-help-content a {
    color: #1a73e8;
    text-decoration: none;
}

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

.api-help-note {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        height: auto;
    }
    
    .container {
        padding: 5px;
        height: auto;
    }
    
    .compact-header {
        padding: 10px;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    h1 {
        font-size: 1.2rem;
        text-align: center;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .api-input-container {
        flex-direction: column;
        width: 100%;
        gap: 8px;
        align-items: stretch;
    }
    
    .api-requirement {
        font-size: 0.8rem;
        text-align: center;
        width: 100%;
    }
    
    .api-key-input {
        max-width: none;
        width: 100%;
    }
    
    .btn {
        width: 100%;
    }
    
    .main-layout {
        flex-direction: column;
    }
    
    .left-panel, .right-panel {
        flex: 1;
        width: 100%;
    }
    
    .section {
        padding: 10px;
    }
    
    .section.compact {
        padding: 10px;
    }
    
    h2 {
        font-size: 1rem;
    }
    
    #selection-canvas {
        max-width: 100%;
        width: 100%;
        height: auto;
    }
    
    .upload-area {
        padding: 15px;
    }
    
    .upload-area.compact {
        padding: 15px;
    }
    
    .upload-icon {
        width: 30px;
        height: 30px;
    }
    
    .btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .result-text {
        font-size: 0.85rem;
        max-height: 200px;
    }
    
    .api-help-content {
        font-size: 0.85rem;
    }
    
    .api-help-content ol {
        padding-left: 15px;
    }
    
    .status-message {
        position: static;
        margin: 5px 0 0 0;
        width: 100%;
        text-align: center;
    }
    
    .canvas-controls {
        flex-direction: column;
        gap: 5px;
    }
    
    .canvas-controls .btn {
        width: 100%;
    }
}