/* 모바일 세로 화면 우선. 버튼 최소 44px, 가로 스크롤 없음. */

* {
  box-sizing: border-box;
}

/* 여러 요소가 class로 display:flex 등을 지정해도 hidden 속성이 항상 이겨야 한다.
   (.banner/.answer-actions/.field가 display:flex를 쓰는데 UA 기본값과 동률이라
   author 스타일이 이겨버려 hidden이 무시되는 문제 — 실제 검증 중 발견) */
[hidden] {
  display: none !important;
}

:root {
  --accent: #5b4636;
  --accent-light: #f4ede4;
  --bg: #faf7f2;
  --text: #2b2620;
  --muted: #7a7267;
  --danger: #b3261e;
  --radius: 14px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  overflow-x: hidden;
}

body {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  background: var(--accent);
  color: white;
}

.app-header h1 {
  flex: 1;
  font-size: 1.05rem;
  margin: 0;
  text-align: center;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: 8px;
}

.icon-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

#app-main {
  flex: 1;
  padding: 16px;
  padding-bottom: 32px;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.screen.active {
  display: flex;
}

.lead {
  font-size: 1rem;
  line-height: 1.5;
  margin: 4px 0;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
}

.field > span:first-child {
  font-weight: 600;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="password"] {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #d8cfc2;
  border-radius: 10px;
  font-size: 1rem;
  background: white;
  color: var(--text);
  width: 100%;
}

.radio-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.radio-row label,
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}

.field-error {
  color: var(--danger);
  font-size: 0.82rem;
  min-height: 1em;
}

.btn-primary {
  min-height: 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:active {
  opacity: 0.85;
}

.btn-secondary {
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: white;
  color: var(--accent);
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: white;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  font-size: 0.9rem;
  min-height: 44px;
  cursor: pointer;
}

.card {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-clickable {
  border: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}

.card-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: var(--accent);
}

.myeongsik-summary {
  font-size: 1.4rem;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.card-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #fff3d6;
  border: 1px solid #e9c46a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.fortune-text {
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.topic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.topic-btn {
  min-height: 56px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.topic-btn:active {
  background: var(--accent);
  color: white;
}

.answer-body {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  min-height: 120px;
}

.answer-text {
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

.answer-disclaimer {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}

.loading {
  color: var(--muted);
  font-size: 0.95rem;
}

.answer-error {
  color: var(--danger);
  font-size: 0.92rem;
  line-height: 1.5;
}

.answer-actions {
  display: flex;
  gap: 10px;
}

.answer-actions button {
  flex: 1;
}

.notice {
  background: #eee;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  text-align: center;
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pillar-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.pillar-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.char-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 10px;
  border: 2px solid var(--border-color, #ccc);
  background: var(--bg-color, #fff);
  color: var(--fg-color, #333);
  font-size: 1.4rem;
  font-weight: 700;
  cursor: pointer;
}

.char-btn.disabled {
  opacity: 0.4;
  cursor: default;
}

.glossary-panel {
  background: white;
  border-radius: var(--radius);
  padding: 14px;
  min-height: 90px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.glossary-hint {
  color: var(--muted);
  margin: 0;
}

.glossary-char {
  font-size: 1.6rem;
  font-weight: 700;
  margin-right: 8px;
}

.glossary-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 6px;
}

.key-input-row {
  display: flex;
  gap: 8px;
}

.key-input-row input {
  flex: 1;
}

.key-status {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recent-item {
  background: white;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
}

.recent-item .recent-meta {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 4px;
}

@media (max-width: 360px) {
  .myeongsik-summary {
    font-size: 1.2rem;
  }
}
