:root { 
    --bg: #121416; 
    --panel: #1c1f23; 
    --tray: #15171a; 
    --border: #2d3138; 
    --text-main: #e2e8f0; 
    --text-dim: #64748b; 
    --c-flour-1: #a8a295; 
    --c-flour-2: #8c867a;
    --c-water: #647b8a; 
    --c-start: #8c7a6b; 
    --c-salt:  #475569; 
    --accent: #8fb3a6;
    --highlight: #eab308;
    --btn-support: #eab308;
    --btn-github: #2d3138;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }

body { 
    font-family: -apple-system, system-ui, sans-serif; 
    background-color: var(--bg); 
    color: var(--text-main); 
    margin: 0; 
    padding: 20px; 
    display: flex; 
    justify-content: center;
    align-items: flex-start; 
}

.container { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }

/* APP TITLE */
.app-title {
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    opacity: 0.9;
}

.module { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 20px; transition: height 0.3s ease; }

.mod-header { 
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 10px; 
}
.mod-label { font-size: 10px; font-weight: 800; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; }

.controls { display: flex; gap: 8px; align-items: center; }

.reset-btn {
    background: transparent; border: 1px solid var(--border); border-radius: 6px;
    color: var(--text-dim); padding: 5px 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.reset-btn:active { background: rgba(255,255,255,0.1); color: var(--text-main); }
.reset-btn svg { width: 12px; height: 12px; fill: currentColor; }

.tune-btn {
    background: rgba(143, 179, 166, 0.1); border: 1px solid var(--accent); border-radius: 6px;
    color: var(--accent); padding: 6px 12px; font-size: 10px; font-weight: 700; 
    cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px; transition: all 0.2s;
}
.tune-btn.active { background: var(--accent); color: #121416; box-shadow: 0 0 10px rgba(143, 179, 166, 0.2); }

.help-btn {
    background: transparent; border: 1px solid var(--text-dim); border-radius: 50%; width: 20px; height: 20px;
    color: var(--text-dim); font-size: 12px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.input-row { margin-bottom: 14px; }
.label { display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: var(--text-dim); text-transform: uppercase; margin-bottom: 6px; font-weight: 700; }

.link-icon { width: 12px; height: 12px; fill: var(--accent); margin-left: 4px; opacity: 1; transition: opacity 0.3s; }
.link-icon.hidden { opacity: 0; }

.stepper { 
    display: grid; 
    grid-template-columns: 38px 1fr 38px; 
    background: rgba(0,0,0,0.2); 
    border: 1px solid var(--border); 
    border-radius: 10px; 
    height: 48px; 
    align-items: center; 
}
.btn { height: 100%; background: transparent; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; touch-action: none; display: flex; align-items: center; justify-content: center;}
.btn:active { color: var(--text-main); background: rgba(255,255,255,0.05); }

.val-box { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    height: 100%; 
    width: 100%; 
    pointer-events: none; 
    gap: 2px;
}
.val { 
    background: transparent; 
    border: none; 
    color: #fff; 
    text-align: right; 
    font-size: 17px; 
    font-weight: 700; 
    outline: none; 
    -moz-appearance: textfield; 
    padding: 0; 
    margin: 0; 
    height: 100%; 
    width: 44px; /* Standard Width */
    min-width: 44px;
    cursor: text;
    pointer-events: auto;
}
.val-wide { width: 56px; min-width: 56px; } /* Wide Mode for Loaf Weight */
.val:focus { color: var(--accent); }

.unit { 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--accent); 
    width: 15px; 
    text-align: left; 
    padding-top: 2px; 
    pointer-events: none; 
}

.expand-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease; opacity: 0; }
.expand-inner { overflow: hidden; }
.expand-wrap.open { 
    grid-template-rows: 1fr; opacity: 1; 
    margin-top: 15px; margin-bottom: 20px;
    background: var(--tray); border-radius: 12px; border: 1px solid var(--border);
    padding: 15px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
#adv-panel .input-row:last-child { margin-bottom: 0; }

.stack { display: flex; flex-direction: column; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); }
.seg { 
    display: grid; grid-template-columns: 1fr auto; align-items: center; 
    padding: 18px 20px; border-bottom: 1px solid rgba(0,0,0,0.05);
}
.seg.hidden { display: none; }
.seg-name { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; opacity: 0.9; }
.seg-amt { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.s-flour-1 { background: var(--c-flour-1); color: #1a1c1e; }
.s-flour-2 { background: var(--c-flour-2); color: #1a1c1e; }
.s-water   { background: var(--c-water); color: #fff; }
.s-start   { background: var(--c-start); color: #fff; }
.s-salt    { background: var(--c-salt); color: #cbd5e1; padding: 12px 20px; border:none; }
.s-inclusion { background: #3a3040; color: #c4aee0; padding: 12px 20px; border:none; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.s-lab { font-size: 8px; color: var(--text-dim); text-transform: uppercase; display: block; }
.s-num { font-size: 14px; font-weight: 700; color: var(--accent); margin-top: 2px; }

.help-box { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.help-box:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.help-title { font-size: 11px; font-weight: 800; color: var(--text-main); text-transform: uppercase; margin-bottom: 4px; display: flex; justify-content: space-between; }
.help-rec { color: var(--highlight); font-size: 10px; }
.help-desc { font-size: 11px; line-height: 1.4; color: var(--text-dim); }
.help-hilite { color: var(--text-main); font-weight: 600; }

/* FOOTER ACTIONS */
.footer-msg { font-size: 12px; color: var(--text-dim); text-align: center; margin-bottom: 15px; font-style: italic; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.action-btn { 
    text-decoration: none; padding: 10px; border-radius: 8px; 
    font-size: 11px; font-weight: 700; text-transform: uppercase; text-align: center;
    display: flex; align-items: center; justify-content: center; transition: opacity 0.2s;
}
.action-btn:active { opacity: 0.7; }
.btn-supp { background: rgba(234, 179, 8, 0.1); color: var(--btn-support); border: 1px solid var(--btn-support); }
.btn-feed { background: rgba(255, 255, 255, 0.05); color: var(--text-dim); border: 1px solid var(--border); }

/* INSTALL APP BUTTON */
.install-btn {
    background: rgba(234, 179, 8, 0.1); 
    color: var(--highlight); 
    border: 1px solid var(--highlight);
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    margin-right: 4px;
    letter-spacing: 0.5px;
}
.install-btn:active { transform: scale(0.95); background: rgba(234, 179, 8, 0.2); }
.install-btn[hidden] { display: none; }

/* BANNETON MODE */
.toggle-switch { position: relative; display: inline-block; width: 34px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border); transition: .4s; border-radius: 20px;
}
.slider:before {
    position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px;
    background-color: var(--text-dim); transition: .4s; border-radius: 50%;
}
input:checked + .slider { background-color: rgba(143, 179, 166, 0.2); border: 1px solid var(--accent); }
input:checked + .slider:before { transform: translateX(14px); background-color: var(--accent); }

.hidden { display: none !important; }

.shape-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.shape-btn {
    background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px; cursor: pointer; color: var(--text-dim); display: flex; flex-direction: column; align-items: center; gap: 4px;
    transition: all 0.2s;
}
.shape-btn svg { width: 24px; height: 24px; opacity: 0.5; }
.shape-btn span { font-size: 10px; font-weight: 700; text-transform: uppercase; }
.shape-btn.active { background: rgba(143, 179, 166, 0.1); border-color: var(--accent); color: var(--accent); }
.shape-btn.active svg { opacity: 1; }

.size-carousel {
    display: flex; overflow-x: auto; gap: 8px; padding: 4px 4px 8px 4px; scrollbar-width: none; align-items: center;
}
.size-carousel::-webkit-scrollbar { display: none; }

.size-pill {
    flex: 0 0 auto; background: var(--panel); border: 1px solid var(--border); color: var(--text-dim);
    font-size: 11px; font-weight: 700; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.size-pill.active { background: var(--accent); color: #121416; border-color: var(--accent); transform: scale(1.05); }

.size-pill.boule {
    width: 40px; height: 40px; border-radius: 50%; padding: 0; /* Fix centering */
}
.size-pill.batard {
    height: 34px; padding: 0 16px; border-radius: 20px; /* Fix Pill Shape */
    min-width: 50px;
}

/* TOAST MESSAGE */
.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: rgba(234, 179, 8, 0.95); color: #121416;
    padding: 8px 16px; border-radius: 20px;
    font-size: 12px; font-weight: 700; text-align: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
    z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    white-space: nowrap;
}
.toast.show { opacity: 1; }
