/* DigiStuff app shell: install prompt + phone-only app chrome.
   Everything here is inert above 780px, so the desktop layout is unchanged. */

/* ------------------------------------------------------ install prompt */
.ds-install {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9000;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  transform: translateY(120%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.ds-install.show { transform: translateY(0); }
.ds-install-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  max-width: 560px;
  margin: 0 auto;
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}
.ds-install-icon { border-radius: 12px; grid-row: span 2; }
.ds-install-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ds-install-copy strong { font-size: 15px; color: var(--ink); }
.ds-install-copy span { font-size: 13px; line-height: 1.45; color: var(--ink-soft); }
.ds-install-actions {
  grid-column: 2;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.ds-install-actions button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
}
.ds-install-actions .ds-install-yes {
  background: var(--marker);
  border-color: var(--marker);
  color: #14202b;
  flex: 1 1 auto;
}

/* ---------------------------------------------------------- tab bar */
.ds-tabs { display: none; }

@media (max-width: 780px) {
  body.ds-has-tabs { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.ds-has-tabs.ds-has-actionbar { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }

  .ds-tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8000;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in oklab, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    border-top: 1.5px solid var(--line);
  }
  .ds-tabs a,
  .ds-tabs button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 50px;
    padding: 4px 2px;
    border: 0;
    background: none;
    font: inherit;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--ink-soft);
    text-decoration: none;
    border-radius: 12px;
    cursor: pointer;
  }
  .ds-tabs span { font-size: 19px; line-height: 1; }
  .ds-tabs .on,
  .ds-tabs a:active,
  .ds-tabs button:active { color: var(--marker-deep); background: color-mix(in oklab, var(--marker) 14%, transparent); }
  .ds-tabs .mid span { color: var(--marker-deep); }

  /* sticky primary action on tool pages */
  .ds-actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom));
    z-index: 7900;
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: color-mix(in oklab, var(--paper) 92%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
  }
  .ds-action-main,
  .ds-action-alt {
    min-height: 48px;
    border-radius: 13px;
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    border: 1.5px solid var(--marker);
  }
  .ds-action-main { flex: 1 1 auto; background: var(--marker); color: #14202b; }
  .ds-action-alt { flex: 0 0 auto; padding: 0 18px; background: transparent; color: var(--marker-deep); }

  /* mobile density */
  main h1 { letter-spacing: -0.01em; }
}

/* ------------------------------------------------------------ sheets */
.ds-scrim {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: flex-end;
  background: rgba(8, 12, 16, 0);
  transition: background 0.22s ease;
}
.ds-scrim.show { background: rgba(8, 12, 16, 0.5); }
body.ds-locked { overflow: hidden; }

.ds-sheet {
  width: 100%;
  max-height: 82vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1.5px solid var(--line);
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}
.ds-scrim.show .ds-sheet { transform: translateY(0); }
.ds-sheet-grip {
  width: 42px;
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  margin: 2px auto 12px;
}
.ds-sheet h3 { font-size: 15px; margin: 0 0 10px; color: var(--ink); }
.ds-sheet-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ds-sheet-links a,
.ds-sheet-links button {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.ds-sheet-links a:active,
.ds-sheet-links button:active { border-color: var(--marker); }
.ds-sheet-empty { grid-column: 1 / -1; font-size: 13.5px; color: var(--ink-soft); margin: 0; }

/* ------------------------------------------------------ search sheet */
.ds-search {
  width: 100%;
  height: 100dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom));
  background: var(--paper);
  transform: translateY(3%);
  opacity: 0;
  transition: transform 0.24s ease, opacity 0.24s ease;
}
.ds-scrim.show .ds-search { transform: translateY(0); opacity: 1; }
.ds-search-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.ds-search-bar input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 48px;
  padding: 0 14px;
  font-size: 16px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.ds-search-close {
  border: 0;
  background: none;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  color: var(--marker-deep);
  min-height: 44px;
  padding: 0 6px;
  cursor: pointer;
}
.ds-recent-label { display: block; font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 8px; }
.ds-search-recent { margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.ds-recent {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.ds-search-results { display: grid; gap: 8px; }
.ds-hit {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  text-decoration: none;
}
.ds-hit-i { font-size: 20px; color: var(--marker-deep); }
.ds-hit b { display: block; font-size: 14.5px; color: var(--ink); }
.ds-hit em { display: block; font-style: normal; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

/* ------------------------------------------------------ save button */
.ds-save {
  margin-left: 10px;
  vertical-align: middle;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ds-save:hover { transform: scale(1.06); }
.ds-save.on { color: var(--marker); border-color: var(--marker); }

/* standalone (installed) tweaks: give the header room under the status bar */
@media (display-mode: standalone) {
  header.tb-header { padding-top: env(safe-area-inset-top); }
  .tb-footer { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .ds-install, .ds-sheet, .ds-search, .ds-scrim { transition: none; }
}

/* consent banner must never sit on top of the mobile tab bar / action bar */
@media (max-width: 780px) {
  #ds-consent {
    bottom: calc(64px + env(safe-area-inset-bottom));
  }
  body.ds-has-actionbar #ds-consent {
    bottom: calc(126px + env(safe-area-inset-bottom));
  }
  #ds-consent .ds-consent-actions button { min-height: 44px; }
}
