*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #000000;
  --fg: #ffffff;
  --fg-muted: rgba(255, 255, 255, 0.5);
  --fg-dim: rgba(255, 255, 255, 0.15);
  --card-border: rgba(255, 255, 255, 0.1);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* ── Frame ── */

.frame {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
}

/* ── Frame top ── */

.frame-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 4px;
  flex-shrink: 0;
  min-height: 44px;
}

.frame-top-left,
.frame-top-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.top-btn:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.92);
}

.install {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  height: 30px;
  padding: 0 12px;
  border-radius: 100px;
  border: 1px solid var(--fg-dim);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  display: none;
  transition: all 0.2s ease;
}

.install:active {
  background: rgba(255, 255, 255, 0.08);
}

.install.visible {
  display: inline-flex;
  align-items: center;
}

/* ── Stack (content area) ── */

.stack {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
}

.stack-content {
  width: 100%;
  padding: 20px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--fg);
  text-wrap: pretty;
  overflow-y: auto;
  max-height: 100%;
  -webkit-overflow-scrolling: touch;
}

.stack-content .about-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--fg);
}

.stack-content .about-text {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 300;
  line-height: 1.7;
  color: var(--fg-muted);
  white-space: pre-line;
}

.stack-content .about-text--hero {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--fg);
  padding: 32px 0;
}

.about-link {
  display: inline-block;
  margin-top: 24px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-decoration: none;
  border: 1px solid var(--fg-dim);
  border-radius: 100px;
  padding: 8px 20px;
  transition: all 0.2s ease;
}

.about-link:active {
  background: rgba(255, 255, 255, 0.08);
}

.stack-content .about-list {
  list-style: none;
  text-align: left;
  max-width: 380px;
  margin: 0 auto;
}

.stack-content .about-list li {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 300;
  line-height: 1.6;
  color: var(--fg-muted);
  padding: 5px 0 5px 20px;
  position: relative;
}

.stack-content .about-list li::before {
  content: '\2014';
  position: absolute;
  left: 0;
  color: var(--fg-dim);
}

/* ── Frame bottom ── */

.frame-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 4px));
  flex-shrink: 0;
  min-height: 56px;
}

.bot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.bot-btn:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.92);
}

.bot-btn.hidden {
  opacity: 0;
  pointer-events: none;
}

[hidden] {
  display: none !important;
}

.bot-btn svg {
  display: block;
}

.bot-btn--share {
  width: 56px;
  height: 56px;
  color: var(--fg);
  margin: 0 12px;
  border: 1px solid var(--fg-dim);
  border-radius: 50%;
}

.bot-btn--share:active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ── Dots ── */

.frame-dots {
  display: none;
  gap: 5px;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 12px;
}

.frame-dots.visible {
  display: flex;
}

.frame-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--fg-dim);
  transition: background 0.25s ease;
}

.frame-dot.active {
  background: var(--fg);
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--fg-muted);
  opacity: 0;
  transition: all 0.35s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Language select ── */

.lang-select-wrap {
  padding: 12px 0;
}

.lang-select {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--fg-dim);
  border-radius: 8px;
  padding: 10px 36px 10px 14px;
  width: 100%;
  max-width: 220px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  transition: border-color 0.2s ease;
}

.lang-select:focus {
  outline: none;
  border-color: var(--fg-muted);
}

.lang-select option {
  background: #111;
  color: var(--fg);
}

/* ── Desktop ── */

@media (min-width: 768px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #app {
    padding: 32px;
  }

  .frame {
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 4px 12px;
  }

  .stack-content {
    font-size: 1.7rem;
    padding: 32px 24px;
  }

  .stack-content .about-text--hero {
    font-size: 2rem;
    padding: 40px 0;
  }

  .about-link {
    font-size: 0.85rem;
  }

  .about-link:hover {
    background: rgba(255, 255, 255, 0.06);
  }

  .stack-content .about-title {
    font-size: 1.5rem;
  }

  .stack-content .about-text,
  .stack-content .about-list li {
    font-size: 0.95rem;
  }

  .bot-btn--share:hover {
    background: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
  }
}

@media (min-width: 1024px) {
  .stack-content {
    font-size: 2rem;
  }

  .stack-content .about-title {
    font-size: 1.6rem;
  }
}

@media (max-height: 640px) {
  .stack-content {
    font-size: 1.2rem;
    padding: 12px;
  }

  .stack-content .about-text--hero {
    font-size: 1.3rem;
    padding: 16px 0;
  }

  .about-link {
    font-size: 0.7rem;
    padding: 6px 16px;
  }

  .top-btn {
    width: 36px;
    height: 36px;
  }

  .bot-btn {
    width: 40px;
    height: 40px;
  }

  .bot-btn--share {
    width: 48px;
    height: 48px;
    margin: 0 8px;
  }

  .frame-top {
    padding: 4px 4px 2px;
    min-height: 36px;
  }

  .frame-bottom {
    padding: 2px 4px calc(2px + env(safe-area-inset-bottom, 2px));
    min-height: 44px;
  }
}

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