* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

/* 40~60대 사용자를 고려해 기본 글자 크기를 한 단계 키운다. rem 기반 크기가
   전부 여기에 비례하므로 사실상 앱 전체 텍스트가 함께 커진다. */
html {
  font-size: 118.75%; /* 16px 기준 → 19px */
}

body {
  background:
    radial-gradient(ellipse 140% 90% at 50% 108%,
      #3A2028 0%, var(--rosewood) 38%, var(--noir-rose) 100%);
  background-attachment: fixed;
  color: var(--blush-veil);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 2.0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* §3.1 미세 그레인 — 평면 색을 깨뜨리는 아주 옅은 노이즈 한 장 */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.25;
  margin: 0;
}

p {
  margin: 0;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

input, textarea {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
}

a {
  color: var(--ash-rose);
}

.display {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1.25;
}

.label {
  font-family: var(--font-label);
  font-size: 0.875rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--mauve-mute);
}

:focus-visible {
  outline: 1px solid var(--pearl);
  outline-offset: 4px;
}

.screen {
  min-height: 100vh;
  width: 100%;
  position: relative;
  z-index: 1;
}

.main-home-button {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-ui);
  background: rgba(49, 28, 35, 0.88);
  color: var(--blush-veil);
  font-family: var(--font-label);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-decoration: none;
  backdrop-filter: blur(10px);
  transition: background 200ms var(--ease-arc), border-color 200ms var(--ease-arc), opacity 200ms var(--ease-arc);
}

.main-home-button:hover {
  background: rgba(74, 40, 50, 0.96);
  border-color: var(--rose-quartz);
}

.main-home-button.is-hidden {
  display: none;
}

.main-home-icon {
  font-size: 1.05rem;
  line-height: 1;
}

@media (max-width: 639px) {
  .main-home-button {
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    padding: 0.35rem 0.7rem;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* §5 로즈 윈도우 — 모든 화면 뒤에 깔리는 시그니처 실루엣 */
.rose-window {
  position: fixed;
  bottom: 0;
  left: 50%;
  width: 130vw;
  aspect-ratio: 1;
  transform: translateX(-50%) rotate(0deg);
  transform-origin: center center;
  pointer-events: none;
  z-index: 0;
  opacity: 0.10;
  animation: rose-spin 240s linear infinite;
}

.rose-window svg {
  width: 100%;
  height: 100%;
  display: block;
}

.rose-window.is-muted {
  opacity: 0.05;
}

@keyframes rose-spin {
  to {
    transform: translateX(-50%) rotate(360deg);
  }
}

/* §3.3 버튼 — 테두리 버튼이 기본. 채워진 버튼(.btn-primary)은 화면당 하나 이하 */
.btn,
.btn-ghost {
  background: transparent;
  border: 1px solid var(--rose-quartz);
  border-radius: var(--radius-ui);
  padding: 0.9rem 2.4rem;
  font-family: var(--font-label);
  font-size: 0.9rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--blush-veil);
  transition: background 240ms var(--ease-arc), border-color 240ms var(--ease-arc), color 240ms var(--ease-arc);
}

.btn:hover,
.btn-ghost:hover {
  background: rgba(184, 115, 127, 0.14);
  border-color: var(--pearl);
}

.btn:disabled,
.btn-ghost:disabled {
  border-color: var(--hairline);
  color: var(--mauve-mute);
  background: transparent;
}

.btn-primary {
  border-color: var(--pearl);
  color: var(--blush-veil);
}

.btn-primary:hover {
  background: rgba(230, 214, 190, 0.12);
}

.btn-primary:disabled {
  border-color: var(--hairline);
  color: var(--mauve-mute);
}

/* ---------- 홈 (#/) ---------- */

.home-screen {
  max-width: 62ch;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  padding: var(--space-4) 24px;
  text-align: center;
}

@media (min-width: 640px) {
  .home-screen {
    padding: var(--space-5) min(8vw, 120px);
  }
}

.home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.home-rule {
  width: 120px;
  height: 1px;
  background: var(--hairline);
}

.home-header h1 {
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  color: var(--blush-veil);
}

.home-subtitle {
  font-family: var(--font-body);
  color: var(--mauve-mute);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.spread-list {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.spread-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--hairline);
  text-align: left;
  transition: background 240ms var(--ease-arc);
}

.spread-list .spread-row:last-child {
  border-bottom: 1px solid var(--hairline);
}

.spread-row:hover,
.spread-row:focus-visible {
  background: rgba(184, 115, 127, 0.08);
}

.spread-row-index {
  flex-shrink: 0;
  width: 2em;
  color: var(--ash-rose);
}

.spread-row-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spread-row-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--blush-veil);
}

.spread-row-subtitle {
  font-family: var(--font-body);
  color: var(--mauve-mute);
  font-size: 0.85rem;
}

.spread-row-count {
  flex-shrink: 0;
  color: var(--mauve-mute);
}

.home-tagline {
  color: var(--mauve-mute);
  font-size: 0.85rem;
}

.journal-link {
  color: var(--mauve-mute);
  font-family: var(--font-label);
  font-size: 0.8125rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-decoration: none;
}

.journal-link:hover {
  color: var(--ash-rose);
}

/* ---------- 오프라인 배지 ---------- */

.fallback-badge {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  background: var(--rosewood);
  border: 1px solid var(--hairline);
  border-top: none;
  color: var(--mauve-mute);
  font-family: var(--font-label);
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  padding: 4px 14px;
  border-radius: 0 0 var(--radius-overlay) var(--radius-overlay);
  transition: transform 240ms var(--ease-arc);
  z-index: 3000;
}

.fallback-badge.is-visible {
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .rose-window {
    animation: none;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
