#app,
.view {
  display: block;
  width: 100%;
  min-width: 0;
}

#app[hidden],
.view[hidden] {
  display: none;
}

nav {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: min(286px, 84vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: #f5f3ff;
  border-radius: 0;
  transform: translateX(0);
  transition: transform .2s ease;
}

body.sidebar-open {
  overflow: hidden;
}

body.home-mode,
body.garage-mode,
body.delivery-mode,
body.invitations-mode {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

.home-mode .shell,
.garage-mode .shell,
.delivery-mode .shell,
.invitations-mode .shell {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

.delivery-mode .shell {
  padding-bottom: env(safe-area-inset-bottom);
}

.sidebar-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: #4f46e5;
}

.sidebar-head strong {
  letter-spacing: .18em;
  font-weight: 700;
}

.sidebar-head button {
  width: 42px;
  min-height: 42px;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 0;
  background: transparent;
  color: #4f46e5;
  font-size: 1.8rem;
  line-height: 1;
}

.sidebar-collapsed nav {
  transform: translateX(-102%);
  pointer-events: none;
}

nav button {
  width: 100%;
  min-width: 0;
  min-height: 54px;
  flex: none;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  text-align: left;
  white-space: normal;
  line-height: 1.15;
  font-size: .92rem;
  font-weight: 500;
  border-radius: 2px;
  background: transparent;
  color: #444;
}

nav button.active {
  background: #4f46e5;
  color: #fff;
}

nav button:disabled {
  background: #eeeef2;
  color: #777;
}

nav button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

nav button small {
  margin: 0;
  font-size: .62rem;
  color: inherit;
  opacity: .72;
  font-weight: 500;
}

.sidebar-scrim {
  position: fixed;
  z-index: 29;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgb(17 17 17 / 28%);
}

.general-message {
  margin: 0 0 20px;
  padding: 16px;
  border-radius: 7px;
  background: #f5f3ff;
}

.general-message p:last-child {
  margin-bottom: 0;
}

.general-message p:not(.eyebrow) {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

#homeView {
  height: calc(100dvh - 96px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: hidden;
}

#homeView .general-message {
  height: 100%;
  margin: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

#homeView .general-message h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vh, 1.65rem);
  line-height: 1.12;
}

#homeView .general-message p {
  margin: 0;
}

#homeView .general-message p:not(.eyebrow) {
  font-size: clamp(.75rem, 1.62vh, .9rem);
  line-height: 1.3;
}

@media (max-height: 650px) {
  #homeView .general-message {
    padding: 12px;
  }

  #homeView .general-message h2 {
    font-size: 1.18rem;
  }

  #homeView .general-message p:not(.eyebrow) {
    font-size: .72rem;
    line-height: 1.24;
  }
}

#deliveryView {
  height: calc(100dvh - 72px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

#deliveryView[hidden] {
  display: none;
}

#deliveryView .section-title,
#deliveryView .inline-code-form {
  flex: none;
}

#deliveryView .delivery-title {
  margin: 0 0 8px;
}

#deliveryView .delivery-title .eyebrow {
  margin: 0;
  color: #6366f1;
  font-size: .72rem;
}

#codes {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  padding-bottom: 8px;
}

#codes .code-card {
  margin: 6px 0;
  padding: 10px 12px;
  border-radius: 5px;
}

#codes .code-row {
  align-items: center;
  gap: 8px;
}

#codes .code-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .92rem;
}

#codes .badge {
  flex: none;
  padding: 3px 6px;
  font-size: .68rem;
}

#codes p {
  margin: 4px 0;
  font-size: .76rem;
  line-height: 1.25;
}

#codes .code-actions {
  gap: 6px;
  margin-top: 6px;
}

#codes .code-actions button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: .78rem;
}

.empty-state {
  min-height: 54dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
}

.empty-state svg {
  width: 42px;
  height: 42px;
  margin-bottom: 16px;
  fill: none;
  stroke: #4f46e5;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-state p {
  margin: 0;
}

.garage-page {
  height: calc(100dvh - 96px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: 0;
  font-size: .88rem;
  overflow-y: hidden;
  padding-bottom: 8px;
}

.garage-page:not(.allow-scroll) {
  touch-action: none;
  overscroll-behavior: none;
}

.garage-page.allow-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.garage-page .detail-heading {
  margin-bottom: 12px;
}

.garage-page .detail-heading h1 {
  font-size: 1.55rem;
}

.garage-page .detail-heading p {
  margin: 4px 0 0;
}

.garage-page .primary {
  padding-block: 12px;
}

.garage-page .garage-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: #a3a3a3;
  color: #fff;
  opacity: 1;
  cursor: wait;
}

.garage-spinner {
  width: 17px;
  height: 17px;
  flex: none;
  border: 2px solid rgb(255 255 255 / 45%);
  border-top-color: #fff;
  border-radius: 50%;
  animation: garage-spin .75s linear infinite;
}

@keyframes garage-spin {
  to { transform: rotate(360deg); }
}

.garage-help {
  margin-top: 12px;
}

.garage-help h2 {
  margin: 8px 0;
  font-size: 1rem;
}

.garage-method {
  margin-bottom: 7px;
  padding: 9px 10px;
  border-radius: 7px;
  background: #f5f3ff;
}

.garage-method p,
.garage-safety {
  margin: 3px 0 0;
  font-size: .8rem;
  line-height: 1.3;
}

.garage-safety {
  padding: 8px 10px;
  background: #f3f3f3;
}

.inline-code-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.inline-code-form label {
  margin: 0 0 10px;
}

.inline-code-form input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 17px;
  padding: 10px 12px;
  border: 0;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
  background-clip: padding-box;
  box-shadow: inset 0 0 0 1px #d8d8df;
}

.inline-code-form input:focus {
  box-shadow: inset 0 0 0 2px #6366f1;
}

.inline-code-form > button {
  width: 40px;
  height: 40px;
  min-width: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #6366f1;
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1;
  box-shadow: none;
}

.garage-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 12px;
  padding: 3px;
  border-radius: 7px;
  background: #f1f1f1;
}

.garage-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #666;
  font: inherit;
  font-weight: 800;
}

.garage-tabs button.active {
  background: #fff;
  color: #111;
}

.garage-only-mode .garage-page,
.garage-only-mode .invitations-page {
  height: calc(100dvh - 148px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.invitations-page {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 12px;
}

.invitations-page .detail-heading {
  margin-bottom: 8px;
}

.invitations-page .detail-heading p:last-child {
  margin: 4px 0 0;
  font-size: .84rem;
}

#invitationForm {
  display: grid;
  gap: 8px;
}

#invitationForm label {
  gap: 5px;
  margin: 0;
  font-size: .82rem;
}

#invitationForm input {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  font-size: 16px;
  box-shadow: inset 0 0 0 1px #d8d8df;
}

#invitationForm .primary {
  padding-block: 11px;
}

.invitation-summary {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 14px 0 7px;
  color: #555;
  font-size: .78rem;
}

.invitation-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  padding: 10px 11px;
  border-radius: 7px;
  background: #f5f3ff;
}

.invitation-card div,
.invitation-card strong,
.invitation-card span {
  min-width: 0;
}

.invitation-card strong,
.invitation-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invitation-card strong {
  font-size: .82rem;
}

.invitation-card span {
  margin-top: 2px;
  color: #666;
  font-size: .75rem;
}

.invitation-card button {
  border: 0;
  background: transparent;
  color: #b42318;
  font: inherit;
  font-size: .75rem;
  font-weight: 800;
}

.invitation-empty {
  margin-top: 10px;
}

@media (prefers-reduced-motion: reduce) {
  nav {
    transition: none;
  }
}
