:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --brand: #2563eb;
  --brand-soft: #dbeafe;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #f59e0b;
  --warn-soft: #fff7ed;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.app-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 14px 12px 88px;
}

.loading-card,
.auth-card,
.wait-card,
.empty-card,
.admin-card,
.recipe-card,
.section-card,
.menu-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.loading-card,
.auth-card,
.wait-card,
.empty-card {
  padding: 22px;
  margin-top: 24px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 23px; letter-spacing: -0.04em; }
h2 { font-size: 20px; letter-spacing: -0.035em; }
h3 { font-size: 17px; letter-spacing: -0.02em; }
p { color: var(--muted); line-height: 1.55; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  margin: -14px -12px 12px;
  padding: 12px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.app-title strong {
  font-size: 19px;
  letter-spacing: -0.04em;
}

.app-title span {
  color: var(--muted);
  font-size: 13px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge-owner { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-pending { background: var(--warn-soft); color: #b45309; }
.badge-comment { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.badge-ok { background: var(--ok-soft); color: #15803d; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  min-height: 40px;
  border-radius: 13px;
  padding: 9px 13px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
}

.btn-primary { background: var(--brand); color: white; }
.btn-ok { background: var(--ok); color: white; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
.btn-wide { width: 100%; }
.btn-small { min-height: 34px; padding: 7px 10px; font-size: 13px; }

.form-stack {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.input, .textarea, .select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  outline: none;
}

.textarea {
  resize: vertical;
  min-height: 96px;
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  background: var(--soft);
  border-radius: 16px;
  margin-bottom: 16px;
}

.auth-tabs button {
  min-height: 42px;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.auth-tabs button.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.08);
}

.notice {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.notice strong { color: var(--ink); }
.notice-warn { border-color: #fed7aa; background: var(--warn-soft); color: #9a3412; }
.notice-danger { border-color: #fecaca; background: var(--danger-soft); color: #991b1b; }

.week-controls {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.week-label {
  text-align: center;
  font-weight: 900;
  font-size: 14px;
  color: var(--ink);
}

.day-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.day-tab {
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: 54px;
  border-radius: 15px;
  background: white;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 900;
}

.day-tab.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.day-tab small {
  font-size: 11px;
  opacity: 0.86;
}

.recipe-card {
  padding: 14px;
  margin: 12px 0;
}

.recipe-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.recipe-head h2 {
  margin: 0;
  font-size: 20px;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.section-card {
  margin: 10px 0;
  overflow: hidden;
}

.section-head,
.menu-head {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  text-align: left;
  background: white;
  padding: 14px;
}

.section-title,
.menu-title {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.section-title strong,
.menu-title strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.chevron {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--muted);
  font-weight: 900;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: #334155;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
  max-width: 100%;
}

.menu-card {
  margin: 8px 12px 12px;
  box-shadow: none;
}

.menu-body {
  border-top: 1px solid var(--line);
  padding: 6px 10px 10px;
}

.ingredient-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 4px;
  border-bottom: 1px solid #eef2f7;
}

.ingredient-row:last-child { border-bottom: 0; }

.check {
  width: 24px;
  height: 24px;
  accent-color: var(--ok);
}

.ingredient-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ingredient-name {
  font-size: 16px;
  font-weight: 850;
  line-height: 1.35;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.ingredient-row.done .ingredient-name {
  color: #475569;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.last-action {
  color: var(--muted);
  font-size: 12px;
}

.comment-button {
  min-height: 34px;
  border-radius: 999px;
  padding: 6px 9px;
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}

.comment-button.empty {
  background: var(--soft);
  border-color: var(--line);
  color: var(--muted);
}

.admin-card {
  margin: 12px 0;
  padding: 14px;
}

.admin-grid {
  display: grid;
  gap: 12px;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}

.log-item {
  background: #fbfdff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.42);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.modal {
  width: min(560px, 100%);
  max-height: min(78vh, 720px);
  overflow: auto;
  background: white;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
  padding: 16px;
}

.comment-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.comment-item {
  border-radius: 14px;
  background: var(--soft);
  padding: 10px;
}

.comment-item strong { display: block; margin-bottom: 3px; }
.comment-item p { color: var(--ink); margin: 0 0 5px; }
.comment-item small { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 80;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  border-radius: 16px;
  padding: 12px 14px;
  background: #0f172a;
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow);
}

@media (max-width: 520px) {
  .app-shell { padding: 10px 8px 86px; }
  .topbar { margin: -10px -8px 10px; padding: 10px 8px; }
  .topbar-row { align-items: flex-start; }
  .actions { justify-content: flex-end; }
  .btn { min-height: 38px; padding: 8px 10px; }
  .section-head,
  .menu-head { padding: 12px; gap: 8px; }
  .recipe-card { padding: 10px; }
  .day-tabs { gap: 4px; }
  .day-tab { min-height: 50px; border-radius: 13px; font-size: 13px; }
  .ingredient-row { grid-template-columns: auto minmax(0, 1fr); }
  .ingredient-row .comment-button { grid-column: 2; justify-self: start; margin-top: 2px; }
  .admin-item { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 8px; }
  .modal { border-radius: 20px 20px 0 0; }
}
