:root {
  color-scheme: light;
  --olive: #3e5641;
  --olive-deep: #304533;
  --sage: #84a98c;
  --cream: #faf7f2;
  --paper: #ffffff;
  --charcoal: #1f2937;
  --muted: #667085;
  --line: rgba(62, 86, 65, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--cream);
  color: var(--charcoal);
}

button,
a { font: inherit; }

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: 46px minmax(0, 1fr);
  background: var(--cream);
}

.shell-bar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  color: #fff;
  background: linear-gradient(100deg, var(--olive-deep), var(--olive));
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 12px rgba(31, 41, 55, 0.12);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand img {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.shell-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.secure-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.82);
}

.secure-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cde8d2;
  box-shadow: 0 0 0 4px rgba(205, 232, 210, 0.1);
}

.install-button {
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 999px;
  padding: 6px 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.install-button:hover,
.install-button:focus-visible { background: rgba(255, 255, 255, 0.18); }

.portal-frame {
  position: relative;
  min-height: 0;
  background:
    radial-gradient(circle at 90% 8%, rgba(132, 169, 140, 0.24), transparent 33%),
    var(--cream);
}

#portal {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: var(--cream);
  opacity: 0;
  transition: opacity 260ms ease;
}

.is-ready #portal { opacity: 1; }

.loading-panel,
.fallback-panel {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  text-align: center;
  background:
    radial-gradient(circle at 15% 85%, rgba(132, 169, 140, 0.2), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(62, 86, 65, 0.13), transparent 30%),
    var(--cream);
}

.loading-panel[hidden],
.fallback-panel[hidden] { display: none; }

.loading-mark { border-radius: 15px; box-shadow: 0 14px 34px rgba(48, 69, 51, 0.18); }

.loading-title {
  margin: 18px 0 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  font-weight: 700;
}

.loading-copy,
.fallback-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.loading-line {
  width: min(220px, 70vw);
  height: 3px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(62, 86, 65, 0.12);
}

.loading-line::after {
  content: "";
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: var(--sage);
  animation: loading 1.25s ease-in-out infinite;
}

.fallback-panel h1 {
  max-width: 520px;
  margin: 18px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.fallback-panel p { max-width: 520px; line-height: 1.55; }

.fallback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.fallback-actions button,
.fallback-actions a {
  min-width: 132px;
  border-radius: 10px;
  padding: 10px 16px;
  text-decoration: none;
  cursor: pointer;
}

.fallback-actions button {
  border: 1px solid var(--olive);
  color: #fff;
  background: var(--olive);
}

.fallback-actions a {
  border: 1px solid var(--line);
  color: var(--olive-deep);
  background: var(--paper);
}

.support-link {
  margin-top: 18px;
  color: var(--olive);
  font-size: 0.84rem;
}

.noscript { margin: 24px; }

@keyframes loading {
  0% { transform: translateX(-110%); }
  55%, 100% { transform: translateX(240%); }
}

@media (max-width: 560px) {
  .app-shell { grid-template-rows: 42px minmax(0, 1fr); }
  .secure-state { display: none; }
  .brand { font-size: 0.98rem; }
  .brand img { width: 27px; height: 27px; }
}

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