:root {
  --color-primary: #ff6b35;
  --color-primary-dark: #e2551f;
  --color-primary-light: #fff0e8;
  --color-bg: #f7f7fb;
  --color-surface: #ffffff;
  --color-text: #1f1f29;
  --color-muted: #6b6b76;
  --color-border: #e4e4ec;
  --color-success: #2e9e5b;
  --color-danger: #d64545;
  --radius: 14px;
  --tab-bar-height: 64px;
  --header-height: 56px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
}

body {
  min-height: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex: 0 0 var(--header-height);
  z-index: 10;
}

.app-header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.app-header h1 span {
  color: var(--color-primary);
}

.header-session {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-muted);
  font-size: 0.75rem;
}

.header-session[hidden] {
  display: none;
}

.header-logout {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
}

.header-logout:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .header-session [data-header-account] {
    display: none;
  }
}

.app-main {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-main::-webkit-scrollbar,
.modal::-webkit-scrollbar {
  display: none;
}

.tab-bar {
  position: relative;
  flex: 0 0 calc(var(--tab-bar-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  height: var(--tab-bar-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 20;
}

.tab-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
  color: var(--color-muted);
  font-size: 0.75rem;
  padding: 8px 0;
}

.tab-link .tab-icon {
  font-size: 1.3rem;
}

.tab-link[aria-current="page"] {
  color: var(--color-primary);
  font-weight: 700;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  width: 100%;
}

.btn:hover {
  background: var(--color-primary-dark);
}

.btn:focus-visible {
  outline: 3px solid #ffb199;
  outline-offset: 2px;
}

.btn.secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.btn.ghost {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn.danger {
  background: var(--color-danger);
}

.btn.small {
  width: auto;
  padding: 8px 12px;
  font-size: 0.85rem;
}

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

.btn-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
  color: var(--color-text);
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--color-primary);
}

.field .error-text {
  color: var(--color-danger);
  font-size: 0.8rem;
  margin-top: 4px;
}

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

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #fff1ea;
  color: var(--color-primary-dark);
}

.badge.success {
  background: #e7f7ec;
  color: var(--color-success);
}

.badge.danger {
  background: #fbeaea;
  color: var(--color-danger);
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
}

.empty-state, .error-state, .loading-state {
  text-align: center;
  color: var(--color-muted);
  padding: 32px 16px;
}

.error-state {
  color: var(--color-danger);
}

.feed-post {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  background: var(--color-surface);
}

.feed-post img {
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 10px;
  margin: 8px 0;
}

.feed-post-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.feed-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.like-btn[aria-pressed="true"] {
  color: var(--color-danger);
  font-weight: 700;
}

.comment-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comment-item {
  font-size: 0.85rem;
  background: var(--color-bg);
  border-radius: 8px;
  padding: 6px 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  scrollbar-width: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.toast-root {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 480px;
}

.toast {
  background: #1f1f29;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  text-align: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.summary-grid .stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.summary-grid .stat .value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-primary);
}

.summary-grid .stat .label {
  font-size: 0.78rem;
  color: var(--color-muted);
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.list-item:last-child {
  border-bottom: none;
}

.rule-box {
  background: #fff8f3;
  border: 1px solid #ffe0cc;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.rule-box ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.onboarding-header {
  background: linear-gradient(135deg, #fff8f3, #ffffff);
  border: 1px solid #ffd8c2;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.onboarding-header h2 { margin: 8px 0 6px; font-size: 1.15rem; }
.onboarding-header p { margin: 0; color: var(--color-muted); line-height: 1.55; }
.onboarding-step { color: var(--color-primary-dark); font-size: 0.78rem; font-weight: 800; }
.onboarding-progress { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: 14px; }
.onboarding-progress span { height: 5px; border-radius: 999px; background: var(--color-border); }
.onboarding-progress span.active { background: var(--color-primary); }

.auth-journey {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 18px 0;
  padding: 0;
  list-style: none;
}

.auth-journey li {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--color-muted);
  font-size: 0.72rem;
  text-align: center;
}

.auth-journey li:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 13px;
  left: calc(50% + 18px);
  width: calc(100% - 30px);
  height: 2px;
  background: var(--color-border);
}

.auth-journey span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: #fff;
  font-weight: 800;
}

.auth-journey li.active { color: var(--color-primary-dark); }
.auth-journey li.active span { border-color: var(--color-primary); background: var(--color-primary-light); }

.auth-tabs { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin:18px 0; padding:4px; border-radius:12px; background:#f2f4f7; }
.auth-tab { border:0; border-radius:9px; padding:10px; background:transparent; color:var(--color-muted); font:inherit; font-weight:700; cursor:pointer; }
.auth-tab.active { background:#fff; color:var(--color-primary-dark); box-shadow:0 1px 5px rgba(0,0,0,.09); }
.auth-next-step { margin-top:14px; text-align:center; }
.onboarding-journey { margin-top: 4px; }
.onboarding-journey li[aria-current="step"] span {
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.setup-complete-card h2 { margin: 12px 0 6px; }
.setup-complete-card p { margin-bottom: 0; color: var(--color-muted); }
.optional-label { color: var(--color-muted); font-size: 0.75rem; font-weight: 500; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.onboarding-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 14px;
}

.onboarding-account div {
  display: grid;
  gap: 3px;
}

.onboarding-account strong {
  font-size: 0.9rem;
}

.onboarding-account span {
  color: var(--color-muted);
  font-size: 0.78rem;
}

.onboarding-account .link-btn {
  flex: 0 0 auto;
}

.login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
  font-size: 1.2rem;
  margin: 0 0 4px;
  text-align: center;
}

.login-card h1 span {
  color: var(--color-primary);
}

.login-card > .hint-text {
  text-align: center;
  margin-bottom: 18px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 400;
}

.checkbox-label input {
  width: auto;
  margin-top: 2px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 700;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
}
