:root {
  --primary: #ff385c;
  --primary-active: #e00b41;
  --primary-disabled: #ffd1da;
  --primary-error: #c13515;
  --luxe: #460479;
  --luxe-soft: #f3ebfa;
  --ink: #222222;
  --body-text: #3f3f3f;
  --muted: #6a6a6a;
  --muted-soft: #929292;
  --hairline: #dddddd;
  --hairline-soft: #ebebeb;
  --border-strong: #c1c1c1;
  --canvas: #ffffff;
  --surface-soft: #f7f7f7;
  --surface-strong: #f2f2f2;
  --on-primary: #ffffff;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  --shadow-1: 0 0 0 1px rgba(0, 0, 0, 0.02), 0 2px 6px rgba(0, 0, 0, 0.04), 0 4px 8px rgba(0, 0, 0, 0.1);

  --space-xxs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-base: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", Roboto, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-base) 48px;
  min-height: 100vh;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--muted);
}

/* --- Login --- */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: var(--space-lg);
}

.login-screen h1 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.18px;
  margin: 0;
  color: var(--ink);
}

.login-screen p {
  color: var(--muted);
  font-size: 16px;
  margin: 0;
}

.google-btn-slot {
  margin-top: var(--space-md);
}

.invite-note {
  background: var(--surface-soft);
  color: var(--ink);
  border: 1px solid var(--hairline);
  padding: var(--space-sm) var(--space-base);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
}

.error-note {
  background: #fdeceb;
  color: var(--primary-error);
  padding: var(--space-sm) var(--space-base);
  border-radius: var(--radius-sm);
  font-size: 13px;
  max-width: 320px;
}

/* --- Layout --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-base);
}

.topbar .who {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.topbar img.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
}

.topbar .name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}

.role-badge {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

.role-badge.viewer {
  background: var(--luxe-soft);
  color: var(--luxe);
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  padding: 6px 4px;
}

.icon-btn:hover { text-decoration: underline; }

/* --- Card --- */
.card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--space-base);
  margin-bottom: var(--space-md);
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 var(--space-md);
  color: var(--ink);
}

.banner {
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  padding: var(--space-base);
  margin-bottom: var(--space-md);
  font-size: 13px;
  line-height: 1.5;
  color: var(--body-text);
}

.banner strong { display: block; margin-bottom: var(--space-xs); color: var(--ink); }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
}

.summary-item {
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
}

.summary-item .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.summary-item .value {
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
  color: var(--ink);
}

/* --- Invite --- */
.invite-box {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.invite-url {
  display: flex;
  gap: var(--space-sm);
}

.invite-url input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-soft);
}

/* --- Buttons --- */
button {
  font-family: inherit;
}

.btn {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  height: 48px;
}

.btn:active { background: var(--primary-active); }

.btn.secondary {
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 13px 23px;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--hairline);
  padding: 13px 23px;
  height: auto;
}

.btn.block { width: 100%; }

.btn:disabled {
  background: var(--primary-disabled);
  color: var(--on-primary);
  cursor: not-allowed;
}

/* --- Calendar --- */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.calendar-header .month-label {
  font-weight: 600;
  font-size: 16px;
  color: var(--ink);
}

.calendar-header button {
  background: var(--surface-strong);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--ink);
  font-size: 14px;
}

.weekday-row, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.weekday-row div {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding-bottom: var(--space-sm);
}

.day-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ink);
}

.day-cell.empty { visibility: hidden; }

.day-cell .num {
  position: relative;
  z-index: 1;
}

.day-cell.period .num {
  background: var(--primary);
  color: var(--on-primary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-cell.predicted .num {
  border: 1.5px dashed var(--primary);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-cell.fertile { background: var(--luxe-soft); border-radius: var(--radius-xs); }

.day-cell.ovulation::after {
  content: "💧";
  position: absolute;
  top: 1px;
  right: 4px;
  font-size: 9px;
}

.day-cell.today .num {
  box-shadow: inset 0 0 0 1.5px var(--ink);
  border-radius: var(--radius-full);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-md);
  font-size: 12px;
  color: var(--muted);
}

.legend span { display: inline-flex; align-items: center; gap: var(--space-xs); }

.dot { width: 10px; height: 10px; border-radius: var(--radius-full); display: inline-block; }
.dot.period { background: var(--primary); }
.dot.predicted { border: 1.5px dashed var(--primary); }
.dot.fertile { background: var(--luxe-soft); border-radius: 3px; }

/* --- Form --- */
.form-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.form-row label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.form-row input, .form-row textarea {
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--canvas);
}

.form-row input:focus, .form-row textarea:focus {
  outline: none;
  border: 2px solid var(--ink);
  padding: 11px;
}

/* --- Log list --- */
.log-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 14px;
}

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

.log-item .dates { font-weight: 600; color: var(--ink); }
.log-item .note { color: var(--muted); font-size: 13px; }

.log-actions button {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
}

.log-actions button:hover { text-decoration: underline; }

.log-actions button.delete { color: var(--primary-error); }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: var(--space-xl) 0;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--on-primary);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  font-size: 13px;
  box-shadow: var(--shadow-1);
  z-index: 100;
}
