/* AUTH SCREEN */
#screen-auth {
  background: var(--greyish);
  overflow-y: auto;
}
#screen-auth.active {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: flex-start;
  justify-content: flex-start;
  padding: 48px 32px 90px;
  text-align: center;
  width: 100%;
  min-height: 100vh;
  box-sizing: border-box;
}

/* ONBOARDING SCREEN */
#screen-onboarding {
  background: var(--greyish);
  position: relative;
  overflow-y: auto;
  -webkit-flex-direction: column;
  flex-direction: column;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: flex-start;
  justify-content: flex-start;
  padding: 48px 32px 90px;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}
#screen-onboarding.active {
  display: -webkit-flex;
  display: flex;
  min-height: 100vh;
}

#screen-onboarding.as-panel {
  display: -webkit-flex;
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 400;
  overflow-y: auto;
  min-height: unset;
  transform: translateY(-100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
#screen-onboarding.as-panel.panel-open { transform: translateY(0); }

.onboard-close {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(17,24,39,0.1);
  border: none;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text);
  z-index: 10;
  line-height: 1;
}
.onboard-close.visible { display: flex; }

.onboard-logo { width: 180px; height: auto; margin-bottom: 40px; }
.onboard-title {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 34px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.15;
  margin-bottom: 16px;
}
.onboard-sub {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 1.7;
  max-width: 340px;
  margin: 0 auto 48px;
}
.onboard-form { width: 100%; max-width: 360px; }
.onboard-legal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  padding-bottom: 12px;
}
.onboard-legal-link {
  font-size: 12px;
  color: var(--text-light);
  text-decoration: none;
  transition: color 0.15s;
}
.onboard-legal-link:hover { color: var(--gold); }
.onboard-legal-sep { font-size: 12px; color: var(--border-dark); }
.field-group { margin-bottom: 20px; text-align: left; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin-bottom: 8px;
}
.field-input {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: 'Instrument Sans', sans-serif;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}
.field-input::placeholder { color: var(--text-light); }
.field-input:focus { border-color: var(--gold); }
.field-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.field-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* MINI TOPBAR */
.mini-topbar {
  position: sticky;
  top: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 20px;
  z-index: 150;
}
.mini-logo { width: 80px; height: auto; }
.burger-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
}
.burger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: opacity 0.2s;
}
.burger-btn:hover .burger-line { opacity: 0.6; }

/* MAIN APP */
#screen-app { background: var(--cream); padding-bottom: 100px; }

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.header-greeting {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
}
.header-day-badge {
  background: var(--white);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-mid);
  letter-spacing: 0.05em;
}
.header-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.header-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* NAV */
.app-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: 'Instrument Sans', sans-serif;
  transition: color 0.2s;
  color: var(--text-light);
}
.nav-btn.active { color: var(--gold); }
.nav-icon { font-size: 22px; line-height: 1; display: block; }
.nav-label { font-size: 10px; font-weight: 500; letter-spacing: 0.04em; }

/* SECTIONS */
.section { display: none; padding: 20px; }
.section.active { display: block; }

/* EDIT PANEL */
.edit-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--greyish);
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}
.edit-panel.panel-open { transform: translateY(0); }
.edit-panel-header {
  position: sticky;
  top: 0;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  z-index: 10;
}
.edit-panel-close {
  margin-left: auto;
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(17,24,39,0.08);
  border: none;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
  line-height: 1;
}
.edit-panel-title { font-size: 15px; font-weight: 500; color: var(--text); line-height: 1.3; }
.edit-panel-day { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.edit-panel-body { padding: 20px; padding-bottom: 48px; }

/* DEMO BAR */
.demo-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  height: 38px;
  background: var(--gold);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
}
.demo-bar-label { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; opacity: 0.9; flex-shrink: 0; }
.demo-bar-day { flex: 1; text-align: center; font-size: 12px; font-weight: 500; }
.demo-bar-btn {
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 5px 11px;
  font-size: 12px;
  font-family: 'Instrument Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}
.demo-bar-btn:hover { background: rgba(255,255,255,0.38); }
body.demo-mode { padding-top: 38px; }
body.demo-mode .mini-topbar { top: 38px; }

/* PWA INSTALL FOOTER */
#pwa-nav-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  justify-content: center;
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
#screen-app.active ~ #pwa-nav-footer { display: none !important; }

@media (min-width: 480px) {
  .section { padding: 24px; }

  /* Header: full width, content aligned with body */
  .mini-topbar {
    width: 100vw;
    margin-left: calc(240px - 50vw);
    padding: 2px calc(50vw - 216px); /* 240 - 24 = 216 */
  }

  /* Navbar: full width, icons constrained to center 480px */
  .app-nav,
  #pwa-nav-footer {
    padding-left: calc(50vw - 240px);
    padding-right: calc(50vw - 240px);
  }

  /* Edit panel: full width, content constrained */
  .edit-panel-header {
    padding-left: calc(50vw - 220px);
    padding-right: calc(50vw - 220px);
  }
  .edit-panel-body {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Auth + Onboarding: full-width background, content constrained */
  #screen-auth {
    width: 100vw;
    margin-left: calc(240px - 50vw);
    padding-left: calc(50vw - 240px + 32px);
    padding-right: calc(50vw - 240px + 32px);
  }

  #screen-onboarding {
    padding-left: calc(50vw - 240px + 32px);
    padding-right: calc(50vw - 240px + 32px);
  }
  #screen-onboarding:not(.as-panel) {
    width: 100vw;
    margin-left: calc(240px - 50vw);
  }
  #screen-onboarding.as-panel {
    left: 0;
    right: 0;
  }
}
