/* ---------------------------------------------------------------
   Mi plan — app shell
   Dark, native-feeling, fixed zoom, safe-area aware.
----------------------------------------------------------------*/

:root {
  --bg:        #0E1116;
  --bg-soft:   #141922;
  --surface:   #1A202B;
  --surface-2: #222937;
  --line:      #2C3444;
  --ink:       #EEF2F8;
  --muted:     #8A93A3;
  --cobalt:    #4C6FFF;
  --amber:     #FFB020;
  --green:     #2ECC71;
  --danger:    #FF5C5C;
  --radius:    16px;
  --pad:       16px;
  --tabbar-h:  64px;
  --shadow:    0 8px 24px rgba(0, 0, 0, .35);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Scrolling stays, pinch-zoom does not. iOS Safari ignores user-scalable=no,
     so the viewport meta tag alone is not enough. */
  touch-action: pan-x pan-y;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
  /* Never let a long word or a wide element push the layout sideways. */
  overflow-x: hidden;
  width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  /* 16px minimum stops mobile browsers from zooming on focus */
  font-size: max(16px, 1em);
  color: inherit;
}

a { color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* --------------------------------------------------- app shell */

.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
}

.app-header {
  padding: calc(env(safe-area-inset-top) + 22px) var(--pad) 14px;
  background: linear-gradient(180deg, var(--bg-soft), var(--bg));
  border-bottom: 1px solid var(--line);
}

.app-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.app-header h1,
.login-brand h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 42px;
  line-height: .95;
  margin: 4px 0 0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .01em;
}

.app-header h1 em {
  font-style: normal;
  color: var(--cobalt);
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.chip {
  background: var(--surface-2);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--line);
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:active { background: var(--surface-2); }

/* ------------------------------------------------------- panes */

.pane {
  padding: 4px var(--pad) 8px;
}

.pane[hidden] { display: none; }

.block-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin: 22px 0 10px;
}

.warm {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #C9D1DE;
}

/* ------------------------------------------------- day selector */

.subnav {
  display: grid;
  gap: 6px;
  margin: 14px 0 4px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, var(--bg) 78%, transparent);
  padding: 10px 0;
}

.subnav.cols-3 { grid-template-columns: repeat(3, 1fr); }
.subnav.cols-7 { grid-template-columns: repeat(7, 1fr); }

.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 9px 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.05;
  min-height: 48px;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.tab .big   { font-size: 20px; }
.tab .small { font-size: 10px; letter-spacing: .06em; margin-top: 4px; font-weight: 600; color: var(--muted); }

.subnav.cols-7 .tab .big { font-size: 16px; }

.tab[aria-selected="true"] {
  background: var(--cobalt);
  border-color: var(--cobalt);
  color: #fff;
}

.tab[aria-selected="true"] .small { color: rgba(255, 255, 255, .8); }

/* ---------------------------------------------------- exercises */

.ex {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.ex::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--cobalt);
}

.ex.acc::before { background: var(--amber); }

.ex-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.idx {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .06em;
}

.name {
  font-weight: 600;
  font-size: 16px;
  line-height: 1.25;
  flex: 1;
}

.how {
  color: #B7C0CE;
  font-size: 14px;
  margin-top: 6px;
}

.how b { color: var(--ink); font-weight: 600; }

.load {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.reps {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
  font-weight: 600;
  font-size: 13px;
}

.rest { color: var(--muted); font-size: 13px; }

.vid {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 9px 13px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.vid span:first-child { color: var(--danger); font-size: 12px; }
.vid:active { background: var(--line); }

.sets {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.dot {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, background .15s ease, color .15s ease;
}

.dot:active { transform: scale(.92); }

.dot[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: #08210F;
}

.sets-hint {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

/* --------------------------------------------------- core cards */

.core-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.core-card h3 {
  margin: 0 0 6px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  text-transform: uppercase;
  font-weight: 700;
}

.core-card p { margin: 0; color: #B7C0CE; font-size: 14px; }

/* -------------------------------------------------------- meals */

.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.kpi .v {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.kpi .k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 4px;
}

.meal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.when {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 700;
}

.dish { font-weight: 600; font-size: 16px; margin-top: 3px; }
.detail { color: #B7C0CE; font-size: 14px; margin-top: 5px; }

.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.tag {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* -------------------------------------------------------- rules */

.rule {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin-bottom: 8px;
}

.rule .n {
  flex: 0 0 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--amber);
}

.rule p { margin: 0; font-size: 14px; color: #B7C0CE; }
.rule p strong { color: var(--ink); }

/* ------------------------------------------------------ actions */

.actions { margin: 18px 0 6px; }

.btn-ghost {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.btn-ghost:active { background: var(--surface); }

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 0;
  background: var(--cobalt);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary:active { filter: brightness(.9); }

/* ------------------------------------------------------- tabbar */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  z-index: 20;
  display: grid;
  background: rgba(14, 17, 22, .92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 0 4px;
  height: var(--tabbar-h);
  cursor: pointer;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  border-top: 2px solid transparent;
  margin-top: -1px;
}

.tabbar button[aria-selected="true"] {
  color: #fff;
  border-top-color: var(--amber);
}

/* -------------------------------------------------------- sheet */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] { display: none; }

.sheet-panel {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border: 1px solid var(--line);
  padding: 18px var(--pad) calc(18px + env(safe-area-inset-bottom));
}

.sheet-title {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.plan-list { display: grid; gap: 6px; margin-bottom: 10px; }

.plan-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
}

.plan-row[aria-current="true"] { border-color: var(--cobalt); }
.plan-row .mark { color: var(--amber); }

.sheet-link {
  display: block;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  text-decoration: none;
  margin-bottom: 6px;
  font-weight: 600;
}

.sheet-link.danger { color: var(--danger); }

.sheet-close {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
}

/* -------------------------------------------------------- login */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: var(--pad);
  background: radial-gradient(120% 80% at 50% 0%, #1B2233 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
}

.login-brand { margin-bottom: 20px; }
.login-brand h1 { color: var(--ink); }

.login-error {
  background: rgba(255, 92, 92, .12);
  border: 1px solid var(--danger);
  color: #FFC9C9;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  margin: 0 0 14px;
}

.field { display: block; margin-bottom: 14px; }

.field > span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.field input,
.field textarea {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field textarea:focus { border-color: var(--cobalt); }

.field textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ------------------------------------------------------ notices */

.notice {
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 14px;
  margin: 14px 0 0;
  border: 1px solid var(--line);
}

.notice.ok  { border-color: var(--green);  background: rgba(46, 204, 113, .1); }
.notice.bad { border-color: var(--danger); background: rgba(255, 92, 92, .1); }

.import-form { margin-top: 10px; }

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