/* デザインシステム・基本設定 */
:root {
    --bg-color: #FAF6F0; /* 温かみのある生成り色 */
    --card-bg: #FFFFFF;
    --primary: #C2410C; /* 温かみのあるテラコッタ・オレンジ */
    --primary-hover: #9A3412;
    --text-main: #2D2A26; /* 深いチャコールグレー */
    --text-muted: #6B6661;
    --border-color: #E6DFD5;
    --shadow: 0 4px 12px rgba(194, 65, 12, 0.05);
    --shadow-hover: 0 12px 24px rgba(194, 65, 12, 0.1);
    --font-family: 'Zen Maru Gothic', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* 画面切り替えの基本 */
.screen {
    display: none;
    min-height: 100vh;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen.active {
    display: block;
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* 共通ボタン */
button {
    font-family: var(--font-family);
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary);
    color: #FFFFFF;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    width: 100%;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background-color: rgba(0, 0, 0, 0.02);
    color: var(--text-main);
}

/* 1. ログイン画面 */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
}

#login-screen.active {
    display: flex;
}

.login-card {
    background-color: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    max-width: 400px;
    width: 90%;
    text-align: center;
    border: 1px solid var(--border-color);
}

.logo {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 16px;
    font-weight: 700;
}

.login-message {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

#login-form input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    margin-bottom: 16px;
    outline: none;
    text-align: center;
    font-family: var(--font-family);
    transition: border-color 0.2s ease;
}

#login-form input:focus {
    border-color: var(--primary);
}

.error-text {
    color: #DC2626;
    font-size: 0.85rem;
    margin-top: 12px;
}

/* 2. メイン画面 */
.main-header {
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* 検索 & フィルター */
.search-section {
    margin-bottom: 32px;
}

.search-bar-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto 20px auto;
}

.search-bar-wrapper input {
    width: 100%;
    padding: 14px 20px 14px 48px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 1.05rem;
    outline: none;
    font-family: var(--font-family);
    transition: all 0.2s ease;
    background-color: var(--card-bg);
}

.search-bar-wrapper input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(194, 65, 12, 0.1);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--text-muted);
}

.filter-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    max-width: 380px;
    margin: 0 auto;
    background-color: var(--card-bg);
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
}

.filter-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(194, 65, 12, 0.1);
}

.filter-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
}

.tag-select {
    flex-grow: 1;
    padding: 8px 12px;
    border: none;
    background-color: transparent;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: var(--font-family);
    outline: none;
    cursor: pointer;
}

/* レシピ件数ステータス */
.recipes-status {
    margin-bottom: 20px;
    display: flex;
    justify-content: flex-start;
}

.recipe-count {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 700;
    background-color: var(--card-bg);
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

/* レシピグリッド */
.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.recipe-card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.recipe-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

.recipe-card-image {
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: #E6DFD5;
}

.recipe-card-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.recipe-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main);
}

.recipe-card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: auto;
}

.card-tag {
    font-size: 0.75rem;
    padding: 2px 8px;
    background-color: #FAF6F0;
    color: var(--text-muted);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.no-results {
    text-align: center;
    padding: 48px 0;
    color: var(--text-muted);
}

/* 3. モーダル詳細画面 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(45, 42, 38, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--card-bg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 2rem;
    color: #FFFFFF;
    background: rgba(0, 0, 0, 0.4);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.6);
}

.recipe-hero-image {
    height: 350px;
    background-size: cover;
    background-position: center;
    background-color: #E6DFD5;
}

.recipe-detail-container {
    padding: 32px;
}

.recipe-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.recipe-tags {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.recipe-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
}

@media (min-width: 768px) {
    .recipe-layout {
        grid-template-columns: 2fr 3fr;
    }
}

.ingredients-box, .steps-box {
    background-color: #FAF6F0;
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.ingredients-box h3, .steps-box h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--primary);
    border-bottom: 2px dashed var(--border-color);
    padding-bottom: 8px;
}

.ingredients-box ul {
    list-style: none;
}

.ingredients-box li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    font-size: 0.95rem;
}

.ingredients-box li:last-child {
    border-bottom: none;
}

.steps-box ol {
    padding-left: 20px;
}

.steps-box li {
    padding: 6px 0;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.steps-box li::marker {
    color: var(--primary);
    font-weight: 700;
}

.recipe-internal-link {
    color: var(--primary);
    text-decoration: underline;
    font-weight: 500;
    cursor: pointer;
}

.recipe-internal-link:hover {
    color: var(--primary-hover);
}

.modal-back-btn {
    position: absolute;
    top: 16px;
    left: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary);
    background: rgba(194, 65, 12, 0.08);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
}

.modal-back-btn:hover {
    background: rgba(194, 65, 12, 0.15);
    color: var(--primary-hover);
}
