/* PHASE 1 minimal styles — real Premium/Mystic design system comes in Phase 2. */

:root {
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: #0b0713;
  color: #f2eefc;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: hidden; /* prevent horizontal overflow on iPhone */
  min-height: 100dvh;
}

.app-shell {
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

h1 {
  font-size: 24px;
  margin: 0;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0;
  color: #b8a8d9;
  font-size: 14px;
}

.status-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
  word-break: break-word;
}

.status-box.status-error {
  background: rgba(255, 80, 80, 0.12);
  border-color: rgba(255, 80, 80, 0.4);
  color: #ffb3b3;
}

.result-block {
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ==========================================================================
   Phase 2 — Product UI (홈 / 카테고리 / 질문 / 타로마스터 선택)
   Mobile-first, 390px baseline; verified additionally at 375/393/430px.
   ========================================================================== */

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  animation: screen-fade-in 0.25s ease;
}

@keyframes screen-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-center {
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 60vh;
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0 0;
  line-height: 1.35;
}

.screen-subtitle {
  font-size: 14px;
  color: #b8a8d9;
  margin: 0;
}

.back-btn {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f2eefc;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
}

.error-banner {
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(255, 80, 80, 0.12);
  border: 1px solid rgba(255, 80, 80, 0.4);
  color: #ffb3b3;
  font-size: 14px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #d4af37;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: #b8a8d9;
  font-size: 14px;
}

/* ---- Buttons ---- */

.btn-primary,
.btn-secondary {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  border-radius: 14px;
  padding: 14px 20px;
  cursor: pointer;
  border: none;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #7a3fc9, #d4af37);
  color: #16091f;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f2eefc;
}

.btn-large {
  padding: 16px 24px;
  font-size: 17px;
}

/* ---- Home screen ---- */

.home-header {
  text-align: center;
  padding: 32px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand-mark {
  letter-spacing: 0.12em;
  font-size: 13px;
  color: #d4af37;
  margin: 0;
}

.home-question {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
}

.home-subtext {
  font-size: 14px;
  color: #b8a8d9;
  margin: 0;
}

.home-cta-area {
  padding: 12px 0 8px;
}

.recent-section {
  margin-top: 8px;
}

.section-title {
  font-size: 15px;
  color: #b8a8d9;
  margin: 0 0 10px;
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  cursor: pointer;
}

.recent-item-category {
  font-weight: 600;
}

.recent-item-reader,
.recent-item-card {
  color: #b8a8d9;
}

/* ---- Category grid ---- */

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f2eefc;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.category-card:active {
  background: rgba(255, 255, 255, 0.1);
}

.category-icon {
  font-size: 26px;
}

.category-name {
  font-size: 16px;
  font-weight: 700;
}

.category-desc {
  font-size: 12px;
  color: #b8a8d9;
  line-height: 1.4;
}

/* ---- Question input ---- */

.category-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: #d4af37;
  font-size: 13px;
  font-weight: 600;
}

.question-textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f2eefc;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
}

.question-textarea:focus {
  outline: none;
  border-color: #d4af37;
}

.question-textarea::placeholder {
  color: #6f6285;
}

.char-counter {
  align-self: flex-end;
  font-size: 12px;
  color: #6f6285;
}

.field-error {
  color: #ffb3b3;
  font-size: 13px;
  margin: 0;
}

.bottom-cta {
  margin-top: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

/* ---- Reader (타로마스터) selection ---- */

.reader-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reader-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f2eefc;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.reader-card:active {
  background: rgba(255, 255, 255, 0.1);
}

.reader-card:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.reader-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.reader-avatar-large {
  width: 96px;
  height: 96px;
}

.reader-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.reader-name {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.reader-tone {
  font-size: 13px;
  color: #b8a8d9;
  margin: 0;
  line-height: 1.4;
}

.reader-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.reader-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #d9cdf0;
}

/* Narrowest supported width (iPhone SE-class, 375px) needs slightly tighter
   grid gaps so two category cards never overflow. */
@media (max-width: 380px) {
  .category-grid {
    gap: 10px;
  }
  .category-card {
    padding: 14px 12px;
  }
}
