:root {
    --primary-color: #2e7d32;
    --primary-hover: #1b5e20;
    --secondary-color: #ff6f00;
    --bg-color: #f5f5f5;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-light: #666666;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

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

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), #4caf50);
    border-radius: 16px;
    color: white;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.95;
}

main {
    flex: 1;
}

section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

h2 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--primary-color);
}

.input-wrapper {
    display: flex;
    gap: 8px;
    position: relative;
}

input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

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

.substitution-section {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
}

.substitution-section h2 {
    color: var(--secondary-color);
}

.section-hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 12px;
}

.substitution-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow);
}

.substitution-suggestions.hidden {
    display: none;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow);
}

.suggestions.hidden {
    display: none;
}

.suggestion-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: #f0f7f0;
}

.suggestion-item .category {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-left: 8px;
}

.counter {
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 8px;
}

#currentCount {
    font-weight: bold;
    color: var(--primary-color);
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state p {
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 0.9rem;
}

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

.ingredient-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.ingredient-item:hover {
    background: #f0f0f0;
}

.ingredient-name {
    flex: 1;
    font-size: 1rem;
}

.ingredient-delete {
    padding: 6px 12px;
    background: #ffebee;
    color: #c62828;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ingredient-delete:hover {
    background: #ffcdd2;
}

.actions {
    margin-top: 16px;
    text-align: center;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--text-light);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

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

.hidden {
    display: none !important;
}

.features-preview {
    background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.feature-card {
    text-align: center;
    padding: 16px 8px;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.feature-card h3 {
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--primary-color);
}

.feature-card p {
    font-size: 0.75rem;
    color: var(--text-light);
}

footer {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 0.8rem;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--text-color);
    color: white;
    border-radius: 8px;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
}

.toast.success {
    background: var(--primary-color);
}

.toast.error {
    background: #c62828;
}

.results-section {
    border: 2px solid var(--secondary-color);
}

.results-section h2 {
    color: var(--secondary-color);
}

.no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-light);
}

.substitution-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.substitution-card.available {
    border-left-color: #4caf50;
}

.substitution-card.unavailable {
    border-left-color: #ff9800;
    opacity: 0.8;
}

.substitution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.substitution-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-color);
}

.suitability-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
}

.suitability-badge.excellent {
    background: #c8e6c9;
    color: #2e7d32;
}

.suitability-badge.good {
    background: #fff9c4;
    color: #f57f17;
}

.suitability-badge.fair {
    background: #ffe0b2;
    color: #e65100;
}

.substitution-ratio {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 8px;
}

.substitution-description {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 8px;
}

.taste-prediction {
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 8px;
}

.taste-level {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.taste-level.minimal {
    color: #4caf50;
}

.taste-level.slight {
    color: #ff9800;
}

.taste-level.moderate {
    color: #ff9800;
}

.taste-level.significant {
    color: #f44336;
}

.taste-description {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.taste-advice {
    font-size: 0.75rem;
    color: #1976d2;
    font-style: italic;
}

.no-ingredient-message {
    text-align: center;
    padding: 20px;
    background: #fff3e0;
    border-radius: 8px;
    color: var(--secondary-color);
}

.no-ingredient-message p {
    margin-bottom: 8px;
}

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

    .feature-cards {
        grid-template-columns: 1fr;
    }

    .input-wrapper {
        flex-direction: column;
    }

    #addButton,
    #searchButton {
        width: 100%;
    }

    .substitution-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
