:root{
  --bg:#f4f5f1;
  --card:#ffffff;
  --text:#171a1f;
  --muted:#747a83;
  --line:#e7e9e3;
  --soft:#f0f2ed;
  --dark:#1d2228;
  --green:#3f8c65;
  --red:#aa4b4b;
  --shadow:0 10px 30px rgba(25,28,31,.06);
  --radius:22px;
  --nav:72px;
}

*{box-sizing:border-box}
html{background:var(--bg);font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:var(--text)}
body{margin:0;background:var(--bg);padding-bottom:calc(var(--nav) + env(safe-area-inset-bottom) + 22px)}
button,input,textarea,select{font:inherit}
button{-webkit-tap-highlight-color:transparent}

.app-shell{max-width:760px;margin:0 auto;padding:16px 14px 28px}
.day-header{position:relative;display:grid;grid-template-columns:48px 1fr 48px;align-items:center;margin:3px 0 14px}
.date-arrow{display:grid;place-items:center;text-decoration:none;color:var(--text);font-size:42px;font-weight:300;height:48px;border-radius:14px}
.date-arrow:active{background:#e9ebe5}
.date-center{border:0;background:transparent;text-align:center;cursor:pointer;padding:5px}
.day-title{display:block;font-size:19px;font-weight:850;letter-spacing:-.025em}
.day-year{display:block;margin-top:4px;color:var(--muted);font-size:11px;font-weight:800;letter-spacing:.09em}
.native-date{position:absolute;opacity:0;pointer-events:none;width:1px;height:1px}
.day-print-actions{display:flex;justify-content:flex-end;margin:-7px 2px 11px}
.print-shortcut{display:inline-flex;align-items:center;gap:6px;border:1px solid #dce1d9;border-radius:99px;background:#fff;padding:7px 11px;color:#4f5b53;text-decoration:none;font-size:10px;font-weight:900;box-shadow:0 5px 14px rgba(25,31,27,.045)}
.print-shortcut:active{background:#edf2ec;transform:scale(.98)}
.future-note{margin:0 0 12px;padding:10px 13px;border-radius:14px;background:#edf3ff;color:#41516d;font-size:12px;line-height:1.45}

.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:17px;margin-bottom:12px}
.section-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:14px}
.section-heading.compact{margin-bottom:10px}
.section-heading h2,.weight-card h2{font-size:18px;margin:2px 0 0;letter-spacing:-.025em}
.eyebrow{font-size:10px;color:var(--muted);font-weight:900;letter-spacing:.12em}
.save-hint{font-size:11px;color:var(--green);font-weight:750}
.meal-count{display:block;margin-top:4px;color:var(--muted);font-size:11px;font-weight:800}

.hero-number{text-align:right;white-space:nowrap}
.hero-number strong{display:block;font-size:27px;line-height:1;letter-spacing:-.05em}
.hero-number span{font-size:11px;color:var(--muted);font-weight:800}

.macro-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:15px}
.macro-grid>div{background:var(--soft);border-radius:14px;padding:10px}
.macro-grid span{font-size:9px;color:var(--muted);font-weight:900}
.macro-grid strong{display:block;font-size:15px;margin:2px 0;letter-spacing:-.02em}
.macro-grid small{font-size:10px;color:var(--muted)}

.mood-row{display:grid;grid-template-columns:repeat(5,1fr);gap:7px;margin:10px 0 14px}
.mood-button{border:2px solid transparent;border-radius:16px;padding:9px 2px 6px;background:#f4f5f1;cursor:pointer;transition:.15s;color:#777}
.mood-button span{font-size:25px;display:block}
.mood-button small{display:block;margin-top:3px;font-weight:850;color:inherit}
.mood-button.is-selected{transform:translateY(-2px);border-color:currentColor;box-shadow:0 6px 14px rgba(0,0,0,.08)}
.mood-1{color:#c54c4c}.mood-2{color:#dd7c43}.mood-3{color:#c39a30}.mood-4{color:#68a45e}.mood-5{color:#328c66}

.field-label{display:block;font-size:12px;font-weight:800;margin:10px 0 6px;color:#565d67}
.textarea,.search-input,.date-input,.select-input,.text-input,.time-input{width:100%;border:1px solid #dfe2dc;background:#fbfcf9;border-radius:14px;padding:12px;color:var(--text);outline:none}
.textarea:focus,.search-input:focus,.date-input:focus,.select-input:focus,.text-input:focus,.time-input:focus{border-color:#a8ada4;box-shadow:0 0 0 3px rgba(20,25,30,.035)}
.textarea{resize:vertical;min-height:64px}
.time-input{font-size:25px;font-weight:850;text-align:center}
.text-action{border:0;background:transparent;color:#58606a;font-size:12px;font-weight:850;padding:9px 0 0;cursor:pointer}

.food-row,.training-row{padding:13px 0;border-top:1px solid var(--line)}
.food-row:first-child,.training-row:first-child{border-top:0}
.food-main,.training-row>div:first-child{display:flex;flex-direction:column;gap:3px}
.food-main strong,.training-row strong{font-size:14px;line-height:1.25}
.food-main span,.training-row span{font-size:12px;color:var(--muted)}
.food-macros{font-size:9px;color:#7b8189;line-height:1.45;letter-spacing:.01em}
.training-note{margin-top:3px;color:#616873;line-height:1.35}
.training-summary{text-align:right;display:flex;flex-direction:column;gap:2px;white-space:nowrap}
.training-summary strong{font-size:16px}.training-summary span{font-size:11px;color:var(--muted)}

.meal-list{display:flex;flex-direction:column;gap:11px}
.meal-card{border:1px solid #dfe3db;background:#fafbf8;border-radius:18px;padding:13px}
.meal-header{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.meal-title{display:flex;flex-direction:column;gap:3px}
.meal-number{font-size:10px;color:var(--muted);font-weight:900;letter-spacing:.1em;text-transform:uppercase}
.meal-time{font-size:20px;line-height:1.1;letter-spacing:-.025em}
.meal-time.is-missing{font-size:13px;color:#b06a3f;letter-spacing:0}
.meal-summary{text-align:right;display:flex;flex-direction:column;gap:2px;white-space:nowrap}
.meal-summary strong{font-size:16px}.meal-summary span{font-size:10px;color:var(--muted)}
.meal-macro-line{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-top:10px}
.meal-macro-line span{background:#eef1eb;border-radius:8px;padding:5px 6px;color:var(--muted);font-size:8px;font-weight:850;text-align:center}
.meal-macro-line strong{color:#444b53;font-size:10px}
.meal-actions{display:flex;gap:7px;margin:9px 0 0}
.meal-actions button{border:0;background:transparent;color:#5b626b;font-size:10px;font-weight:850;padding:3px 0;cursor:pointer}
.meal-actions .danger-link{color:var(--red);margin-left:auto}
.meal-foods{border-top:1px solid var(--line);margin-top:10px}
.empty-meal{padding:13px 2px;color:#969ba2;font-size:11px;text-align:center}
.add-food-to-meal{width:100%;border:1px dashed #ccd2c8;background:#f2f4ef;color:#4d555e;border-radius:11px;padding:9px 10px;font-size:11px;font-weight:900;cursor:pointer}

.row-actions{display:flex;gap:5px;flex-wrap:wrap;margin-top:8px}
.row-actions button{border:0;background:#f1f3ee;border-radius:9px;padding:7px 10px;font-size:11px;font-weight:800;color:#555c65;cursor:pointer}
.row-actions button:disabled{opacity:.28}
.row-actions .danger-link{color:var(--red)}

.empty-state{padding:16px 4px;color:#92979f;font-size:13px;text-align:center}
.compact-empty{padding-top:7px}
.button-pair{display:grid;grid-template-columns:1.1fr 1fr;gap:8px;margin-top:12px}
.primary-button,.secondary-button,.danger-button{border:0;border-radius:14px;padding:12px 14px;font-weight:900;cursor:pointer;text-align:center}
.primary-button{background:var(--dark);color:#fff}
.secondary-button{background:#edf0ea;color:#373d45}
.danger-button{background:#fff1f1;color:#a33e3e;margin-top:8px}
.primary-button.full,.secondary-button.full,.danger-button.full{width:100%;margin-top:12px}
.secondary-button.small{padding:9px 13px}
.weight-card{display:flex;justify-content:space-between;align-items:center}

.bottom-nav{position:fixed;z-index:50;left:50%;transform:translateX(-50%);bottom:0;width:min(760px,100%);height:calc(var(--nav) + env(safe-area-inset-bottom));padding:7px 12px calc(7px + env(safe-area-inset-bottom));display:grid;grid-template-columns:repeat(3,1fr);background:rgba(250,251,248,.95);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border-top:1px solid var(--line)}
.bottom-nav__item{text-decoration:none;color:#777d85;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;border-radius:14px;font-size:11px;font-weight:800}
.bottom-nav__icon{font-size:21px}
.bottom-nav__item.is-active{background:var(--dark);color:#fff}

.modal[hidden]{display:none!important}
.modal{position:fixed;z-index:100;inset:0;display:flex;align-items:flex-end;justify-content:center}
.modal-backdrop{position:absolute;inset:0;background:rgba(16,18,22,.48);backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px)}
.modal-sheet{position:relative;width:min(760px,100%);max-height:88vh;overflow:auto;background:#fff;border-radius:26px 26px 0 0;padding:10px 16px calc(18px + env(safe-area-inset-bottom));box-shadow:0 -10px 40px rgba(0,0,0,.2)}
.small-sheet{max-height:50vh}
.modal-handle{width:44px;height:5px;border-radius:99px;background:#d9ddd5;margin:0 auto 10px}
.modal-title-row{display:flex;justify-content:space-between;align-items:center}
.modal-title-row h3{margin:5px 0 12px}
.close-button{border:0;background:#eff1ec;width:34px;height:34px;border-radius:50%;font-size:23px;cursor:pointer}
.search-help{font-size:11px;color:var(--muted);margin:7px 2px 10px;line-height:1.4}
.recent-title{font-weight:850;text-transform:uppercase;letter-spacing:.07em;font-size:9px}
.search-results{display:flex;flex-direction:column;gap:6px}
/* En móvil, el buscador de alimentos queda anclado arriba.
   Así, al reducirse los resultados mientras escribes, el panel se acorta
   hacia arriba y los resultados no terminan ocultos detrás del teclado. */
@media (max-width: 760px){
  #foodModal{
    align-items:flex-start;
    padding-top:max(10px, env(safe-area-inset-top));
  }
  #foodModal .modal-sheet{
    width:calc(100% - 16px);
    max-height:calc(100dvh - 20px - env(safe-area-inset-top));
    margin:0 8px;
    border-radius:22px;
    overflow:auto;
    padding-bottom:18px;
  }
  #foodModal .search-results{
    scroll-margin-bottom:12px;
  }
}

.search-item{border:1px solid var(--line);background:#fff;border-radius:13px;padding:11px;text-align:left;cursor:pointer}
.search-item:active{background:#f4f6f1}
.search-item strong{display:block;font-size:13px}
.search-item small{color:var(--muted);display:block;margin-top:3px}
.amount-panel{border-top:1px solid var(--line);margin-top:12px;padding-top:12px}
.amount-panel h3{margin:5px 0 10px;font-size:16px}
.amount-line{display:grid;grid-template-columns:1fr auto;align-items:center;gap:8px}
.amount-line input{width:100%;font-size:28px;font-weight:850;border:1px solid #dfe2dc;border-radius:14px;padding:10px 12px;outline:none}
.amount-line span{font-size:17px;color:var(--muted);font-weight:850;min-width:46px}
.inline-action{display:grid;grid-template-columns:1fr auto;gap:8px;align-items:center}
.copy-results{margin-top:12px}
.copy-meal{border:1px solid var(--line);border-radius:13px;margin-bottom:9px;padding:8px 10px}
.copy-meal-title{display:flex;justify-content:space-between;gap:10px;padding:3px 0 7px;font-size:11px;font-weight:900;text-transform:uppercase;letter-spacing:.06em}
.copy-meal-title span{color:var(--muted)}
.copy-empty{padding:8px 2px;color:var(--muted);font-size:11px;text-align:center}
.copy-item{display:flex;align-items:center;gap:10px;padding:10px 3px;border-top:1px solid var(--line)}
.copy-item input{width:20px;height:20px}
.copy-item label{flex:1;font-size:13px}.copy-item label small{color:var(--muted)}
.copy-item.is-unavailable{opacity:.58}
.copy-item.is-unavailable label{text-decoration:line-through;text-decoration-color:#b7bbb4}
.copy-unavailable{border-radius:99px;background:#f2e7e7;color:#985050;padding:4px 7px;font-size:8px;font-weight:900;text-transform:uppercase;letter-spacing:.04em}
.copy-toolbar{display:flex;justify-content:space-between;align-items:center;margin:8px 0}
.two-cols{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:10px}
.two-cols label{font-size:12px;font-weight:800;color:#565d67}
.two-cols input{margin-top:6px}
.weight-input{margin:8px 0 12px}

.toast{position:fixed;z-index:200;left:50%;transform:translateX(-50%);bottom:calc(var(--nav) + 18px + env(safe-area-inset-bottom));background:#1e2328;color:#fff;border-radius:12px;padding:10px 14px;font-size:12px;font-weight:800;box-shadow:0 8px 28px rgba(0,0,0,.2);max-width:calc(100% - 32px);text-align:center}
.placeholder-page{min-height:70vh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:30px}
.placeholder-page h1{margin:8px 0}.placeholder-page p{max-width:380px;color:var(--muted);line-height:1.55}.placeholder-icon{font-size:46px}.link-button{text-decoration:none;margin-top:10px}

@media(min-width:620px){
  .app-shell{padding-top:28px}
  .card{padding:20px}
  .macro-grid{grid-template-columns:repeat(6,1fr)}
  .meal-macro-line{grid-template-columns:repeat(6,1fr)}
  .modal{align-items:center}
  .modal-sheet{border-radius:26px;max-height:82vh}
  .bottom-nav{border-left:1px solid var(--line);border-right:1px solid var(--line);border-radius:18px 18px 0 0}
}

/* BIBLIOTECA */
.library-shell{max-width:900px;padding-top:18px}
.library-header{position:relative;overflow:hidden;margin:0 0 14px;padding:23px 22px;border-radius:27px;background:linear-gradient(135deg,#18231e 0%,#2f684c 58%,#4e8d68 100%);color:#fff;box-shadow:0 16px 38px rgba(29,74,51,.19)}
.library-header::after{content:"";position:absolute;right:-42px;top:-62px;width:170px;height:170px;border-radius:50%;background:rgba(255,255,255,.08)}
.library-header .eyebrow{color:rgba(255,255,255,.7)}
.library-header h1{position:relative;font-size:31px;letter-spacing:-.045em;margin:4px 0 5px}
.library-header p{position:relative;margin:0;color:rgba(255,255,255,.76);font-size:12px;line-height:1.45}
.library-tabs{display:grid;grid-template-columns:repeat(3,1fr);gap:9px;margin-bottom:20px}
.library-tab{position:relative;min-height:76px;border:1px solid #e1e5dd;background:rgba(255,255,255,.88);border-radius:18px;padding:12px 7px 10px;color:#687079;cursor:pointer;box-shadow:0 7px 22px rgba(25,28,31,.055);transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease}
.library-tab:active{transform:scale(.98)}
.library-tab>span{display:block;font-size:23px;margin-bottom:4px}
.library-tab strong{display:block;font-size:12px}
.library-tab small{position:absolute;right:8px;top:8px;display:grid;place-items:center;min-width:22px;height:22px;border-radius:99px;padding:0 6px;background:#eef1eb;color:#747b84;font-size:9px;font-weight:900}
.library-tab.is-active{background:#1d2923;border-color:#1d2923;color:#fff;box-shadow:0 11px 28px rgba(25,46,35,.2)}
.library-tab.is-active small{background:rgba(255,255,255,.15);color:#fff}
.library-panel[hidden]{display:none!important}
.library-panel{margin-bottom:18px}
.library-panel-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 2px 12px}
.library-panel-heading h2{font-size:22px;margin:2px 0 0;letter-spacing:-.035em}
.small-action{min-height:42px;padding:10px 15px;font-size:12px;white-space:nowrap;box-shadow:0 7px 18px rgba(23,31,27,.13)}
.library-tools{position:sticky;z-index:12;top:max(8px,env(safe-area-inset-top));display:grid;grid-template-columns:1fr auto;align-items:center;gap:11px;margin-bottom:14px;padding:10px;border:1px solid rgba(222,226,218,.92);border-radius:18px;background:rgba(250,251,248,.93);box-shadow:0 8px 25px rgba(25,28,31,.07);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px)}
.library-tools .search-input{min-height:44px;background:#fff;border-color:#dce1d8}
.library-tools.single-tool{display:flex;justify-content:flex-end}
.library-toggle{display:flex;align-items:center;gap:8px;color:#5f676f;font-size:11px;font-weight:850;white-space:nowrap;cursor:pointer;padding:4px}
.library-toggle input{width:19px;height:19px;accent-color:#397b59}
.library-list{display:flex;flex-direction:column;gap:13px}
.library-row{position:relative;overflow:hidden;display:block;padding:17px 17px 14px;border:1px solid #e1e5dd;border-radius:21px;background:#fff;box-shadow:0 9px 28px rgba(30,37,32,.065)}
.library-row::before{content:"";position:absolute;left:0;top:0;bottom:0;width:5px;background:#75a98a}
.library-row[hidden]{display:none!important}
.library-row.is-inactive{background:#f6f6f3;border-color:#dadcd6;box-shadow:none}
.library-row.is-inactive::before{background:#a7aaa4}
.recipe-library-card::before{background:#d89a55}
.training-library-card::before{background:#6b91b8}
.library-row-main{min-width:0;display:flex;flex-direction:column;gap:11px}
.library-card-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.library-identity{min-width:0}
.library-name-line{display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.library-name-line strong{min-width:0;font-size:16px;line-height:1.28;letter-spacing:-.015em}
.unit-badge,.recipe-badge,.status-badge{flex:0 0 auto;border-radius:99px;padding:5px 8px;font-size:8px;font-weight:950;text-transform:uppercase;letter-spacing:.06em}
.unit-badge{background:#eaf2ec;color:#3c7152}
.recipe-badge{background:#fff0df;color:#97612b}
.status-inactive{background:#e9e9e5;color:#686d68}
.library-meta-line{display:flex;flex-wrap:wrap;gap:5px 12px;margin-top:6px;color:#777e85;font-size:10px;font-weight:750}
.library-meta-line span+span{position:relative}
.library-meta-line span+span::before{content:"•";position:absolute;left:-8px;color:#b2b6b0}
.library-primary-macros{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px}
.library-stat{min-width:0;border-radius:13px;padding:9px 9px 8px;background:#f1f3ef}
.library-stat span{display:block;overflow:hidden;color:#747b82;font-size:8px;font-weight:900;text-overflow:ellipsis;text-transform:uppercase;white-space:nowrap}
.library-stat strong{display:inline-block;margin-top:3px;color:#353c42;font-size:16px;letter-spacing:-.03em}
.library-stat small{margin-left:3px;color:#8d9398;font-size:8px;font-weight:800}
.stat-kcal{background:#f4eee3}.stat-kcal strong{color:#8a602c}
.stat-protein{background:#e9f3ed}.stat-protein strong{color:#397452}
.stat-carbs{background:#eef0f8}.stat-carbs strong{color:#4f618e}
.stat-fat{background:#f5eceb}.stat-fat strong{color:#8a5650}
.library-secondary-macros{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px;margin-top:-3px}
.library-secondary-macros span{border:1px solid #e7e9e4;border-radius:99px;background:#fafbf8;padding:5px 8px;color:#727980;font-size:9px}
.library-secondary-macros b{color:#555d63;font-weight:900}
.library-subtitle{font-size:10px;color:var(--muted)}
.library-row-actions{display:flex;align-items:center;justify-content:flex-start;gap:7px;flex-wrap:wrap;margin-top:13px;padding-top:12px;border-top:1px solid #eceee9}
.library-row-actions button,.library-row-actions a{display:inline-flex;align-items:center;justify-content:center;min-height:39px;border:1px solid transparent;background:#eef1eb;border-radius:11px;padding:9px 12px;color:#50585f;text-decoration:none;font-size:10px;font-weight:900;cursor:pointer}
.library-row-actions button:active,.library-row-actions a:active{transform:scale(.98)}
.library-row-actions button:disabled{opacity:.25}
.library-row-actions .edit-link{background:#eaf0f5;color:#496479}
.library-row-actions .print-recipe-link{background:#f4ecdf;color:#805c32}
.library-row-actions .danger-link{color:#9d4a4a;background:#fff0f0}
.library-row-actions .restore-link{color:#2f714d;background:#e5f3e9}
.library-row-actions .permanent-delete-link{margin-left:auto;color:#fff;background:#a84747;box-shadow:0 5px 14px rgba(133,47,47,.16)}
.compact-library-row{padding-top:15px}
.compact-library-row .library-row-main{gap:4px}
.compact-library-row .library-row-actions{margin-top:11px}
.library-no-results{border-style:dashed;box-shadow:none}

.library-editor-sheet{max-height:92vh;padding-left:19px;padding-right:19px}
.library-editor-sheet .field-label{margin-top:14px;font-size:12px}
.library-editor-sheet .text-input,.library-editor-sheet .select-input,.library-editor-sheet .search-input,.library-editor-sheet .textarea{min-height:45px;background:#fff;border-color:#d9ded5}
.library-form-grid{margin-top:9px;gap:11px}
.nutrition-form-heading{display:flex;justify-content:space-between;align-items:center;margin:21px 0 10px;padding-top:16px;border-top:1px solid var(--line)}
.nutrition-form-heading strong{font-size:14px}.nutrition-form-heading span{border-radius:99px;background:#edf2ec;padding:5px 8px;font-size:9px;color:#51705e;font-weight:900}
.nutrient-form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:9px}
.nutrient-form-grid label{border-radius:13px;background:#f5f6f3;padding:9px;font-size:10px;font-weight:900;color:#59616a}
.nutrient-form-grid input{margin-top:6px}
.recipe-editor-sheet{padding-bottom:calc(24px + env(safe-area-inset-bottom))}
.compact-amount-line input{font-size:22px}
.recipe-section-heading{display:flex;justify-content:space-between;align-items:flex-end;gap:10px;margin:21px 0 9px;padding-top:16px;border-top:1px solid var(--line)}
.recipe-section-heading strong{font-size:15px}.recipe-section-heading span{font-size:9px;color:var(--muted);text-align:right}
.ingredient-search-results{display:flex;flex-direction:column;gap:6px;max-height:220px;overflow:auto;margin:8px 0}
.ingredient-search-results button{border:1px solid var(--line);background:#fff;border-radius:13px;padding:11px 12px;text-align:left;cursor:pointer}
.ingredient-search-results button strong{display:block;font-size:12px}.ingredient-search-results button small{display:block;margin-top:3px;color:var(--muted);font-size:9px}
.ingredient-search-empty{padding:11px;color:var(--muted);font-size:11px;text-align:center}
.recipe-ingredients{margin-top:9px}
.empty-recipe-ingredients{padding:17px 8px;border:1px dashed #cfd5cb;border-radius:14px;background:#fafbf8;color:#8e959b;font-size:11px;text-align:center}
.recipe-ingredient-row{display:grid;grid-template-columns:minmax(0,1fr) 105px 36px;align-items:center;gap:8px;padding:11px 0;border-top:1px solid var(--line)}
.recipe-ingredient-row>div{min-width:0}.recipe-ingredient-row strong{display:block;font-size:12px;line-height:1.25}.recipe-ingredient-row small{font-size:9px;color:var(--muted)}
.recipe-ingredient-row label{display:grid;grid-template-columns:1fr auto;align-items:center;gap:4px}
.recipe-ingredient-row input{width:100%;min-width:0;border:1px solid #d9ded5;border-radius:10px;padding:9px;font-size:12px;font-weight:850;text-align:right}
.recipe-ingredient-row label span{font-size:10px;color:var(--muted);font-weight:850}
.recipe-ingredient-row>button{border:0;background:#fff0f0;color:var(--red);width:34px;height:34px;border-radius:50%;font-size:18px;cursor:pointer}
.recipe-calculation{margin-top:13px;background:linear-gradient(135deg,#edf3ee,#f4f1e8);border:1px solid #e1e5dd;border-radius:15px;padding:13px}
.recipe-calculation>div{display:flex;justify-content:space-between;gap:12px;align-items:center}
.recipe-calculation span{font-size:10px;color:var(--muted);font-weight:850}.recipe-calculation strong{font-size:14px}
.recipe-calculation small{display:block;margin-top:8px;color:#555d65;font-size:9px;line-height:1.6}

@media(max-width:760px){
  .library-modal{align-items:flex-start;padding-top:max(8px,env(safe-area-inset-top))}
  .library-modal .modal-sheet{width:calc(100% - 12px);max-height:calc(100dvh - 16px - env(safe-area-inset-top));margin:0 6px;border-radius:20px;overflow:auto;padding-bottom:18px}
}

@media(max-width:520px){
  .library-shell{padding-left:11px;padding-right:11px}
  .library-header{padding:20px 18px;border-radius:23px}
  .library-header h1{font-size:28px}
  .library-tabs{gap:7px}
  .library-tab{min-height:70px;padding-left:4px;padding-right:4px}
  .library-tools{grid-template-columns:1fr;padding:9px}
  .library-toggle{justify-self:start}
  .library-row{padding:16px 14px 13px}
  .library-card-top{gap:8px}
  .library-name-line strong{font-size:15px}
  .library-primary-macros{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
  .library-stat{padding:9px 10px}
  .library-row-actions .permanent-delete-link{width:100%;margin-left:0}
  .library-form-grid{grid-template-columns:1fr}
  .nutrient-form-grid{grid-template-columns:repeat(2,1fr)}
}

@media(min-width:620px){
  .nutrient-form-grid{grid-template-columns:repeat(4,1fr)}
}

/* BOTONERA V5.1 ---------------------------------------------------------- */
:root{
  --button-green:#326f4e;
  --button-green-dark:#23553b;
  --button-blue:#476b83;
  --button-amber:#a66e30;
  --button-red:#a94a4a;
  --button-shadow:0 8px 18px rgba(25,45,34,.14),0 2px 4px rgba(25,45,34,.08);
  --button-soft-shadow:0 5px 13px rgba(28,35,31,.075);
}

button,a{
  -webkit-tap-highlight-color:transparent;
}
button,.date-arrow,.print-shortcut,.bottom-nav__item,.library-row-actions a{
  transition:transform .14s ease,box-shadow .14s ease,background-color .14s ease,border-color .14s ease,color .14s ease,filter .14s ease;
}
button:focus-visible,a:focus-visible{
  outline:3px solid rgba(63,140,101,.28);
  outline-offset:2px;
}
button:disabled{
  cursor:not-allowed;
  box-shadow:none!important;
  filter:grayscale(.35);
}

/* Navegación y acciones superiores del día */
.date-arrow{
  width:44px;
  height:44px;
  justify-self:center;
  border:1px solid #dde2da;
  border-radius:14px;
  background:linear-gradient(180deg,#fff,#f0f3ee);
  color:#30453a;
  font-size:34px;
  font-weight:450;
  line-height:1;
  box-shadow:var(--button-soft-shadow);
}
.date-arrow:active{transform:scale(.93);background:#e7ede7}
.date-center{
  min-height:48px;
  margin:0 7px;
  border:1px solid transparent;
  border-radius:15px;
}
.date-center:active{transform:scale(.985);background:#ecefe9;border-color:#e0e4dc}
.day-print-actions{margin:-5px 1px 13px}
.print-shortcut{
  min-width:176px;
  min-height:48px;
  display:grid;
  grid-template-columns:34px 1fr 12px;
  align-items:center;
  gap:9px;
  border:1px solid #d7e6da;
  border-radius:15px;
  padding:7px 10px 7px 8px;
  background:linear-gradient(135deg,#ffffff 0%,#edf6ef 100%);
  color:#294737;
  text-decoration:none;
  box-shadow:0 8px 20px rgba(41,84,58,.11);
}
.print-shortcut-icon{
  display:grid;
  place-items:center;
  width:34px;
  height:34px;
  border-radius:11px;
  background:linear-gradient(145deg,#397b57,#23563b);
  color:#fff;
  font-size:16px;
  box-shadow:0 5px 11px rgba(34,91,59,.22);
}
.print-shortcut-copy{display:flex;min-width:0;flex-direction:column;gap:1px;text-align:left}
.print-shortcut-copy strong{font-size:11px;line-height:1.15}
.print-shortcut-copy small{color:#748178;font-size:8px;font-weight:800}
.print-shortcut-arrow{color:#5e7868;font-size:21px;font-weight:700;line-height:1}
.print-shortcut:active{transform:scale(.97);background:#e7f2e9;box-shadow:0 3px 9px rgba(41,84,58,.1)}

/* Botones principales y secundarios */
.primary-button,.secondary-button,.danger-button{
  min-height:45px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  border:1px solid transparent;
  border-radius:14px;
  letter-spacing:.005em;
}
.primary-button{
  border-color:#24583d;
  background:linear-gradient(145deg,var(--button-green),var(--button-green-dark));
  color:#fff;
  box-shadow:var(--button-shadow);
  text-shadow:0 1px rgba(0,0,0,.12);
}
.secondary-button{
  border-color:#dde3db;
  background:linear-gradient(180deg,#fff,#edf1eb);
  color:#39483f;
  box-shadow:var(--button-soft-shadow);
}
.danger-button{
  border-color:#f0d0d0;
  background:linear-gradient(180deg,#fff6f6,#f9e6e6);
  color:#9e3e3e;
  box-shadow:0 5px 13px rgba(139,53,53,.09);
}
.primary-button:active,.secondary-button:active,.danger-button:active{transform:translateY(1px) scale(.98);box-shadow:0 2px 6px rgba(25,35,29,.1)}
.primary-button.small-action{min-height:43px;border-radius:13px;padding:10px 15px;box-shadow:0 7px 17px rgba(35,85,58,.2)}
#copyFoodButton::before{content:"⇄";font-size:15px}
#addTrainingButton{border-style:dashed;border-color:#bfcbbf;background:linear-gradient(180deg,#f9fbf8,#e9efe9)}
#weightButton::before{content:"✎";font-size:13px}
#saveMeal::before,#confirmFood::before,#saveFoodEdit::before,#saveTraining::before,#saveWeight::before,#saveLibraryFood::before,#savePrepared::before,#saveTrainingType::before{content:"✓";font-size:13px;font-weight:950}
#confirmCopy::before{content:"⇄";font-size:15px}
#deleteWeight::before{content:"×";font-size:17px;line-height:1}

/* Acciones dentro de comidas y entrenamientos */
.meal-actions{gap:7px;margin-top:11px}
.meal-actions button{
  min-height:34px;
  display:inline-flex;
  align-items:center;
  gap:5px;
  border:1px solid #dfe5dd;
  border-radius:10px;
  padding:7px 10px;
  background:linear-gradient(180deg,#fff,#eef2ed);
  color:#506057;
  box-shadow:0 3px 8px rgba(30,40,34,.06);
}
.meal-actions [data-action="edit-meal"]::before{content:"◷";font-size:14px;color:#47725b}
.meal-actions .danger-link{margin-left:auto;border-color:#f0dada;background:#fff5f5;color:#a44b4b}
.meal-actions .danger-link::before{content:"×";font-size:15px}
.meal-actions button:active{transform:scale(.97);box-shadow:none}
.add-food-to-meal{
  min-height:42px;
  margin-top:3px;
  border:1px dashed #9db6a3;
  border-radius:12px;
  background:linear-gradient(180deg,#f7fbf7,#eaf3eb);
  color:#356448;
  box-shadow:inset 0 1px #fff;
}
.add-food-to-meal:active{transform:scale(.985);background:#dfede2}
.row-actions{gap:6px}
.row-actions button{
  min-height:34px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  border:1px solid #e0e5dd;
  border-radius:10px;
  padding:7px 10px;
  background:linear-gradient(180deg,#fff,#edf1eb);
  color:#536057;
  box-shadow:0 3px 8px rgba(30,40,34,.055);
}
.row-actions [data-action="move-up"],.row-actions [data-action="move-down"]{width:34px;padding:7px;color:#3f6751;font-size:14px}
.row-actions [data-action="edit-food"]::before,.row-actions [data-action="edit-training"]::before{content:"✎";color:#52748a}
.row-actions .danger-link{border-color:#f1dddd;background:#fff4f4;color:#a94a4a}
.row-actions .danger-link::before{content:"×";font-size:14px}
.row-actions button:active{transform:scale(.95);box-shadow:none}
.text-action{
  min-height:38px;
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin-top:9px;
  border:1px solid #dbe5dc;
  border-radius:11px;
  padding:8px 12px;
  background:#eef6ef;
  color:#346148;
  box-shadow:var(--button-soft-shadow);
}
.text-action::before{content:"✓";font-size:12px}
.text-action:active{transform:scale(.98);box-shadow:none}

/* Estado, buscadores, modales y menú inferior */
.mood-button{border-width:1px;background:linear-gradient(180deg,#fff,#f1f3ef);box-shadow:0 4px 11px rgba(30,38,33,.055)}
.mood-button:active{transform:scale(.94)}
.mood-button.is-selected{border-width:2px;background:#fff;box-shadow:0 8px 18px rgba(0,0,0,.1),inset 0 0 0 2px rgba(255,255,255,.8)}
.close-button{
  display:grid;
  place-items:center;
  border:1px solid #dfe4dc;
  background:linear-gradient(180deg,#fff,#e9ede7);
  color:#5e6861;
  box-shadow:0 4px 10px rgba(25,32,28,.09);
}
.close-button:active{transform:scale(.9);background:#e3e8e1}
.search-item,.ingredient-search-results button{
  position:relative;
  border-color:#dde3da;
  background:linear-gradient(180deg,#fff,#f8faf7);
  box-shadow:0 4px 11px rgba(30,38,33,.045);
}
.search-item:active,.ingredient-search-results button:active{transform:scale(.985);background:#eef4ed}
.bottom-nav__item:active{transform:scale(.94)}
.bottom-nav__item.is-active{background:linear-gradient(145deg,#26392e,#17251d);box-shadow:0 6px 15px rgba(25,47,35,.18)}

/* Biblioteca: pestañas y acciones de cada ficha */
.library-tab{overflow:hidden}
.library-tab::after{content:"";position:absolute;inset:auto 16% 0;height:3px;border-radius:99px 99px 0 0;background:transparent}
.library-tab.is-active::after{background:#77bd91}
.library-tab:active{transform:translateY(1px) scale(.97)}
.library-row-actions{gap:8px;padding-top:13px}
.library-row-actions button,.library-row-actions a{
  min-height:40px;
  gap:6px;
  border-color:#e0e5dd;
  border-radius:12px;
  padding:9px 12px;
  background:linear-gradient(180deg,#fff,#edf1eb);
  box-shadow:0 4px 10px rgba(29,38,32,.065);
}
.library-row-actions .edit-link,.library-row-actions [data-action="edit-training-type"]{
  border-color:#d6e2e9;
  background:linear-gradient(180deg,#f8fcff,#e5eef4);
  color:var(--button-blue);
}
.library-row-actions .edit-link::before,.library-row-actions [data-action="edit-training-type"]::before{content:"✎";font-size:13px}
.library-row-actions .print-recipe-link{
  border-color:#ead9bf;
  background:linear-gradient(180deg,#fffaf2,#f1e4d1);
  color:#875b29;
  box-shadow:0 5px 12px rgba(142,94,40,.11);
}
.library-row-actions .print-recipe-link>span{font-size:13px;line-height:1}
.library-row-actions .danger-link{
  border-color:#f0d8d8;
  background:linear-gradient(180deg,#fff8f8,#f7e6e6);
  color:#9e4545;
}
.library-row-actions .danger-link::before{content:"⏻";font-size:12px;font-weight:950}
.library-row-actions .restore-link{
  border-color:#cee4d5;
  background:linear-gradient(180deg,#f7fff9,#e1f1e6);
  color:#2e714c;
}
.library-row-actions .restore-link::before{content:"↻";font-size:14px}
.library-row-actions .permanent-delete-link{
  border-color:#943b3b;
  background:linear-gradient(145deg,#b95656,#913737);
  color:#fff;
  box-shadow:0 6px 14px rgba(133,47,47,.19);
}
.library-row-actions .permanent-delete-link::before{content:"×";font-size:15px}
.library-row-actions [data-action="move-training-up"],.library-row-actions [data-action="move-training-down"]{width:40px;padding:9px;color:#4d7088;font-size:14px}
.library-row-actions button:active,.library-row-actions a:active{transform:translateY(1px) scale(.96);box-shadow:none}
.recipe-ingredient-row>button{border:1px solid #efdada;background:linear-gradient(180deg,#fff7f7,#f7e6e6);box-shadow:0 4px 9px rgba(135,52,52,.08)}
.recipe-ingredient-row>button:active{transform:scale(.9)}

@media(hover:hover){
  .primary-button:hover{filter:brightness(1.07);transform:translateY(-1px);box-shadow:0 10px 22px rgba(32,83,55,.22)}
  .secondary-button:hover,.date-arrow:hover,.row-actions button:hover,.meal-actions button:hover,.library-row-actions button:hover,.library-row-actions a:hover{transform:translateY(-1px);filter:brightness(1.015);box-shadow:0 7px 15px rgba(28,38,32,.1)}
  .print-shortcut:hover{transform:translateY(-1px);box-shadow:0 11px 24px rgba(41,84,58,.15)}
  .library-tab:hover:not(.is-active){transform:translateY(-2px);border-color:#cad4c9;box-shadow:0 10px 25px rgba(25,38,30,.09)}
}

@media(max-width:520px){
  .button-pair{grid-template-columns:1fr 1fr}
  .primary-button,.secondary-button,.danger-button{padding-left:11px;padding-right:11px;font-size:12px}
  .meal-actions button{padding-left:9px;padding-right:9px}
  .library-row-actions button,.library-row-actions a{flex:1 1 auto;padding-left:10px;padding-right:10px}
  .library-row-actions [data-action="move-training-up"],.library-row-actions [data-action="move-training-down"]{flex:0 0 40px}
  .library-row-actions .permanent-delete-link{flex-basis:100%}
}

/* NAVEGACIÓN RÁPIDA Y DOBLE IMPRESIÓN V5.3 ----------------------------- */
.date-center-group{min-width:0;display:flex;align-items:center;justify-content:center;gap:7px}
.date-center-group .date-center{min-width:0;flex:0 1 auto;margin:0;padding-left:7px;padding-right:7px}
.calendar-quick-button{
  position:relative;
  overflow:hidden;
  flex:0 0 40px;
  width:40px;
  height:40px;
  display:grid;
  place-items:center;
  border:1px solid #cfe0d3;
  border-radius:13px;
  background:linear-gradient(145deg,#f8fff9,#e1efe4);
  color:#2f6849;
  font-size:21px;
  font-weight:900;
  line-height:1;
  box-shadow:0 6px 15px rgba(42,91,60,.13);
  cursor:pointer;
}
.calendar-quick-button span{transform:translateY(-1px)}
.calendar-quick-button .native-date-overlay{
  position:absolute;
  inset:0;
  z-index:2;
  width:100%;
  height:100%;
  margin:0;
  padding:0;
  border:0;
  border-radius:inherit;
  opacity:.001;
  pointer-events:auto;
  cursor:pointer;
  font-size:16px;
}
.calendar-quick-button:focus-within{outline:3px solid rgba(47,104,73,.2);outline-offset:2px}
.calendar-quick-button:active{transform:scale(.93);background:#d9eadc;box-shadow:none}
.day-print-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:100%;margin:-3px 0 13px}
.day-print-actions .print-shortcut{min-width:0;width:100%}
.week-print-shortcut{border-color:#e6d9c5;background:linear-gradient(135deg,#fff 0%,#f7efe3 100%);color:#65451f;box-shadow:0 8px 20px rgba(116,78,32,.1)}
.week-print-shortcut .print-shortcut-icon{background:linear-gradient(145deg,#b27a39,#825423);box-shadow:0 5px 11px rgba(126,81,31,.2)}
.week-print-shortcut .print-shortcut-copy small{color:#8a7965}
.week-print-shortcut .print-shortcut-arrow{color:#8c714f}
.week-print-shortcut:active{background:#f2e7d6;box-shadow:0 3px 9px rgba(116,78,32,.08)}

@media(hover:hover){
  .calendar-quick-button:hover{transform:translateY(-1px);filter:brightness(1.02);box-shadow:0 9px 19px rgba(42,91,60,.17)}
  .week-print-shortcut:hover{box-shadow:0 11px 24px rgba(116,78,32,.14)}
}

@media(max-width:430px){
  .date-center-group{gap:4px}
  .date-center-group .date-center{padding-left:3px;padding-right:3px}
  .calendar-quick-button{flex-basis:36px;width:36px;height:36px;border-radius:11px;font-size:19px}
  .day-print-actions{gap:7px}
  .day-print-actions .print-shortcut{grid-template-columns:31px minmax(0,1fr);gap:7px;padding-right:8px}
  .day-print-actions .print-shortcut-icon{width:31px;height:31px;border-radius:10px;font-size:14px}
  .day-print-actions .print-shortcut-arrow{display:none}
  .day-print-actions .print-shortcut-copy strong{font-size:10px}
  .day-print-actions .print-shortcut-copy small{font-size:7.5px}
}

/* DÍA LIBRE / INGESTA SIN CONTABILIZAR V6 ------------------------------ */
.free-day-control{
  display:grid;
  grid-template-columns:46px minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  margin:0 0 12px;
  padding:13px 14px;
  overflow:hidden;
  border:1px solid #e5ded3;
  border-radius:18px;
  background:linear-gradient(135deg,#fff 0%,#faf7f1 100%);
  box-shadow:0 8px 22px rgba(73,54,32,.055);
}
.free-day-control-icon{
  display:grid;
  place-items:center;
  width:46px;
  height:46px;
  border:1px solid #e5d5c0;
  border-radius:15px;
  background:linear-gradient(145deg,#fff9ef,#f2e4d1);
  color:#9a6328;
  font-size:21px;
  font-weight:950;
  box-shadow:0 5px 12px rgba(137,88,36,.09);
}
.free-day-control-copy{min-width:0}
.free-day-control-copy .eyebrow{display:block;color:#9a7147;font-size:8px}
.free-day-control-copy>strong{display:block;margin-top:3px;color:#493829;font-size:14px;line-height:1.2;letter-spacing:-.01em}
.free-day-control-copy p{margin:4px 0 0;color:#766b60;font-size:10px;line-height:1.4}
.free-day-toggle{
  min-height:42px;
  border:1px solid #d8c4a9;
  border-radius:13px;
  padding:9px 12px;
  background:linear-gradient(180deg,#fffdf9,#f1e7da);
  color:#76502b;
  font-size:10px;
  font-weight:950;
  line-height:1.2;
  cursor:pointer;
  box-shadow:0 5px 12px rgba(91,61,28,.09);
}
.free-day-toggle:active{transform:scale(.96);box-shadow:none}

.free-day-control.is-active{
  border-color:#e9ad78;
  background:linear-gradient(135deg,#fff4e8 0%,#ffe9d5 58%,#fff7ef 100%);
  box-shadow:0 10px 26px rgba(177,86,29,.12),inset 4px 0 0 #dc6e2c;
}
.free-day-control.is-active .free-day-control-icon{
  border-color:#ce6025;
  background:linear-gradient(145deg,#e77b32,#ba4b20);
  color:#fff;
  text-shadow:0 1px rgba(0,0,0,.12);
  box-shadow:0 6px 15px rgba(173,71,25,.22);
}
.free-day-control.is-active .free-day-control-copy .eyebrow{color:#a54820}
.free-day-control.is-active .free-day-control-copy>strong{color:#873716}
.free-day-control.is-active .free-day-control-copy p{color:#7c4c35}
.free-day-control.is-active .free-day-toggle{
  border-color:#ce632b;
  background:linear-gradient(145deg,#db7135,#b84821);
  color:#fff;
  text-shadow:0 1px rgba(0,0,0,.12);
  box-shadow:0 7px 16px rgba(158,62,24,.18);
}

.nutrition-card.is-excluded{
  border-color:#edc29d;
  background:linear-gradient(180deg,#fffdfa 0%,#fff8f1 100%);
  box-shadow:0 10px 30px rgba(111,61,27,.075);
}
.nutrition-card.is-excluded .nutrition-heading .eyebrow{color:#b15326}
.free-day-total strong{color:#bd5525;font-size:31px;letter-spacing:.02em}
.free-day-total span{color:#99502d}
.free-day-nutrition-note{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  margin:-1px 0 15px;
  border:1px solid #efd2b7;
  border-radius:14px;
  padding:10px 12px;
  background:#fff2e5;
}
.free-day-nutrition-note strong{color:#934019;font-size:11px;line-height:1.3}
.free-day-nutrition-note span{max-width:360px;color:#7b5c49;font-size:9px;line-height:1.45;text-align:right}
.nutrition-card.is-excluded .meal-card{border-color:#ebd4c0;background:#fffdfa}
.nutrition-card.is-excluded .meal-header{border-bottom-color:#ead9ca}
.nutrition-card.is-excluded .meal-number{color:#a7542c}
.nutrition-card.is-excluded .food-row{border-color:#eee1d5}
.nutrition-card.is-excluded .food-main>span{color:#8d6854}
.excluded-label{color:#b04b20!important;font-size:11px!important;text-transform:uppercase;letter-spacing:.045em}

@media(hover:hover){
  .free-day-toggle:hover{transform:translateY(-1px);filter:brightness(1.02);box-shadow:0 8px 17px rgba(91,61,28,.13)}
  .free-day-control.is-active .free-day-toggle:hover{box-shadow:0 9px 19px rgba(158,62,24,.22)}
}

@media(max-width:520px){
  .free-day-control{grid-template-columns:42px minmax(0,1fr);gap:10px;padding:12px}
  .free-day-control-icon{width:42px;height:42px;border-radius:13px}
  .free-day-toggle{grid-column:1/-1;width:100%;min-height:44px}
  .free-day-nutrition-note{flex-direction:column;gap:3px}
  .free-day-nutrition-note span{max-width:none;text-align:left}
}
