.weekly-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px 56px;
  background: var(--bg-main, #f7f9fd);
  min-height: 100vh;
  box-sizing: border-box;
}

.weekly-calendar-section {
  background: #fff;
  border-radius: 24px;
  padding: 24px 32px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.weekly-detail-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.weekly-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  color: #222;
}

.weekly-period-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #666;
}

.weekly-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #f0f3ff;
  color: #4a5cff;
  cursor: pointer;
}

.weekly-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.weekly-day {
  background: #f9fbff;
  border-radius: 14px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.weekly-day-label {
  font-size: 11px;
  font-weight: 500;
  color: #9aa0b5;
}

.weekly-day-date {
  font-size: 18px;
  font-weight: 600;
  color: #222;
}

.weekly-day-dots {
  display: flex;
  gap: 4px;
}

.weekly-day-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.weekly-day-dot.success {
  background: #30c85a;
}

.weekly-day-dot.miss {
  background: #ff6b6b;
}

.weekly-day-dot.late {
  background: #ffa94d;
}

.weekly-day.active {
  border-color: #4a5cff;
  background: #eef1ff;
  box-shadow: 0 0 0 1px rgba(74, 92, 255, 0.15);
}

.weekly-legend {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 11px;
  color: #888;
}

.legend-item::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 6px;
}

.legend-success::before {
  background: #30c85a;
}

.legend-miss::before {
  background: #ff6b6b;
}

.legend-late::before {
  background: #ffa94d;
}

.weekly-card {
  background: #fff;
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.intake-manual-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.intake-manual-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.manual-date-field {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #666;
  gap: 4px;
}

.manual-date-field input {
  border: 1px solid #d9deff;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 14px;
}

.manual-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.manual-drug-column,
.manual-input-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.manual-field-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: #333;
}

.manual-group-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.manual-group-controls select {
  flex: 1;
  border: 1px solid #d9deff;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}

.manual-drug-list {
  border: 1px solid #eef0fb;
  border-radius: 16px;
  padding: 12px;
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f9fbff;
}

.manual-drug-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #222;
}

.manual-drug-item input {
  width: 16px;
  height: 16px;
}

.manual-input-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.manual-input-row label,
.manual-memo-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #444;
}

.manual-input-row select,
.manual-input-row input,
.manual-memo-field textarea {
  border: 1px solid #d9deff;
  border-radius: 12px;
  padding: 10px;
  font-size: 14px;
  background: #fff;
}

.manual-memo-field textarea {
  resize: vertical;
  min-height: 84px;
}

.manual-condition-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: #444;
}

.condition-emoji-group {
  display: flex;
  gap: 8px;
}

.condition-emoji-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: #f4f6ff;
  cursor: pointer;
  font-size: 20px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.condition-emoji-btn.is-selected {
  border-color: #4a5cff;
  background: #eef1ff;
  transform: translateY(-2px);
}

.manual-primary-btn,
.manual-secondary-btn {
  border-radius: 12px;
  border: none;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.manual-primary-btn {
  background: linear-gradient(90deg, #4a5cff, #7b8bff);
  color: #fff;
  box-shadow: 0 8px 18px rgba(74, 92, 255, 0.2);
}

.manual-secondary-btn {
  background: #eef1ff;
  color: #4a5cff;
  border: 1px solid #dfe3ff;
}

.manual-primary-btn:hover,
.manual-secondary-btn:hover {
  transform: translateY(-1px);
}

.manual-block-btn {
  width: 100%;
}


/* 로컬 저장 복용 기록 표시 */
.weekly-history-item.from-local {
  background: linear-gradient(to right, #f8f9ff, #fff);
  border-left: 3px solid #4a5cff;
  padding-left: 12px;
}

.weekly-card-title {
  font-size: 16px;
  font-weight: 600;
  color: #233;
  margin-bottom: 14px;
}

.weekly-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.weekly-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  transition: background 0.15s ease;
}

.weekly-history-item:hover {
  background: #f8f9ff;
}

.weekly-history-time {
  font-size: 14px;
  color: #555;
}

.weekly-history-pill-name {
  font-size: 14px;
  color: #222;
  margin-left: 12px;
}

.weekly-history-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weekly-history-detail {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #666;
  margin-left: auto;
  text-align: right;
}

.weekly-history-extra {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.weekly-history-memo {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weekly-history-status {
  min-width: 60px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  text-align: center;
  color: #fff;
}

.weekly-history-status.success {
  background: #30c85a;
}

.weekly-history-status.miss {
  background: #ff6b6b;
}

.weekly-history-status.late {
  background: #ffa94d;
}

.weekly-history-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weekly-history-delete {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #f0f0f0;
  color: #999;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.weekly-history-item:hover .weekly-history-delete {
  opacity: 1;
}

.weekly-history-delete:hover {
  background: #ff6b6b;
  color: #fff;
}

.weekly-summary-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.weekly-summary-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.weekly-summary-label {
  font-size: 12px;
  color: #666;
}

.weekly-summary-bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #f1f3fb;
  overflow: hidden;
}

.weekly-summary-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4a5cff, #7b8bff);
}

@media (max-width: 1200px) {
  .weekly-detail-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .weekly-page {
    padding: 24px 32px;
  }

  .weekly-calendar-section,
  .weekly-detail-section {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .weekly-page {
    gap: 16px;
    padding: 16px;
  }

  .weekly-calendar-section,
  .weekly-card {
    padding: 16px;
    border-radius: 18px;
  }

  .weekly-calendar-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
  }

  .page-title {
    font-size: 18px;
  }

  .weekly-calendar {
    gap: 8px;
  }

  .weekly-day {
    padding: 8px 6px;
    border-radius: 12px;
  }

  .weekly-day-label {
    font-size: 10px;
  }

  .weekly-day-date {
    font-size: 15px;
  }

  .weekly-detail-section {
    gap: 16px;
  }

  .weekly-card-title {
    font-size: 16px;
    margin-bottom: 14px;
  }

  .weekly-history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .weekly-history-status {
    align-self: flex-end;
  }

  .manual-section-grid {
    grid-template-columns: 1fr;
  }

  .weekly-legend {
    flex-wrap: wrap;
    gap: 12px;
  }
}
