:root {
  --green: #07594f;
  --green-dark: #043e38;
  --mint: #eaf4f0;
  --burgundy: #7b0f38;
  --ink: #15322d;
  --muted: #61756f;
  --line: #d9e6e1;
  --white: #fff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #edf5f2;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { min-width: 300px; background: #edf5f2; }
button, a { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: calc(64px + env(safe-area-inset-top)) minmax(0, 1fr) calc(70px + env(safe-area-inset-bottom));
  background: var(--white);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(7px + env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 7px max(10px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .97);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 5px 24px rgba(18, 58, 48, .08);
  z-index: 20;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}
.brand img { width: 46px; height: 46px; border-radius: 11px; object-fit: contain; background: #fff; }
.brand-text { min-width: 0; display: grid; line-height: 1.05; }
.brand strong { font-size: 19px; letter-spacing: .08em; }
.brand small { margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.connection { display: none; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: #15946e; box-shadow: 0 0 0 4px rgba(21, 148, 110, .12); }
.connection.offline i { background: #b53434; box-shadow: 0 0 0 4px rgba(181, 52, 52, .12); }
.icon-button, .install-button {
  min-height: 39px;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  color: var(--green);
  background: #fff;
  text-decoration: none;
  font-weight: 800;
}
.icon-button { width: 39px; font-size: 20px; }
.install-button { padding: 0 13px; border-color: var(--green); color: #fff; background: var(--green); font-size: 12px; }
.install-button[hidden] { display: none; }
.icon-button:focus-visible, .install-button:focus-visible, .nav-item:focus-visible, .dialog-close:focus-visible { outline: 3px solid #f0b72d; outline-offset: 2px; }

.browser { position: relative; min-height: 0; overflow: hidden; background: linear-gradient(145deg, #eef6f2, #dcebe6); }
.browser iframe { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; border: 0; background: #fff; }
.loading { position: absolute; inset: 0; z-index: 1; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--green); font-size: 14px; font-weight: 800; }
.loading img { width: 96px; height: 96px; border-radius: 22px; object-fit: contain; animation: breathe 1.6s ease-in-out infinite; }
.loading.hidden { display: none; }
.noscript { position: absolute; inset: 20px; z-index: 5; display: grid; place-content: center; text-align: center; }
@keyframes breathe { 50% { transform: scale(1.04); opacity: .72; } }

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  padding: 5px max(5px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -5px 24px rgba(18, 58, 48, .08);
  z-index: 20;
}
.nav-item { min-width: 0; border: 0; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #637771; background: transparent; font-size: 9px; font-weight: 800; }
.nav-icon { min-width: 26px; height: 25px; padding: 0 4px; border-radius: 8px; display: grid; place-items: center; color: var(--green); background: var(--mint); font-size: 12px; }
.nav-item.active { color: var(--burgundy); background: #f8edf1; }
.nav-item.active .nav-icon { color: #fff; background: var(--burgundy); }
.nav-item.private .nav-icon { color: #fff; background: var(--green); }
.nav-item.private.active { color: var(--green-dark); background: var(--mint); }

dialog { width: min(calc(100% - 28px), 520px); max-height: calc(100dvh - 32px); overflow: auto; border: 0; border-radius: 24px; padding: 24px; color: var(--ink); box-shadow: 0 24px 80px rgba(16, 45, 39, .32); }
dialog::backdrop { background: rgba(10, 34, 29, .68); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; color: var(--ink); background: #edf4f1; font-size: 25px; line-height: 1; }
.dialog-logo { width: 70px; height: 70px; border-radius: 16px; object-fit: contain; }
dialog h1 { margin: 13px 42px 10px 0; font-size: 25px; }
dialog h2 { margin: 20px 0 8px; color: var(--green); font-size: 16px; }
dialog ol { margin: 8px 0 0; padding-left: 23px; line-height: 1.65; }
dialog li + li { margin-top: 5px; }
.dialog-note { margin: 20px 0 0; padding: 12px; border-radius: 12px; color: #526761; background: var(--mint); font-size: 12px; line-height: 1.5; }
.offline-message { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 40; width: min(calc(100% - 28px), 520px); transform: translateX(-50%); border-radius: 13px; padding: 12px 16px; color: #fff; background: #9c2e2e; box-shadow: 0 12px 35px rgba(44, 11, 11, .26); text-align: center; font-size: 12px; font-weight: 700; }

@media (min-width: 700px) {
  .app-shell { grid-template-rows: 72px minmax(0, 1fr) 76px; }
  .app-header { padding-left: 18px; padding-right: 18px; }
  .connection { display: flex; }
  .brand img { width: 52px; height: 52px; }
  .brand strong { font-size: 21px; }
  .brand small { font-size: 11px; }
  .install-button { padding: 0 18px; font-size: 13px; }
  .bottom-nav { padding-left: max(12px, calc((100% - 760px) / 2)); padding-right: max(12px, calc((100% - 760px) / 2)); }
  .nav-item { flex-direction: row; gap: 7px; font-size: 11px; }
}

@media (display-mode: standalone) {
  #install { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
