/*
  Design system source of truth.
  Future themes should override these tokens, not component CSS.
*/
:root {
    /* Typography */
    --font-sans: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: var(--font-sans);

    /* Primitive palette */
    --color-cream-50: #FAFCF9;
    --color-white: #FFFFFF;
    --color-sage-50: #E9EFEA;
    --color-sage-100: #E2E8E4;
    --color-sage-600: #6B8878;
    --color-forest-700: #3B5F4D;
    --color-forest-800: #2C4A3B;
    --color-ink-900: #1C231F;
    --color-stone-500: #737A76;
    --color-stone-100: #EDF0EE;
    --color-terracotta-100: #F4EDE8;
    --color-terracotta-600: #A67554;

    /* Semantic color tokens used by components */
    --body-bg: var(--color-sage-100);
    --bg-color: var(--color-cream-50);
    --surface: var(--color-white);
    --surface-glass: rgba(255, 255, 255, 0.85);
    --header-bg: rgba(250, 252, 249, 0.92);
    --nav-bg: rgba(255, 255, 255, 0.95);
    --phone-border: var(--color-white);
    --primary: var(--color-forest-800);
    --primary-strong: var(--color-forest-700);
    --primary-light: var(--color-sage-50);
    --primary-muted: var(--color-sage-600);
    --primary-border-subtle: rgba(44, 74, 59, 0.1);
    --primary-shadow: rgba(44, 74, 59, 0.3);
    --accent: var(--color-terracotta-600);
    --accent-light: var(--color-terracotta-100);
    --text-main: var(--color-ink-900);
    --text-muted: var(--color-stone-500);
    --border: var(--color-stone-100);
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --image-overlay-bg: rgba(0, 0, 0, 0.6);
    --on-image-text: var(--color-white);

    /* Shape and elevation */
    --phone-shell-shadow: 0 40px 80px rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 4px 16px rgba(44, 74, 59, 0.04);
    --shadow-md: 0 -4px 24px rgba(44, 74, 59, 0.06);
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-pill: 9999px;
    --nav-height: 80px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: var(--font-sans); background-color: var(--body-bg); display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; color: var(--text-main); line-height: 1.4; }
button, input, textarea, select { font: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid rgba(166, 117, 84, 0.35); outline-offset: 3px; }
h1, h2, h3, h4 { font-family: var(--font-display); }

#phone-shell { width: 100%; max-width: 420px; height: 850px; max-height: 92vh; background-color: var(--bg-color); border-radius: 48px; box-shadow: var(--phone-shell-shadow), inset 0 0 0 8px var(--phone-border); position: relative; overflow: hidden; display: flex; flex-direction: column; }

.screen { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: var(--bg-color); overflow-y: auto; overflow-x: hidden; display: block; opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease; transform: translateX(20px); padding-bottom: calc(var(--nav-height) + 24px); }
.screen.active { opacity: 1; pointer-events: all; transform: translateX(0); }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: var(--surface); border: none; padding: 18px 24px; border-radius: var(--radius-pill); font-size: 1.15rem; font-weight: 500; width: 100%; cursor: pointer; box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform 0.2s, box-shadow 0.2s; }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: var(--surface); color: var(--text-main); border: 2px solid var(--border); padding: 18px 24px; border-radius: var(--radius-pill); font-size: 1.15rem; font-weight: 500; width: 100%; cursor: pointer; }
.btn-secondary:active { background: var(--bg-color); }

.glass-btn { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-glass); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; color: var(--text-main); border: none; box-shadow: var(--glass-shadow); cursor: pointer;}
.glass-btn-sm { width: 40px; height: 40px; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--primary); border: 1px solid var(--border); box-shadow: var(--shadow-sm); cursor: pointer; }

.input-group { margin-bottom: 24px; }
.input-group label { display: block; font-size: 1.05rem; font-weight: 600; color: var(--primary); margin-bottom: 8px; margin-left: 12px; }
.input-group input, .input-group textarea { width: 100%; padding: 18px 20px; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-lg); font-family: inherit; font-size: 1.15rem; outline: none; transition: border-color 0.2s; }
.input-group input:focus, .input-group textarea:focus { border-color: var(--primary); }

.tag-pill { display: inline-flex; align-items: center; justify-content: center; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-pill); padding: 8px 16px; font-weight: 500; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.tag-pill.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }

.dash-header { padding: 40px 24px 20px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--header-bg); backdrop-filter: blur(12px); z-index: 10; }
.dash-header h2 { font-size: 1.8rem; font-weight: 600; color: var(--primary); }
.dash-header .avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1.2rem; overflow: hidden; cursor: pointer; border: 2px solid var(--surface); box-shadow: var(--shadow-sm);}
.search-area { padding: 0 24px; margin-bottom: 24px; position: relative; }
.search-area input { width: 100%; padding: 18px 24px 18px 56px; border-radius: var(--radius-pill); border: none; background: var(--surface); box-shadow: var(--shadow-sm); font-size: 1.1rem; outline:none; font-family: inherit; }
.search-area i { position: absolute; left: 44px; top: 50%; transform: translateY(-50%); font-size: 1.4rem; color: var(--primary-muted); }
.scroller-wrap { padding: 0 24px; margin-bottom: 32px; overflow-x: auto; white-space: nowrap; }
.scroller-wrap::-webkit-scrollbar { display: none; }
.top-tags { display: inline-flex; gap: 12px; }
.section-title { padding: 0 24px; font-size: 1.4rem; font-weight: 600; color: var(--primary); margin-bottom: 16px; display: flex; justify-content: space-between; align-items: baseline;}

.feed { padding: 0 24px; display: flex; flex-direction: column; gap: 24px; }
.post-card { background: var(--surface); border-radius: var(--radius-xl); padding: 20px; box-shadow: var(--shadow-sm); }
.post-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.post-header img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.post-header p { font-size: 1.1rem; color: var(--text-main); line-height: 1.2; }
.post-image { width: 100%; height: 220px; border-radius: var(--radius-lg); object-fit: cover; cursor: pointer; background: var(--border); position: relative; }
.placeholder-tag { position: absolute; top: 12px; right: 12px; background: var(--image-overlay-bg); color: var(--on-image-text); padding: 6px 12px; border-radius: var(--radius-pill); font-size: 0.9rem; font-weight: 500; backdrop-filter: blur(4px); display: flex; gap: 6px; align-items: center; }

.recipe-header { position: relative; height: 350px; background: var(--border); }
.recipe-header img { width: 100%; height: 100%; object-fit: cover; }
.recipe-nav { position: absolute; top: 40px; left: 24px; right: 24px; display: flex; justify-content: space-between; }
.recipe-body { background: var(--bg-color); border-radius: 40px 40px 0 0; padding: 32px 24px; margin-top: -40px; position: relative; }
.recipe-title { font-size: 2.2rem; color: var(--primary); font-weight: 600; line-height: 1.1; margin-bottom: 16px; }
.recipe-metadata { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.meta-tag { background: var(--surface); color: var(--primary); padding: 6px 12px; border-radius: var(--radius-pill); border: 1px solid var(--border); font-size: 0.95rem; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.ingredients-box { background: linear-gradient(180deg, var(--primary-light), rgba(255, 255, 255, 0.72)); padding: 24px; border-radius: var(--radius-xl); margin-bottom: 24px; border: 1px solid var(--primary-border-subtle); }
.ingredients-box h3 { font-size: 1.4rem; color: var(--primary); margin-bottom: 16px; }
.recipe-block { background: var(--surface); padding: 24px; border-radius: var(--radius-xl); box-shadow: 0 12px 30px rgba(44, 74, 59, 0.06); margin-bottom: 24px; border: 1px solid rgba(44, 74, 59, 0.05); }
.recipe-block h3 { font-size: 1.4rem; color: var(--primary); margin-bottom: 16px; }
.step-block { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px dashed var(--border); }
.step-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.step-text { font-size: 1.2rem; margin-bottom: 12px; display: flex; gap: 14px; line-height: 1.48; align-items: flex-start; }
.step-num { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: var(--surface); font-weight: 800; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.step-photos { display: flex; gap: 8px; overflow-x: auto; margin-top: 12px; }
.step-photos img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--border);}

.create-header { padding: 40px 24px 24px; display: flex; justify-content: space-between; align-items: center; }
.create-form { padding: 0 24px; }
.step-edit-block { background: var(--surface); padding: 20px; border-radius: var(--radius-xl); border: 2px dashed var(--primary-muted); margin-bottom: 16px; position: relative; }
.step-edit-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.step-edit-header h4 { color: var(--primary); font-size: 1.2rem; }
.multiple-photos-tray { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto;}
.multiple-photos-tray .photo-thumb { width: 80px; height: 80px; border-radius: var(--radius-md); object-fit: cover; }
.multiple-photos-tray .add-more { width: 80px; height: 80px; border-radius: var(--radius-md); background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; cursor: pointer; border: 1px dashed var(--primary-muted); }
.upload-hero-empty { background: var(--surface); padding: 32px 24px; margin: 32px 0 24px; border-radius: var(--radius-xl); border: 2px dashed var(--primary); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--primary); font-size: 1.1rem; cursor: pointer; box-shadow: var(--shadow-sm); text-align: center;}
.upload-hero-empty i { font-size: 3rem; color: var(--primary); }

.modal-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: var(--overlay-bg); z-index: 200; display: none; align-items: flex-end; opacity: 0; transition: opacity 0.3s; }
.modal-bg.show { opacity: 1; }
.action-sheet { width: 100%; background: var(--bg-color); border-radius: 32px 32px 0 0; padding: 32px 24px 48px; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-bg.show .action-sheet { transform: translateY(0); }
.sheet-btn { display: flex; align-items: center; gap: 16px; background: var(--surface); padding: 20px; border-radius: var(--radius-xl); border: 2px solid var(--border); width: 100%; text-align: left; margin-bottom: 16px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border 0.2s; }
.sheet-btn:active { border-color: var(--primary); background: var(--primary-light); }
.sheet-btn i { font-size: 2.5rem; color: var(--accent); }
.sheet-btn h3 { font-size: 1.25rem; color: var(--primary); margin-bottom: 4px; }
.sheet-btn p { color: var(--text-muted); font-size: 1rem; }

.repo-tabs { display: flex; gap: 16px; margin: 0 24px 24px; border-bottom: 2px solid var(--border); }
.repo-tab { padding: 12px 4px; font-size: 1.1rem; font-weight: 500; color: var(--text-muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.repo-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.bottom-nav { position: absolute; bottom: 0; left: 0; right: 0; height: var(--nav-height); background: var(--nav-bg); backdrop-filter: blur(12px); display: flex; justify-content: space-between; align-items: center; padding: 0 32px; box-shadow: var(--shadow-md); z-index: 100; border-top: 1px solid var(--border); }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; border: none; background: transparent; cursor: pointer; transition: all 0.2s; width: 66px; height: 100%; }
.nav-item i { font-size: 1.8rem; margin-bottom: 2px;}
.nav-item.active { color: var(--primary); }
.nav-item.active i { background: var(--primary-light); border-radius: var(--radius-pill); padding: 4px 16px; }
.nav-center-wrapper { position: relative; width: 80px; height: 100%; display: flex; align-items: flex-start; justify-content: center;}
.nav-btn-center { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-strong)); color: var(--surface); border: none; display: flex; align-items: center; justify-content: center; font-size: 2rem; box-shadow: 0 8px 24px var(--primary-shadow); transform: translateY(-24px); cursor: pointer; transition: transform 0.2s; }
.form-select { width: 100%; padding: 12px 16px; background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-md); font-family: inherit; font-size: 1.05rem; color: var(--text-main); outline: none; appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23737A76' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
